![](/img/trans.png)
[英]Telegram bot with telegraf.js : can't send random photo to chat using flickr api
[英]How to resolve Telegram API error . 403 CHAT_WRITE_FORBIDDEN You can't write in this chat
基本上我有一个组(我是管理员),我希望能够以编程方式添加和踢出用户。 我使用我的电报帐户创建了一个电报应用程序。 我想访问方法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,
}),
})
);
但出现错误:
RPCError: 403: CHAT_WRITE_FORBIDDEN (由 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.banMember 方法来实现删除功能。 为此,需要将机器人添加到具有管理员权限的电报组。 我也觉得这种方式简单得多。 除了直接在电报中向用户发送消息外,您几乎可以做任何事情。 –
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.