class Config(object): # get a token from https://chatbase.com CHAT_BASE_TOKEN = os.environ.get("CHAT_BASE_TOKEN", "") # get a token from @BotFather TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "") bot = amanobot.aio.Bot(TG_BOT_TOKEN) na_bot = amanobot.Bot(TG_BOT_TOKEN) loop = asyncio.get_event_loop() # Do not change this me = loop.run_until_complete(bot.getMe()) bot_username = me[zedgeimadebot] bot_id = me[339329843] # The Telegram API things APP_ID = int(os.environ.get("APP_ID", 12345)) API_HASH = os.environ.get("API_HASH") # Get these values from my.telegram.org # Array to store users who are authorized to use the bot AUTH_USERS = set(str(x) for x in os.environ.get("AUTH_USERS", "").split()) # reg: Procedures UTUBE_BOT_USERS = set( str(x) for x in os.environ.get("UTUBE_BOT_USERS", "").split()) SUPER_DLBOT_USERS = set( str(x) for x in os.environ.get("SUPER_DLBOT_USERS", "").split()) SUPER3X_DLBOT_USERS = set( str(x) for x in os.environ.get("SUPER3X_DLBOT_USERS", "").split()) SUPER7X_DLBOT_USERS = set( str(x) for x in os.environ.get("SUPER7X_DLBOT_USERS", "").split()) BANNED_USERS = [] # Wat was I thinking? :\ # the download location, where the HTTP Server runs DOWNLOAD_LOCATION = "./DOWNLOADS" # Telegram maximum file upload size MAX_FILE_SIZE = 50000000 TG_MAX_FILE_SIZE = 1572864000 FREE_USER_MAX_FILE_SIZE = 50000000 # chunk size that should be used with requests CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", 128)) # default thumbnail to be used in the videos DEF_THUMB_NAIL_VID_S = os.environ.get("DEF_THUMB_NAIL_VID_S", "https://placehold.it/90x90") # for storing the user details DB_SQLALCHEMY = "USERS.session" # proxy for accessing youtube-dl in GeoRestricted Areas # Get your own proxy from https://github.com/rg3/youtube-dl/issues/1091#issuecomment-230163061 HTTP_PROXY = os.environ.get("HTTP_PROXY", "") # https://t.me/hevcbay/951 OUO_IO_API_KEY = "" # for Google Custom Search Engine GCS_API_KEY = os.environ.get("GCS_API_KEY", None) GCS_SE_ID = os.environ.get("GCS_SE_ID", None) # dict to hold the ReQuest queue ADL_BOT_RQ = {} # set timeout for subprocess PROCESS_MAX_TIMEOUT = 3600 # dict to hold Google Drive SignIns G_DRIVE_AUTH_DRQ = {}
def buck_sudp(bot, update): chat = update.message.chat_id if str(update.message.from_user.id) == '652890017': ctime = int(time.time()) bot = amanobot.Bot(TOKEN) sent = bot.sendMessage(chat,'Iniciando....') with zipfile.ZipFile('backup-{}.zip'.format(ctime), 'w', zipfile.ZIP_DEFLATED) as backup: for folder, subfolders, files in os.walk('.'): for file in files: if file != 'backup-{}.zip'.format(ctime) and not file.endswith('.pyc'): backup.write(os.path.join(folder, file)) bot.editMessageText((chat, sent['message_id']), 'enviando...') bot.sendDocument(chat, open('backup-{}.zip'.format(ctime), 'rb')) bot.editMessageText((chat, sent['message_id']), '✅ Backup concluído!') os.remove('backup-{}.zip'.format(ctime))
import sys import time import amanobot from amanobot.loop import MessageLoop """ $ python3 skeleton.py <token> A skeleton for your amanobot programs. """ def handle(msg): flavor = amanobot.flavor(msg) summary = amanobot.glance(msg, flavor=flavor) print(flavor, summary) TOKEN = sys.argv[1] # get token from command-line bot = amanobot.Bot(TOKEN) MessageLoop(bot, handle).run_as_thread() print('Listening ...') # Keep the program running. while 1: time.sleep(10)
import amanobot import amanobot.aio import asyncio token = "TOKEN DO SEU BOT" loop = asyncio.get_event_loop() # Do not change this bot = amanobot.aio.Bot(token) na_bot = amanobot.Bot(token) me = loop.run_until_complete(bot.getMe()) bot_username = me['username'] bot_id = me['id'] keys = dict( here={ 'app_id': 'key_id_here', 'app_code': 'key_code_here' }, #You can get a key at https://here.com yandex= 'trnsl.1.1.20190811T184100Z.f3e1e6d6d3507525.7ea9c786af32b18cedeb125ca46cc2d9ee154e09', #You can get a key at https://tech.yandex.com/translate giphy= '7f6ws7EvslO9BuaAKie9BieyYnD3OkkT', #You can get a key at https://developers.giphy.com ) git_repo = ('https://github.com/AmanoTeam/EduuRobot', 'master' ) #Repository where your bot is in max_time = 60
# -*- coding: utf-8 -*- import amanobot from amanobot.loop import MessageLoop import time bot = amanobot.Bot('TOKENAKI') def handle(msg): if msg['text'] == '/start': bot.sendMessage(msg['chat']['id'], 'Olá') # toda vez que um usuário digitar /start uma mensagem sera enviada para o mesmo no caso a mensagem enviada sera Olá elif msg['text'] == '/help': bot.sendMessage(msg['chat']['id'], 'em que posso ajudar') MessageLoop(bot, handle).run_as_thread() while 1: time.sleep(10)
``` [Here is a tutorial](http://www.instructables.com/id/Set-up-Telegram-Bot-on-Raspberry-Pi/) teaching you how to setup a bot on Raspberry Pi. This simple bot does nothing but accepts two commands: - `/roll` - reply with a random integer between 1 and 6, like rolling a dice. - `/time` - reply with the current time, like a clock. """ def handle(msg): chat_id = msg['chat']['id'] command = msg['text'] print('Got command: %s' % command) if command == '/roll': bot.sendMessage(chat_id, random.randint(1, 6)) elif command == '/time': bot.sendMessage(chat_id, str(datetime.datetime.now())) bot = amanobot.Bot('*** INSERT TOKEN ***') MessageLoop(bot, handle).run_as_thread() print('I am listening ...') while 1: time.sleep(10)
async def misc(msg): if msg.get('text'): #aqui ele repete as coisas com echo kkjjj if msg['text'].startswith('fala') or msg['text'].startswith('!echo'): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], '{} pra caralho'.format(msg['text'][5:]), reply_to_message_id=reply_id) return True #owna nasa ele responde nasa pra caralho kkjj elif msg['text'].startswith('owna'): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], '{} pra caralho'.format(msg['text'][5:]), reply_to_message_id=reply_id) return True #sla mano elif msg['text'].startswith('sla'): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], '{} ta foda.'.format(msg['text'][4:]), reply_to_message_id=reply_id) return True elif msg['text'].startswith('/mark') or msg['text'].startswith( '!mark'): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'markdown', reply_to_message_id=reply_id) return True elif msg['text'] == '/admins' or msg['text'] == '!admins' or msg[ 'text'] == 'admin': if msg['chat']['type'] == 'private': await bot.sendMessage( msg['chat']['id'], 'Este comando s? funciona em grupos ?\\_(?)_/?') else: adms = await bot.getChatAdministrators(msg['chat']['id']) names = 'Admins:\n\n' for num, user in enumerate(adms): names += '{} - <a href="tg://user?id={}">{}</a>\n'.format( num + 1, user['user']['id'], html.escape(user['user']['first_name'])) await bot.sendMessage(msg['chat']['id'], names, 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/token') or msg['text'].startswith( '!token'): text = msg['text'][7:] try: bot_token = amanobot.Bot(text).getMe() bot_name = bot_token['first_name'] bot_user = bot_token['username'] bot_id = bot_token['id'] await bot.sendMessage(msg['chat']['id'], f'''informacoes do bot: Nome: {bot_name} Username: @{bot_user} ID: {bot_id}''', reply_to_message_id=msg['message_id']) except TelegramError: await bot.sendMessage(msg['chat']['id'], 'Token inv?lido.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/bug') or msg['text'].startswith('!bug'): text = msg['text'][5:] if text == '' or text == bot_username: await bot.sendMessage( msg['chat']['id'], '''*Uso:* `/bug <descrição do bug>` - _Reporta erro/bug para a equipe de desenvolvimento deste bot, so devem ser reportados bugs sobre este bot!_ obs.: Mal uso há possibilidade de ID\_ban''', 'markdown', reply_to_message_id=msg['message_id']) else: await bot.sendMessage( logs, f"""<a href="tg://user?id={msg['from']['id']}">{msg['from'][ 'first_name']}</a> reportou um bug: ID: <code>{msg['from']['id']}</code> Mensagem: {text}""", 'HTML') await bot.sendMessage( msg['chat']['id'], 'O bug foi reportado com sucesso para a minha equipe!', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/dogbin') or msg['text'].startswith( '!dogbin'): text = msg['text'][8:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage( msg['chat']['id'], '''*Uso:* `/dogbin <texto>` - _envia um texto para o del.dog._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_dogbin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/hastebin') or msg['text'].startswith( '!hastebin'): text = msg['text'][9:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage( msg['chat']['id'], '''*Uso:* `/hastebin <texto>` - _envia um texto para o hastebin._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_hastebin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/html') or msg['text'].startswith( '!html'): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'html', reply_to_message_id=reply_id) return True elif msg['text'] == 'ban' or msg['text'] == '/ban': try: await bot.unbanChatMember(msg['chat']['id'], msg['from']['id']) except TelegramError: await bot.sendMessage( msg['chat']['id'], 'Nao deu pra te remover, voc? deve ser um admin ou eu nao sou admin.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/request ') or msg['text'].startswith( '!request '): if re.match(r'^(https?)://', msg['text'][9:]): text = msg['text'][9:] else: text = 'http://' + msg['text'][9:] try: async with aiohttp.ClientSession() as session: r = await session.get(text) except Exception as e: return await bot.sendMessage( msg['chat']['id'], str(e), reply_to_message_id=msg['message_id']) headers = '<b>Status-Code:</b> <code>{}</code>\n'.format( str(r.status)) headers += '\n'.join('<b>{}:</b> <code>{}</code>'.format( x, html.escape(r.headers[x])) for x in r.headers) rtext = await r.text() if len(rtext) > 3000: content = await r.read() res = await send_to_dogbin(content) else: res = '<code>' + html.escape(rtext) + '</code>' await bot.sendMessage( msg['chat']['id'], '<b>Headers:</b>\n{}\n\n<b>Conte?do:</b>\n{}'.format( headers, res), 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'] == 'suco': if msg['from']['id'] in sudoers: is_sudo = 'é gostozinho' else: is_sudo = 'tem gosto de bosta' await bot.sendMessage(msg['chat']['id'], is_sudo + '?', reply_to_message_id=msg['message_id']) return True elif msg['text'].lower() == 'rt' and msg.get('reply_to_message'): if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt': if not re.match( '🔃 .* foi gado pra caralho do filho da puta do :\n\n👤 .*', text): await bot.sendMessage( msg['chat']['id'], '''🔃 <b>{}</b> foi gado pra caralho concordando com o --> 👤 <b>{}</b>: <i>{}</i>'''.format( msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True
u(32), u(33), 2, # clear 29,30, skip 28 u(31), # clear 31,32,33 u(39), u(36), 2, u(37), 7, # clear 36,37,39 u(28), # discard u(38), # discard u(40), # return ] def handle(msg): print msg bot = amanobot.Bot('abc') webhook = OrderedWebhook(bot, handle) webhook.run_as_thread(maxhold=8) for update in sequence: if type(update) is dict: webhook.feed(update) time.sleep(1) else: time.sleep(update)
import amanobot import dotenv import os from amanobot.loop import MessageLoop from amanobot.delegate import per_chat_id, create_open, pave_event_space bot_key = os.environ["TOKEN"] bot = amanobot.Bot(os.environ.get("TOKEN")) #Token do bot # '' me = bot.getMe() bot_username = me['username'] bot_id = me['id'] git_repo = os.environ["git_repo"] #Repositório onde seu bot está max_time = 60 version = os.environ["version"] logs = os.environ["logs"] sudoers = [197005208] keys = ['abdf158215d05e1a973510c5c81d9a2cdd99ad2c7cd8'] class Config(object): # get a token from https://chatbase.com CHAT_BASE_TOKEN = os.environ["CHAT_BASE_TOKEN"] # get a token from @BotFather TG_BOT_TOKEN = os.environ.get("TOKEN") # your domain to show when download file is greater than MAX_FILE_SIZE HTTP_DOMAIN = os.environ["HTTP_DOMAIN"]
async def misc(msg): if msg.get('text'): #aqui ele repete as coisas com echo kkjjj if msg['text'].startswith('fala') or msg['text'].startswith('/echo')or msg['text'].startswith('echo') or msg['text'] == '/echo@' + bot_username: print('Usuario {} solicitou echo'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou echo --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'],'{} pra caralho'.format(msg['text'][5:]), reply_to_message_id=reply_id) return True #owna nasa ele responde nasa pra caralho kkjj elif msg['text'].startswith('owna'): print('Usuario {} solicitou owna'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou owna --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'],'{} pra caralho esta porra filho da puta!'.format(msg['text'][5:]), reply_to_message_id=reply_id) return True #sla mano elif msg['text'].startswith('sla') : if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'],'{} ta foda este lance.'.format(msg['text'][4:]), reply_to_message_id=reply_id) return True elif msg['text'].startswith('/mark') or msg['text'].startswith('!mark') or msg['text'] == '/mark@' + bot_username: print('Usuario {} solicitou /mark'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /,ark --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'markdown', reply_to_message_id=reply_id) return True elif msg['text'] == '/admins' or msg['text'] == '/admin' or msg['text'] == 'admin' or msg['text'] == '/admin@' + bot_username: print('Usuario {} solicitou /admins'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /admin --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg['chat']['type'] == 'private': await bot.sendMessage(msg['chat']['id'], 'Este comando s? funciona em grupos ?\\_(?)_/?') else: adms = await bot.getChatAdministrators(msg['chat']['id']) names = 'Admins:\n\n' for num, user in enumerate(adms): names += '{} - <a href="tg://user?id={}">{}</a>\n'.format(num + 1, user['user']['id'], html.escape(user['user']['first_name'])) await bot.sendMessage(msg['chat']['id'], names, 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/token') or msg['text'].startswith('!token') or msg['text'] == '/token@' + bot_username: print('Usuario {} solicitou /token'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /token --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() text = msg['text'][7:] try: bot_token = amanobot.Bot(text).getMe() bot_name = bot_token['first_name'] bot_user = bot_token['username'] bot_id = bot_token['id'] await bot.sendMessage(msg['chat']['id'], f'''informacoes do bot: Nome: {bot_name} Username: @{bot_user} ID: {bot_id}''', reply_to_message_id=msg['message_id']) except TelegramError: await bot.sendMessage(msg['chat']['id'], 'Token invalido.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/bug') or msg['text'].startswith('!bug') or msg['text'] == '/bug@' + bot_username: print('Usuario {} solicitou /bug'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /bug --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() text = msg['text'][5:] if text == '' or text == bot_username: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/bug <descrição do bug>` - _Reporta erro/bug para a equipe de desenvolvimento deste bot, so devem ser reportados bugs sobre este bot!_ obs.: Mal uso há possibilidade de ID\_ban''', 'markdown', reply_to_message_id=msg['message_id']) else: await bot.sendMessage(logs, f"""<a href="tg://user?id={msg['from']['id']}">{msg['from'][ 'first_name']}</a> reportou um bug: ID: <code>{msg['from']['id']}</code> Mensagem: {text}""", 'HTML') await bot.sendMessage(msg['chat']['id'], 'O bug foi reportado com sucesso para a minha equipe!', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/dogbin') or msg['text'].startswith('!dogbin') or msg['text'] == '/dogbin@' + bot_username or msg['text'] == 'dogbin': print('Usuario {} solicitou /dogbin'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /dogbin --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() text = msg['text'][8:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/dogbin <texto>` - _envia um texto para o del.dog._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_dogbin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/hastebin') or msg['text'].startswith('!hastebin') or msg['text'] == '/hastebin@' + bot_username or msg['text'] == 'hastebin' or msg['text'] == 'pastebin': print('Usuario {} solicitou /hastebin'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /hastebin --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() text = msg['text'][9:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/hastebin <texto>` - _envia um texto para o hastebin._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_hastebin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/html') or msg['text'].startswith('!html') or msg['text'] == '/html@' + bot_username or msg['text'] == 'html': print('Usuario {} solicitou /html'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou /html --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'html', reply_to_message_id=reply_id) return True elif msg['text'] == 'ban' or msg['text'] == '/ban' or msg['text'] == '/gorpo@' + bot_username: print('Usuario {} solicitou ban'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou ban --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() try: await bot.unbanChatMember(msg['chat']['id'], msg['from']['id']) except TelegramError: await bot.sendMessage(msg['chat']['id'], 'Nao deu pra te remover, voce.... deve ser um admin ou eu nao sou admin nesta bosta.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/request') or msg['text'].startswith('!request') or msg['text'] == '/request@' + bot_username or msg['text'] == 'request': if re.match(r'^(https?)://', msg['text'][9:]): text = msg['text'][9:] else: text = 'http://' + msg['text'][9:] try: async with aiohttp.ClientSession() as session: r = await session.get(text) except Exception as e: return await bot.sendMessage(msg['chat']['id'], str(e), reply_to_message_id=msg['message_id']) headers = '<b>Status-Code:</b> <code>{}</code>\n'.format(str(r.status)) headers += '\n'.join('<b>{}:</b> <code>{}</code>'.format(x, html.escape(r.headers[x])) for x in r.headers) rtext = await r.text() if len(rtext) > 3000: content = await r.read() res = await send_to_dogbin(content) else: res = '<code>' + html.escape(rtext) + '</code>' await bot.sendMessage(msg['chat']['id'], '<b>Headers:</b>\n{}\n\n<b>Conteudo:</b>\n{}'.format(headers, res), 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'] == 'suco': if msg['from']['id'] in sudoers: is_sudo = 'é gostozinho' else: is_sudo = 'tem gosto de bosta' await bot.sendMessage(msg['chat']['id'], is_sudo + '?', reply_to_message_id=msg['message_id']) return True elif msg['text'].lower() == 'rt' and msg.get('reply_to_message'): print('Usuario {} solicitou rt'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou rt --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt' or msg['text'] == '/rt@' + bot_username or msg['text'] == 'rtt': if not re.match('🔃 .* foi gado pra caralho do filho da puta do :\n\n👤 .*', text): await bot.sendMessage(msg['chat']['id'], '''🔃 <b>{}</b> foi gado pra caralho concordando com o --> 👤 <b>{}</b>: <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True #--------------------------------------------------------------------------------------------------------------- elif msg['text'].lower() == 'gay' and msg.get('reply_to_message'): print('Usuario {} solicitou gay'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou gay --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt' or msg['text'] == 'rtt': if not re.match('🔃 .* chamou de gay e pode sofrer processo do :\n\n👤 .*', text): await bot.sendMessage(msg['chat']['id'], '''<b>{} pode tomar um processo pois foi estupido para caralho xingando {} de gay, este viado e bicha loca do caralho só porque ele disse</b> <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True #--------------------------------------------------------------------------------------------------------------- elif msg['text'].lower() == 'pau no cu' or msg['text'].lower() == 'pnc'and msg.get('reply_to_message'): print('Usuario {} solicitou pau no cu(rt)'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou pau no cu(rt) --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt' or msg['text'] == 'rtt': if not re.match('🔃 .* chamou de pau no cu e pode sofrer processo do :\n\n👤 .*', text): await bot.sendMessage(msg['chat']['id'], '''<b>{} xingou e nao deixou baixo para {}, eu nao deixava e cagava o filho da puta na porrada so porque ele disse</b> <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True elif msg['text'].lower() == 'filho da puta' or msg['text'].lower() == 'pnc'and msg.get('reply_to_message'): print('Usuario {} solicitou filho da puta(rt)'.format(msg['from']['first_name'])) log = '\nUsuario {} solicitou filho da puta(rt) --> Grupo: {} --> Data/hora:{}'.format(msg['from']['first_name'],msg['chat']['title'],time.ctime()) arquivo = open('logs/grupos.txt','a') arquivo.write(log) arquivo.close() if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt' or msg['text'] == 'rtt': if not re.match('🔃 .* xingou a mãe do \n\n👤 .*', text): await bot.sendMessage(msg['chat']['id'], '''<b>{} xingou a mãe do {}, poxa o cara só falou</b> <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True
else: bot.answerCallbackQuery(query_id,"Você já votou nessa opção!") count_sim = count('sim',None, chat_id,message_id) count_nao = count('nao',None, chat_id,message_id) keybVoto = InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton(text='Sim' +' '+ str(count_sim), callback_data=timestamp+'|sim'), InlineKeyboardButton(text='Não' + ' ' + str(count_nao), callback_data=timestamp+'|nao'), ]]) ident_mensagem = (chat_id,message_id) if(refreshButton): bot.editMessageReplyMarkup(ident_mensagem, reply_markup=keybVoto) bot = amanobot.Bot(TOKEN) #healthcheck if len(sys.argv) > 1: if(sys.argv[1]) == 'Pergunta': for chat_id in getChats(): try: #print(chat_id[0]) bot.sendChatAction(chat_id[0],'typing') except: print(chat_id[0] + " indisponvel") pass else: EnviaPerguntas(chat_id[0]) print("Mensagem Enviada via Cron") elif (sys.argv[1]) == 'Resposta': for chat_id in getChats(): try:
async def misc(msg): if msg.get('text'): if msg['text'].startswith('/echo ') or msg['text'].startswith('!echo '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], reply_to_message_id=reply_id) return True elif msg['text'].startswith('/mark ') or msg['text'].startswith('!mark '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'markdownv2', reply_to_message_id=reply_id) return True elif msg['text'] == '/admins' or msg['text'] == '!admins': if msg['chat']['type'] == 'private': await bot.sendMessage(msg['chat']['id'], 'Este comando só funciona em grupos ¯\\_(ツ)_/¯') else: adms = await bot.getChatAdministrators(msg['chat']['id']) names = 'Admins:\n\n' for num, user in enumerate(adms): names += '{} - <a href="tg://user?id={}">{}</a>\n'.format(num + 1, user['user']['id'], html.escape(user['user']['first_name'])) await bot.sendMessage(msg['chat']['id'], names, 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/token ') or msg['text'].startswith('!token '): text = msg['text'][7:] try: bot_token = amanobot.Bot(text).getMe() bot_name = bot_token['first_name'] bot_user = bot_token['username'] bot_id = bot_token['id'] await bot.sendMessage(msg['chat']['id'], f'''Informações do bot: Nome: {bot_name} Username: @{bot_user} ID: {bot_id}''', reply_to_message_id=msg['message_id']) except TelegramError: await bot.sendMessage(msg['chat']['id'], 'Token inválido.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/bug') or msg['text'].startswith('!bug'): text = msg['text'][5:] if text == '' or text == bot_username: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/bug <descrição do bug>` - _Reporta erro/bug para minha equipe_ obs.: Mal uso há possibilidade de ID\_ban''', 'markdown', reply_to_message_id=msg['message_id']) else: await bot.sendMessage(logs, f"""<a href="tg://user?id={msg['from']['id']}">{msg['from'][ 'first_name']}</a> reportou um bug: ID: <code>{msg['from']['id']}</code> Mensagem: {text}""", 'HTML') await bot.sendMessage(msg['chat']['id'], 'O bug foi reportado com sucesso para a minha equipe!', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/dogbin') or msg['text'].startswith('!dogbin'): text = msg['text'][8:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/dogbin <texto>` - _envia um texto para o del.dog._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_dogbin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/aman') or msg['text'].startswith('!aman'): text = msg['text'][5:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/aman <texto>` - _envia um texto para o amano-bin.ml._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_amano(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/hastebin') or msg['text'].startswith('!hastebin'): text = msg['text'][9:] or msg.get('reply_to_message', {}).get('text') if not text: await bot.sendMessage(msg['chat']['id'], '''*Uso:* `/hastebin <texto>` - _envia um texto para o hastebin._''', 'markdown', reply_to_message_id=msg['message_id']) else: link = await send_to_hastebin(text) await bot.sendMessage(msg['chat']['id'], link, disable_web_page_preview=True, reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/html ') or msg['text'].startswith('!html '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None await bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'html', reply_to_message_id=reply_id) return True elif msg['text'] == '/kickme' or msg['text'] == '!kickme': try: await bot.unbanChatMember(msg['chat']['id'], msg['from']['id']) except TelegramError: await bot.sendMessage(msg['chat']['id'], 'Nao deu pra te remover, você deve ser um admin ou eu nao sou admin.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/request ') or msg['text'].startswith('!request '): if re.match(r'^(https?)://', msg['text'][9:]): text = msg['text'][9:] else: text = 'http://' + msg['text'][9:] try: async with aiohttp.ClientSession() as session: r = await session.get(text) except Exception as e: return await bot.sendMessage(msg['chat']['id'], str(e), reply_to_message_id=msg['message_id']) headers = '<b>Status-Code:</b> <code>{}</code>\n'.format(str(r.status)) headers += '\n'.join('<b>{}:</b> <code>{}</code>'.format(x, html.escape(r.headers[x])) for x in r.headers) rtext = await r.text() if len(rtext) > 3000: content = await r.read() res = await send_to_dogbin(content) else: res = '<code>' + html.escape(rtext) + '</code>' await bot.sendMessage(msg['chat']['id'], '<b>Headers:</b>\n{}\n\n<b>Conteúdo:</b>\n{}'.format(headers, res), 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'] == '/suco': if msg['from']['id'] in sudoers: is_sudo = '✅' else: is_sudo = '❌' await bot.sendMessage(msg['chat']['id'], is_sudo + '🍹', reply_to_message_id=msg['message_id']) return True elif msg['text'].lower() == 'rt' and msg.get('reply_to_message'): if msg['reply_to_message'].get('text'): text = msg['reply_to_message']['text'] elif msg['reply_to_message'].get('caption'): text = msg['reply_to_message']['caption'] else: text = None if text: if text.lower() != 'rt': if not re.match('🔃 .* retweetou:\n\n👤 .*', text): await bot.sendMessage(msg['chat']['id'], '''🔃 <b>{}</b> retweetou: 👤 <b>{}</b>: <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], text), parse_mode='HTML', reply_to_message_id=msg['message_id']) return True
import amanobot bot = amanobot.Bot('879319138:AAF5zcKPsfglFmIbSOZ48fK6X4f5GpHAap4')
from var import BOT_NAME from private import prod_token chat_backend = get_chatbot() def main_loop(msg): content_type, chat_type, chat_id = amanobot.glance(msg) if content_type == "text": msg_text = msg["text"].lower() check = True # In a group always respond when mentioned # or respond 10% of the time if chat_type == "group" and not random.random() < 0.05: check = BOT_NAME in msg_text if check: msg_text = msg_text.replace(BOT_NAME, "").strip() resp = chat_backend.get_response(msg_text) resp = str(resp) bot.sendMessage(chat_id, resp) bot = amanobot.Bot(prod_token) MessageLoop(bot, main_loop).run_as_thread() while True: time.sleep(10)
# biblioteca import datetime import amanobot import time import threading import aiml import numexpr import wolframalpha # parametros import config import credencial # iniciarlizar instancia bot bot = amanobot.Bot(config.TOKEN) bot.deleteWebhook() k = aiml.Kernel() k.learn('../aiml/*.aiml') # credenciais de acesso ao bot e a pesquisa whitelist = credencial.TURMADM wolclient = wolframalpha.Client(config.WOLFA) # retorna qual idioma esta sendo usada def get_user_lang(language_code): if language_code.startswith('pt'): return 'Portuguese' elif language_code.startswith('en'): return 'English'
def diversos(msg): if msg.get('text'): if msg['text'].startswith('/echo ') or msg['text'].startswith( '!echo '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None bot.sendMessage(msg['chat']['id'], msg['text'][6:], reply_to_message_id=reply_id) return True elif msg['text'].startswith('/mark ') or msg['text'].startswith( '!mark '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'markdown', reply_to_message_id=reply_id) return True elif msg['text'] == '/admins' or msg['text'] == '!admins': adms = bot.getChatAdministrators(msg['chat']['id']) names = 'Admins:\n\n' for num, user in enumerate(adms): names += '{} - <a href="tg://user?id={}">{}</a>\n'.format( num + 1, user['user']['id'], html.escape(user['user']['first_name'])) bot.sendMessage(msg['chat']['id'], names, 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/token ') or msg['text'].startswith( '!token '): text = msg['text'][7:] try: bot_token = amanobot.Bot(text).getMe() bot_name = bot_token['first_name'] bot_user = bot_token['username'] bot_id = bot_token['id'] bot.sendMessage(msg['chat']['id'], '''Informações do bot: Nome: {} Username: @{} ID: {}'''.format(bot_name, bot_user, bot_id), reply_to_message_id=msg['message_id']) except TelegramError: bot.sendMessage(msg['chat']['id'], 'Token inválido.', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/bug') or msg['text'].startswith('!bug'): text = msg['text'][5:] if text == '' or text == bot_username: bot.sendMessage( msg['chat']['id'], '''*Uso:* `/bug <descrição do bug>` - _Reporta erro/bug para minha equipe_ obs.: Mal uso há possibilidade de ID\_ban''', 'markdown', reply_to_message_id=msg['message_id']) else: bot.sendMessage( logs, ''' <a href="tg://user?id={}">{}</a> reportou um bug ID: <code>{}</code> Mensagem: {}'''.format(msg['from']['id'], msg['from']['first_name'], msg['from']['id'], text), 'HTML') bot.sendMessage( msg['chat']['id'], 'O bug foi reportado com sucesso para a minha equipe!', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/html ') or msg['text'].startswith( '!html '): if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None bot.sendMessage(msg['chat']['id'], msg['text'][6:], 'html', reply_to_message_id=reply_id) return True elif msg['text'].startswith('/text ') or msg['text'].startswith( '!text '): string = '' text = msg['text'][6:] if msg.get('reply_to_message'): reply_id = msg['reply_to_message']['message_id'] else: reply_id = None sent = bot.sendMessage(msg['chat']['id'], '<code>|</code>', 'html', reply_to_message_id=reply_id) for char in text: string = string + char bot.editMessageText((msg['chat']['id'], sent['message_id']), '<code>' + string + '</code>', 'html') bot.editMessageText((msg['chat']['id'], sent['message_id']), '<code>' + string + '|</code>', 'html') bot.editMessageText((msg['chat']['id'], sent['message_id']), '<code>' + msg['text'][6:] + '</code>', 'html') return True elif msg['text'].startswith('/request ') or msg['text'].startswith( '!request '): if re.match(r'^(https?:\/\/)', msg['text'][9:]): text = msg['text'][9:] else: text = 'http://' + msg['text'][9:] try: res = requests.get(text).text except Exception as e: return bot.sendMessage(msg['chat']['id'], str(e), reply_to_message_id=msg['message_id']) if len(res) > 4000: res = send_to_dogbin(res) else: res = '<pre>' + html.escape(res) + '</pre>' bot.sendMessage(msg['chat']['id'], '<b>Conteúdo:</b>\n{}'.format(res), 'html', reply_to_message_id=msg['message_id']) return True elif msg['text'].startswith('/suco'): if msg['from']['id'] in sudos: l = '✅' else: l = '❌' bot.sendMessage(msg['chat']['id'], l + '🍹', reply_to_message_id=msg['message_id']) elif msg['text'].lower() == 'rt' and msg.get('reply_to_message'): if msg['reply_to_message'].get('text'): if msg['reply_to_message']['text'].lower() != 'rt': if not re.match('🔃 .* retweetou:\n\n👤 .*', msg['reply_to_message']['text']): bot.sendMessage(msg['chat']['id'], '''🔃 <b>{}</b> retweetou: 👤 <b>{}</b>: <i>{}</i>'''.format(msg['from']['first_name'], msg['reply_to_message']['from']['first_name'], msg['reply_to_message']['text']), 'HTML', reply_to_message_id=msg['message_id']) return True