def get_about(bot, update, args): rez = "" if len(args): if args[0] == "stat" and update.message.from_user.name == admin_pwd: if len(args) > 1: limit = args[1] else: limit = 10 rez = "Last {} request:\n```\n".format(limit) + get_stat(limit).get_string() + "\n```" elif args[0] == "top" and update.message.from_user.name == admin_pwd: if len(args) > 1: field = args[1] limit = 10 if len(args) > 2: limit = args[2] else: field = 'user_name' limit = 10 rez = "TOP {}s:\n```\n".format(field) + get_top(field, limit).get_string() + "\n```" elif args[0] == "get-vars" and update.message.from_user.name == admin_pwd: vars = get_vars() rez = "AES KEY: {}\n" \ "token: {}\n" \ "DeviceID: {}\n" \ "PRIVATE\_KEY: {}".format(vars[0], vars[1], vars[2], vars[3]) elif args[0] == "set-vars" and update.message.from_user.name == admin_pwd: if '-t' in args: set_new_token(args[args.index('-t')+1]) if '-k' in args: set_new_aes_key(args[args.index('-k')+1]) if '-d' in args: set_new_device_id(args[args.index('-d')+1]) if '-e' in args: set_new_exp(args[args.index('-e')+1]) if '-r' in args: log_reamins(args[args.index('-r')+1]) rez = 'New vars have been setup' else: if update.message.from_user.name == admin_pwd: rez = "Hello my master!\nYou can use commands:\n" \ "/batya stat 15 - Last 15 request (default 10)\n" \ "/batya top user\_name 15 - Top 15 users who asked bot (default: user-name)\n" \ "/batya top requested\_phone 15 - Top 15 requested-phone (default: user-name)\n" \ "/batya get-vars - Get vars values\n" \ "/batya set-vars -t token -k key -d DeviceID -e PRIVATE-KEY -r REMAIN" else: rez = "Hi {}.\n@Chpkk moy batya!".format(update.message.from_user.username) bot.send_message(chat_id=update.message.chat_id, text=rez, parse_mode="Markdown")
def get_about(bot, update, args): rez = "" global whitelist_status global getcontact_status global numbuster_status global tg_status if len(args): if args[0] == "stat" and update.message.from_user.id == admin_id: if len(args) > 1: limit = args[1] else: limit = 10 rez = "Last {} request:\n```\n".format(limit) + get_stat( limit).get_string() + "\n```" elif args[0] == "top" and update.message.from_user.id == admin_id: if len(args) > 1: field = args[1] limit = 10 if len(args) > 2: limit = args[2] else: field = 'user_name' limit = 10 rez = "TOP {}s:\n```\n".format(field).replace('_', '-') + get_top( field, limit).get_string().replace('_', '-') + "\n```" elif args[0] == "get-vars" and update.message.from_user.id == admin_id: vars = get_vars() rez = "AES KEY: {}\n" \ "token: {}\n" \ "DeviceID: {}\n" \ "PRIVATE\_KEY: {}".format(vars[0], vars[1], vars[2], vars[3]) elif args[0] == "set-vars" and update.message.from_user.id == admin_id: if '-t' in args: set_new_token(args[args.index('-t') + 1]) if '-k' in args: set_new_aes_key(args[args.index('-k') + 1]) if '-d' in args: set_new_device_id(args[args.index('-d') + 1]) if '-e' in args: set_new_exp(args[args.index('-e') + 1]) if '-r' in args: remain = { "name": get_env_data()[0]['name'], "remain": args[args.index('-r') + 1] } log_reamins(remain) rez = 'New vars have been setup' elif args[0] == "ban" and update.message.from_user.id == admin_id: if len(args) <= 1: rez = 'Banned users:\n{}'.format(get_banlist(15)) else: ban_user(args[1].split(":")[0], args[1].split(":")[1]) rez = 'User {} was banned'.format(args[1]) elif args[0] == "add" and update.message.from_user.id == admin_id: if len(args) <= 1: rez = "Add username that will be added to the whitelist" else: whitelist_user(args[1].split(":")[0], args[1].split(":")[1]) rez = 'User {} was whitelisted'.format(args[1]) bot.send_message( chat_id=int(args[1].split(":")[1]), text= 'Hey! Your invite was approved. Now you can use bot without any restrictions.' ) elif args[0] == "rem" and update.message.from_user.id == admin_id: if len(args) <= 1: rez = "Add user_id that will be removed from the whitelist" else: whitelist_rem_user(args[1]) rez = 'User {} was removed from the whitelist'.format(args[1]) bot.send_message(chat_id=int(args[1]), text='Hey! You was banned. Sorry for that :)') elif args[0] == "remban" and update.message.from_user.id == admin_id: if len(args) <= 1: rez = "Add user_id that will be removed from the banlist" else: banlist_rem_user(args[1]) rez = 'User {} was removed from the banlist'.format(args[1]) elif args[0] == "wlist" and update.message.from_user.id == admin_id: if len(args) <= 1: whitelist_status = 1 rez = "Whitelist was enabled" else: whitelist_status = int(args[1]) rez = 'Whitelist status set to {}'.format(args[1]) elif args[0] == "getc" and update.message.from_user.id == admin_id: if len(args) <= 1: getcontact_status = 1 rez = "GetContact was enabled" else: getcontact_status = int(args[1]) rez = 'GetContact status set to {}'.format(args[1]) elif args[0] == "numb" and update.message.from_user.id == admin_id: if len(args) <= 1: numbuster_status = 1 rez = "NumBuster was enabled" else: numbuster_status = int(args[1]) rez = 'NumBuster status set to {}'.format(args[1]) elif args[0] == "status" and update.message.from_user.id == admin_id: rez = "Reamain:\n {}\n" \ "Whitelist status: {}\n" \ "GetContact status: {}\n"\ "NumBuster status: {}\n" \ "Demorequests: {}\n" \ "Banned:\n{}\n" \ "Whitelisted:\n{}\n" \ "Invite req:\n".format(get_admin_reamins(),whitelist_status,getcontact_status,numbuster_status,demoreqests_nbr,get_banlist(15),get_whitelist(15)) rez = rez + get_invitelist(15) bot.send_message(chat_id=update.message.chat_id, text=rez) return elif args[0] == "inv" and update.message.from_user.id == admin_id: rez = 'Invite requests:\n' + get_invitelist(20) bot.send_message(chat_id=update.message.chat_id, text=rez) return elif args[0] == "say" and update.message.from_user.id == admin_id: if args[1]: say_to_user(bot, [args[1]], ' '.join(args[2:])) return elif args[0] == "sayall" and update.message.from_user.id == admin_id: if args[1]: say_to_all_users(bot, ' '.join(args[2:])) return else: if update.message.from_user.id == admin_id: rez = "Hello my master!\nYou can use commands:\n" \ "/batya stat 15 - Last 15 request (default 10)\n" \ "/batya top user\_name 15 - Top 15 users who asked bot (default: user-name)\n" \ "/batya top requested\_phone 15 - Top 15 requested-phone (default: user-name)\n" \ "/batya get-vars - Get vars values\n" \ "/batya set-vars -t token -k key -d DeviceID -e PRIVATE-KEY -r REMAIN\n" \ "/batya ban USERNAME:id - Ban user\n" \ "/batya remban id - Unban user\n" \ "/batya add USERNAME:id - Add user to whitelist\n" \ "/batya rem id - Remove user from whitelist\n" \ "/batya wlist 1/0 - Enamble/disable whitelist\n" \ "/batya inv - print invite request\n" \ "/batya getc 1/0 - Enable/disable GetContact\n" \ "/batya numb 1/0 - Enable/disable Numbuster\n" \ "/batya status - Print lists (white/black), remains, etc\n" \ "/batya say ids text\n" \ "/batya sayall text" else: rez = "Hi {}.\nFeel free to write me a message via /say command".format( update.message.from_user.username) bot.send_message(chat_id=update.message.chat_id, text=rez, parse_mode="Markdown")