0

Kick a Chat Member

by
Published Jun 6, 2022
Script telegram Verified

The script

Submitted by hugo989 Bun
Verified 6 days ago
1
import { Telegram as Telegraf } from "[email protected]";
2

3
/**
4
 * @param until_date Unix time. If user is banned for more than
5
 * 366 days or less than 30 seconds from the current time they
6
 * are considered to be banned forever.
7
 *
8
 * @param revoke_messages If `true` then the banned user's messages
9
 * will be deleted from the chat.
10
 */
11
type Telegram = {
12
  token: string;
13
};
14
export async function main(
15
  auth: Telegram,
16
  chat_id: string,
17
  user_id: number,
18
  until_date?: number,
19
  revoke_messages?: boolean | undefined,
20
) {
21
  const client = new Telegraf(auth.token);
22
  return await client.banChatMember(chat_id, user_id, until_date || undefined, {
23
    revoke_messages,
24
  });
25
}
26

Other submissions
  • Submitted by adam186 Deno
    Created 398 days ago
    1
    import { Telegram } from "npm:[email protected]";
    2
    
    
    3
    /**
    4
     * @param until_date Unix time. If user is banned for more than
    5
     * 366 days or less than 30 seconds from the current time they
    6
     * are considered to be banned forever.
    7
     *
    8
     * @param revoke_messages If `true` then the banned user's messages
    9
     * will be deleted from the chat.
    10
     */
    11
    type Telegram = {
    12
      token: string;
    13
    };
    14
    export async function main(
    15
      auth: Telegram,
    16
      chat_id: string,
    17
      user_id: number,
    18
      until_date?: number,
    19
      revoke_messages?: boolean | undefined,
    20
    ) {
    21
      const client = new Telegram(auth.token);
    22
      return await client.banChatMember(chat_id, user_id, until_date || undefined, {
    23
        revoke_messages,
    24
      });
    25
    }
    26