Add support for kicking Telegram users from Matrix

This commit is contained in:
Tulir Asokan
2017-12-03 22:50:57 +02:00
parent 8a082a4598
commit debcf0dc29
3 changed files with 38 additions and 7 deletions
+9 -3
View File
@@ -448,17 +448,23 @@ class Portal {
}
async kickTelegram(telegramPOV, user) {
let updates
if (this.peer.type === "chat") {
const updates = await telegramPOV.client("messages.deleteChatUser", {
updates = await telegramPOV.client("messages.deleteChatUser", {
chat_id: this.peer.id,
user_id: user.toPeer(telegramPOV).toInputObject(),
})
console.log("Chat kick result:", updates)
} else if (this.peer.type === "channel") {
throw new Error("I don't know how to kick users from channels :(")
this.loadAccessHash(telegramPOV)
updates = await telegramPOV.client("channels.kickFromChannel", {
channel: this.peer.toInputObject(),
user_id: user.toPeer(telegramPOV).toInputObject(),
kicked: true,
})
} else {
throw new Error(`Can't invite user to peer type ${this.peer.type}`)
}
await telegramPOV.handleUpdate(updates)
}
/**