2021-05-12 22:07:00 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
import { InputPeerLike } from '../../types'
|
2021-05-15 20:25:59 +03:00
|
|
|
import { isInputPeerChannel } from '../../utils/peer-utils'
|
2021-05-12 22:07:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Kick a user from a chat.
|
|
|
|
*
|
|
|
|
* This effectively bans a user and immediately unbans them.
|
|
|
|
*
|
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param userId User ID
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function kickChatMember(
|
|
|
|
this: TelegramClient,
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
userId: InputPeerLike
|
|
|
|
): Promise<void> {
|
2021-05-15 20:25:59 +03:00
|
|
|
const chat = await this.resolvePeer(chatId)
|
|
|
|
const user = await this.resolvePeer(userId)
|
2021-05-12 22:07:00 +03:00
|
|
|
|
|
|
|
await this.banChatMember(chat, user)
|
|
|
|
|
|
|
|
// not needed in case this is a legacy group
|
|
|
|
if (isInputPeerChannel(chat)) {
|
|
|
|
await this.unbanChatMember(chat, user)
|
|
|
|
}
|
|
|
|
}
|