Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Telegraf = require('telegraf')
- const bot = new Telegraf(process.env.BOT_TOKEN)
- const spam_suspect = new Map();
- bot.on('channel_post', async (ctx) => {
- let chat_id = ctx.chat.id;
- let msg = ctx.update.channel_post.text;
- // console.log(ctx)
- if (msg.match(/t\.me\/joinchat/i)) {
- ctx.telegram.deleteMessage(chat_id, ctx.update.channel_post.message_id);
- }
- if (msg.match(/porno/i)) {
- ctx.telegram.deleteMessage(chat_id, ctx.update.channel_post.message_id);
- }
- if (ctx.update.channel_post.reply_to_message !== undefined) {
- let comment_is_spam = ctx.update.channel_post.text.match(/spam/i)
- if (comment_is_spam) {
- let msg_id = ctx.update.channel_post.reply_to_message.message_id
- let vote_counter = spam_suspect.get(msg_id) || 1;
- if (vote_counter < 2) {
- vote_counter++;
- spam_suspect.set(msg_id, vote_counter)
- } else {
- spam_suspect.delete(msg_id)
- ctx.telegram.deleteMessage(chat_id, msg_id);
- }
- }
- }
- })
- bot.startPolling()
Add Comment
Please, Sign In to add comment