This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.ts
62 lines (51 loc) · 1.77 KB
/
bot.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Bot, Context, InlineKeyboard } from './deps.deno.ts';
import { botToken, joinCheckId, joinCheckEnabled } from './config.ts';
export const bot = new Bot(botToken);
// custom filters
const decorator = bot.filter(async (ctx: Context) => {
// if joincheck is not enabled, return true
if (!joinCheckEnabled) {
return true;
}
// store const's
const isPrivate = ctx.chat?.type === 'private';
const userId = Number(ctx.from?.id);
const member = await ctx.api.getChatMember(joinCheckId, userId);
const isMember =
member.status === 'member' ||
member.status === 'creator' ||
member.status === 'administrator';
// if user is not a member, also send a message to ask user to join channel
if (!isMember) {
const joinChannel = 'DivideProjects';
await ctx.reply(`You have to join my channel @${joinChannel} to use me!`, {
reply_markup: new InlineKeyboard().url(
'Join Channel',
`https://t.me/${joinChannel}`,
),
});
}
return isMember && isPrivate;
});
decorator.command(
'start',
async (ctx: Context) =>
await ctx.reply(`Hello ${ctx.from?.first_name}
I'm ${ctx.me?.first_name} and I can send the file that you send me, without the forwarded from tag!`),
);
decorator.command(
'help',
async (ctx: Context) =>
await ctx.reply(`This bot will send back the document/file/pic/video/image/text that you forward, back to you, so that the forwarded from tag is removed and it looks like it's forwarded from the bot!!
Made with ❤️ by @DivideProjects`),
);
decorator.command(
'ping',
async (ctx: Context) => await ctx.reply(`Pong! ${new Date()} ${Date.now()}`),
);
decorator
.on([':media', ':file'])
.on(
':forward_date',
async (ctx: Context) => await ctx.copyMessage(Number(ctx.chat?.id)),
);