Guest User

Untitled

a guest
Sep 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. const Telegraf = require('telegraf')
  2.  
  3. const bot = new Telegraf(process.env.BOT_TOKEN)
  4.  
  5. const spam_suspect = new Map();
  6.  
  7. bot.on('channel_post', async (ctx) => {
  8. let chat_id = ctx.chat.id;
  9. let msg = ctx.update.channel_post.text;
  10. // console.log(ctx)
  11. if (msg.match(/t\.me\/joinchat/i)) {
  12. ctx.telegram.deleteMessage(chat_id, ctx.update.channel_post.message_id);
  13. }
  14.  
  15. if (msg.match(/porno/i)) {
  16. ctx.telegram.deleteMessage(chat_id, ctx.update.channel_post.message_id);
  17. }
  18.  
  19. if (ctx.update.channel_post.reply_to_message !== undefined) {
  20. let comment_is_spam = ctx.update.channel_post.text.match(/spam/i)
  21. if (comment_is_spam) {
  22. let msg_id = ctx.update.channel_post.reply_to_message.message_id
  23. let vote_counter = spam_suspect.get(msg_id) || 1;
  24. if (vote_counter < 2) {
  25. vote_counter++;
  26. spam_suspect.set(msg_id, vote_counter)
  27. } else {
  28. spam_suspect.delete(msg_id)
  29. ctx.telegram.deleteMessage(chat_id, msg_id);
  30. }
  31. }
  32. }
  33. })
  34.  
  35. bot.startPolling()
Add Comment
Please, Sign In to add comment