Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import os
- import telebot
- from ybot import YBot
- import dbmod # Module database
- import sshmod # Module ssh
- ywbot = YBot() # Instance classe
- bot = ywbot.handler() # Instance telebot
- commands = bot.message_handler
- errors = {'notusername': 'Tente /cadastrar nomeusuario (sem espaços)',
- 'limitexceeded':'O limite de 250 pessoas cadastradas foi excedido!',
- 'notgroup': 'Desculpe mas eu não funciono nesse chat.',
- 'registered': 'Parece que você já está cadastrado.',
- 'notprivate': 'Só posso enviar sua senha em privado.',
- 'notregistered': 'Parece que você não está cadastrado.',
- 'notadmin': 'Você não é um administrador',
- 'delnoneusername': 'Você precisa enviar o username',
- 'notfounduser': 'Usuário não existe.',
- 'notehi': 'Arquivos ehi não cadastrados',
- 'notmasteradmin': 'Você não é um master admin.',
- 'notidadmin': 'Você precisa enviar o id do admin, sem espaços. Ex: 12345678',
- 'notisdigit': 'Você precisa enviar somente números sem espaços.'}
- sucess = {'registerok': '*Cadastro concluido! Fale comigo no privado para receber sua senha.(/senha)*',
- 'password': 'Sua senha é {}',
- 'deleteok': 'Usuário apagado!',
- 'savedfile': 'Arquivos cadastrados!',
- 'delfiles': 'Arquivos apagados!'}
- @commands('/helpsv2')
- def helper(msg):
- admins = ywbot.getAdmins()
- adminsUserName = ''
- for admin in admins:
- if ywbot.getInfoUser(admin):
- adminsUserName += '@'+ywbot.getInfoUser(admin).username+'\n'
- text = """
- \n*Minhas funcionalidades são:*\
- \n*# Para usuário*\
- ```
- \n/cadastrar nome\
- \n/helpsv2\
- \n/senha\
- \n/ehi\
- ```
- \n*# Para admin*\
- ```
- \n/listar_usuarios(OFF)\
- \n/apagar_usuario nome\
- \n/limpar_expirados(OFF)\
- \n/apagar_arquivos\
- \n/addfile\
- \n/cadastrar_admin\
- \n/apagar_admin nome\
- ```
- \n*Administradores*\
- \n{}\
- \n_Desenvolvido por:_ @ftimoteo\
- \n_Versão 2.1_""".format(adminsUserName)
- bot.send_message(msg.chat.id, text, parse_mode='Markdown')
- @commands('cadastrar')
- def register_user(msg):
- userid = msg.from_user.id
- text = msg.text.split(maxsplit=1)
- if len(text) <= 1:
- bot.reply_to(msg, errors['notusername'])
- elif dbmod.count_logins() >= 250:
- bot.reply_to(msg, errors['limitexceeded'])
- elif msg.chat.id not in ywbot.getGroups():
- bot.reply_to(msg, errors['notgroup'])
- elif sshmod.user_exists(text[1]) or dbmod.registred_user(userid):
- bot.reply_to(msg, errors['registered'])
- else:
- sshmod.register_user(text[1], msg)
- ywbot.save_log('[+] User {} registred.'.format(text[1]))
- bot.reply_to(msg, sucess['registerok'], parse_mode='Markdown')
- @commands('senha')
- def my_password(msg):
- if msg.chat.type != 'private':
- return bot.send_message(msg.chat.id, errors['notprivate'])
- password = dbmod.search_password(msg.from_user.id)
- if password:
- bot.send_message(msg.chat.id, sucess['password'].format(password))
- else:
- bot.send_message(msg.chat.id, errors['notregistered'])
- @commands('apagar_usuario')
- def delete_user(msg):
- username = (msg.text).split(maxsplit=1)
- if msg.from_user.id not in ywbot.getAdmins():
- bot.send_message(msg.chat.id, errors['notadmin'])
- elif len(username) <= 1:
- bot.send_message(msg.chat.id, errors['delnoneusername'])
- else:
- if sshmod.user_exists(username[1]):
- sshmod.delete_user(username[1])
- dbmod.delete_user(username[1])
- ywbot.save_log('[-] User {} deleted from admin {}'.format(username[1],
- msg.from_user.username))
- bot.send_message(msg.chat.id, sucess['deleteok'])
- @commands('addfile')
- def add_files(msg):
- if msg.from_user.id not in ywbot.getAdmins():
- bot.send_message(msg.chat.id, errors['notadmin'])
- else:
- ywbot.setFiles(msg.chat.id, msg.reply_to_message.message_id)
- ywbot.save_log('[+] News files saved')
- bot.send_message(msg.chat.id, sucess['savedfile'])
- @commands('ehi')
- def ehi(msg):
- if not ywbot.getFiles():
- bot.send_message(msg.chat.id, errors['notehi'])
- else:
- for from_chat_id, message_id in ywbot.getFiles():
- bot.forward_message(msg.chat.id, from_chat_id, message_id)
- @commands('apagar_arquivos')
- def delete_files(msg):
- if msg.from_user.id not in ywbot.getAdmins():
- bot.send_message(msg.chat.id, errors['notadmin'])
- else:
- ywbot.delFiles()
- ywbot.save_log('[-] Files deleted from admin {}'.format(msg.from_user.id))
- bot.send_message(msg.chat.id, sucess['delfiles'])
- @commands('cadastrar_admin')
- def register_admin(msg):
- text = msg.text.split(maxsplit=1)
- if msg.from_user.id not in ywbot.getMasterAdmin():
- bot.send_message(msg.chat.id, errors['notmasteradmin'])
- elif len(text) <= 1:
- bot.send_message(msg.chat.id, errors['notidadmin'])
- elif not text[1].isdigit():
- bot.send_message(msg.chat.id, errors['notisdigit'])
- else:
- adminid = int(text[1])
- ywbot.save_config(adminid)
- ywbot.load_config()
- ywbot.save_log('[+] Admin ID {} added from Master admin: {}'.format(adminid, msg.from_user.id))
- @commands('apagar_admin')
- def delete_admin(msg):
- text = msg.text.split(maxsplit=1)
- if msg.from_user.id not in ywbot.getMasterAdmin():
- bot.send_message(msg.chat.id, errors['notmasteradmin'])
- elif len(text) <= 1:
- bot.send_message(msg.chat.id, errors['notidadmin'])
- elif not text[1].isdigit():
- bot.send_message(msg.chat.id, errors['notisdigit'])
- else:
- adminid = int(text[1])
- ywbot.del_config(adminid)
- ywbot.load_config()
- ywbot.save_log('[-] Admin ID {} deleted from Master admin {}'.format(adminid, msg.from_user.id))
- def search_expired_users():
- "Search expired users and delete"
- pass
- if __name__ == '__main__':
- if 'TOKEN_BOT' not in os.environ:
- print('Please declare a global variable named TOKEN_BOT on system')
- exit()
- ywbot.load_config()
- bot.skip_pending = True
- print('Working...')
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement