![](/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.