Last active
August 22, 2021 19:33
-
-
Save requeijaum/35ccec77d41013feadbf70d6977b9bf5 to your computer and use it in GitHub Desktop.
Bot kickador de bots para Telegram - invocar gogogo.sh via crontab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/52029026/telegram-python-bot-event-when-bot-is-added-to-a-group | |
# https://github.com/python-telegram-bot/python-telegram-bot | |
TOKEN = "" | |
from telegram.ext import Updater, MessageHandler, Filters | |
from telegram import Bot | |
import re | |
exp_list = [r'(.{4,}_\d{4,})|((.{4,}\d{4,}))' ] #, r'.{4,}'] | |
chat_id = "@nomedogrupo" | |
botObj = Bot(token=TOKEN) | |
def new_member(update, context): | |
for member in update.message.new_chat_members: | |
# https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html?highlight=kick#telegram.Bot.ban_chat_member | |
for exp in exp_list : | |
if re.match(exp, member.username) : | |
# https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/bot.py#L2349 | |
if botObj.ban_chat_member(chat_id=chat_id, user_id=member.id) : | |
update.message.reply_text('Tchau, queride ' + member.username + ' id=' + str(member.id) + ' !') | |
print('\nO kick/ban veio para:') | |
print(member) | |
print(update.message.new_chat_members) | |
updater = Updater(TOKEN, use_context=True) # use_context will be True by default in version 13+ | |
updater.dispatcher.add_handler(MessageHandler(Filters.status_update.new_chat_members, new_member)) | |
updater.start_polling() | |
updater.idle() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $(screen -r | grep "telegram-kick_a_bot") ]] ; | |
then echo "kick_a_bot ja esta funcionando"; | |
else echo "subindo kick_a_bot..." ; screen -dmS telegram-kick_a_bot python3.9 bot.py ; | |
fi ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment