如何解决电报API错误。403 CHAT_WRITE_FORBIDDEN 你不能在这个聊天中写



基本上我有一个组(其中我是管理员),我希望能够添加和踢出用户编程。我用我的电报账户创建了一个电报应用程序。我想访问方法channels.EditBanned。该组是使用创建应用程序的相同帐户创建的。这个:

new Api.channels.EditBanned({
channel: "Test_Channel",
participant: "vishalkale151071",
bannedRights: new Api.ChatBannedRights({
untilDate: 43,
viewMessages: 0,
sendMessages: 1,
sendMedia: true,
sendStickers: true,
sendGifs: false,
sendGames: true,
sendInline: true,
sendPolls: true,
changeInfo: true,
inviteUsers: true,
pinMessages: true,
}),
})
); 

But got error:

RPCError: 403: CHAT_WRITE_FORBIDDEN (caused by channels. editprohibited)

参考:https://gram.js.org/tl/channels/EditBanned

禁止/踢人你可以使用:

new Api.channels.EditBanned({
channel: new Api.InputChannel({
channelId: <channel_id>,
accessHash: BigInt(<hash>),
}),
participant: <user_id>,
bannedRights: new Api.ChatBannedRights({
untilDate: 43,
viewMessages: true,
sendMessages: true,
sendMedia: true,
sendStickers: true,
sendGifs: true,
sendGames: true,
sendInline: true,
sendPolls: true,
changeInfo: true,
inviteUsers: true,
pinMessages: true,
}),
})
要获取通道accessHash和id,必须在调用createChannel时存储结果:
const result = await client.invoke(
new Api.channels.CreateChannel({
title: "grupo-legal-2",
about: "about test",
broadcast: true,
// megagroup: true,
// forImport: true,
geoPoint: new Api.InputGeoPoint({
lat: -26.30444,
long: -48.84556,
accuracyRadius: 100,
}),
address: "address test",
})
);
console.log(result);
console.log(result.chats[0].id);
console.log(result.chats[0].accessHash);

好的。由于我对项目有一个截止日期,所以我最终通过创建一个bot并调用bot来实现删除功能。banMember方法。为此,需要将bot添加到具有管理员权限的电报组。而且我觉得这样更简单。除了在电报中直接向用户发送消息外,您几乎可以做任何事情。-

相关内容

最新更新