def sudopromote(bot: Bot, update: Update, args: List[str]): message = update.effective_message banner = update.effective_user user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return "" if int(user_id) == OWNER_ID: message.reply_text( "The specified user is my owner! No need add him to SUDO_USERS list!" ) return "" if int(user_id) in SUDO_USERS: message.reply_text("The user is already a sudo user.") return "" with open("sudo_users.txt", "a") as file: file.write(str(user_id) + "\n") SUDO_USERS.append(user_id) message.reply_text("Succefully added to SUDO user list!") return ""
def get_id(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat msg = update.effective_message user_id = extract_user(msg, args) if user_id: if msg.reply_to_message and msg.reply_to_message.forward_from: user1 = message.reply_to_message.from_user user2 = message.reply_to_message.forward_from msg.reply_text(f"The original sender, {html.escape(user2.first_name)}," f" has an ID of <code>{user2.id}</code>.\n" f"The forwarder, {html.escape(user1.first_name)}," f" has an ID of <code>{user1.id}</code>.", parse_mode=ParseMode.HTML) else: user = bot.get_chat(user_id) msg.reply_text(f"{html.escape(user.first_name)}'s id is <code>{user.id}</code>.", parse_mode=ParseMode.HTML) else: if chat.type == "private": msg.reply_text(f"Your id is <code>{chat.id}</code>.", parse_mode=ParseMode.HTML) else: msg.reply_text(f"This group's id is <code>{chat.id}</code>.", parse_mode=ParseMode.HTML)
def demote(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat message = update.effective_message user = update.effective_user log_message = "" user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return log_message try: user_member = chat.get_member(user_id) except: return log_message if user_member.status == 'creator': message.reply_text( "This person CREATED the chat, how would I demote them?") return log_message if not user_member.status == 'administrator': message.reply_text("Can't demote what wasn't promoted!") return log_message if user_id == bot.id: message.reply_text( "I can't demote myself! Get an admin to do it for me.") return log_message try: bot.promoteChatMember(chat.id, user_id, can_change_info=False, can_post_messages=False, can_edit_messages=False, can_delete_messages=False, can_invite_users=False, can_restrict_members=False, can_pin_messages=False, can_promote_members=False) bot.sendMessage(chat.id, "Sucessfully demoted <b>{}</b>!".format( user_member.user.first_name or user_id), parse_mode=ParseMode.HTML) log_message += "<b>{}:</b>" \ "\n#DEMOTED" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name)) return log_message except BadRequest: message.reply_text("Could not demote. I might not be admin, or the admin status was appointed by another" \ "user, so I can't act upon them!") return log_message
def warns(bot: Bot, update: Update, args: List[str]): message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = f"This user has {num_warns}/{limit} warnings, for the following reasons:" for reason in reasons: text += f"\n - {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"User has {num_warns}/{limit} warnings, but no reasons for any of them." ) else: update.effective_message.reply_text( "This user hasn't got any warnings!")
def sudodemote(bot: Bot, update: Update, args: List[str]): message = update.effective_message user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return "" if int(user_id) == OWNER_ID: message.reply_text( "The specified user is my owner! I won't remove him from SUDO_USERS list!" ) return "" if user_id not in SUDO_USERS: message.reply_text("{} is not a sudo user".format(user_id)) return "" users = [line.rstrip('\n') for line in open("sudo_users.txt")] with open("sudo_users.txt", "w") as file: for user in users: if not int(user) == user_id: file.write(str(user) + "\n") SUDO_USERS.remove(user_id) message.reply_text("Succefully removed from SUDO user list!") return ""
def removewhitelist(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat user_id = extract_user(message, args) user_member = bot.getChat(user_id) reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ALLUKA_FAMILY_LIST, 'r') as infile: data = json.load(infile) if user_id in WHITELIST_USERS: message.reply_text("Demoting to normal user") WHITELIST_USERS.remove(user_id) data['whitelists'].remove(user_id) with open(ALLUKA_FAMILY_LIST, 'w') as outfile: json.dump(data, outfile, indent=4) log_message = (f"#UNWHITELIST\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}") if chat.type != 'private': log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message else: message.reply_text("This user is not a whitelist!") return ""
def gkick(bot: Bot, update: Update, args: List[str]): message = update.effective_message user_id = extract_user(message, args) try: user_chat = bot.get_chat(user_id) except BadRequest as excp: if excp.message in GKICK_ERRORS: pass else: message.reply_text("User cannot be Globally kicked because: {}".format(excp.message)) return except TelegramError: pass if not user_id or int(user_id)==777000: message.reply_text("You don't seem to be referring to a user.") return if int(user_id) in SUDO_USERS or int(user_id) in SUPPORT_USERS: message.reply_text("OHHH! Someone's trying to gkick a sudo/support user! *Grabs popcorn*") return if int(user_id) == OWNER_ID: message.reply_text("Wow! Someone's so noob that he want to gkick my owner! *Grabs Potato Chips*") return if user_id == bot.id: message.reply_text("Welp, I'm not gonna to gkick myself!") return chats = get_all_chats() banner = update.effective_user # type: Optional[User] send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "<b>Global Kick</b>" \ "\n#GKICK" \ "\n<b>Status:</b> <code>Enforcing</code>" \ "\n<b>Sudo Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>ID:</b> <code>{}</code>".format(mention_html(banner.id, banner.first_name), mention_html(user_chat.id, user_chat.first_name), user_chat.id), html=True) message.reply_text("Globally kicking user @{}".format(user_chat.username)) sql.gkick_user(user_id, user_chat.username, 1) for chat in chats: try: member = bot.get_chat_member(chat.chat_id, user_id) if member.can_send_messages is False: bot.unban_chat_member(chat.chat_id, user_id) # Unban_member = kick (and not ban) bot.restrict_chat_member(chat.chat_id, user_id, can_send_messages = False) else: bot.unban_chat_member(chat.chat_id, user_id) except BadRequest as excp: if excp.message in GKICK_ERRORS: pass else: message.reply_text("User cannot be Globally kicked because: {}".format(excp.message)) return except TelegramError: pass
def promote(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message chat = update.effective_chat user = update.effective_user log_message = "" user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return log_message try: user_member = chat.get_member(user_id) except: return log_message if user_member.status == 'administrator' or user_member.status == 'creator': message.reply_text("How am I meant to promote someone that's already an admin?") return log_message if user_id == bot.id: message.reply_text("I can't promote myself! Get an admin to do it for me.") return log_message # set same perms as bot - bot can't assign higher perms than itself! bot_member = chat.get_member(bot.id) try: bot.promoteChatMember(chat.id, user_id, can_change_info=bot_member.can_change_info, can_post_messages=bot_member.can_post_messages, can_edit_messages=bot_member.can_edit_messages, can_delete_messages=bot_member.can_delete_messages, can_invite_users=bot_member.can_invite_users, # can_promote_members=bot_member.can_promote_members, can_restrict_members=bot_member.can_restrict_members, can_pin_messages=bot_member.can_pin_messages) except BadRequest as err: if err.message == "User_not_mutual_contact": message.reply_text("I can't promote someone who isn't in the group.") return log_message else: message.reply_text("An error occured while promoting.") return log_message bot.sendMessage(chat.id, "Sucessfully promoted <b>{}</b>!".format(user_member.user.first_name or user_id), parse_mode=ParseMode.HTML) log_message += "<b>{}:</b>" \ "\n#PROMOTED" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name)) return log_message
def ungban(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return user_chat = bot.get_chat(user_id) if user_chat.type != 'private': message.reply_text("That's not a user!") return if not sql.is_user_gbanned(user_id): message.reply_text("This user is not gbanned!") return banner = update.effective_user # type: Optional[User] message.reply_text("I'll give {} a second chance, globally.".format(mention_html(user_chat.id, user_chat.first_name)), parse_mode=ParseMode.HTML) send_to_list(bot, SUDO_USERS, "{} has ungbanned user {}".format(mention_html(banner.id, banner.first_name), mention_html(user_chat.id, user_chat.first_name)), html=True) chats = get_all_chats() for chat in chats: chat_id = chat.chat_id # Check if this group has disabled gbans if not sql.does_chat_gban(chat_id): continue try: member = bot.get_chat_member(chat_id, user_id) if member.status == 'kicked': bot.unban_chat_member(chat_id, user_id) except BadRequest as excp: if excp.message in UNGBAN_ERRORS: pass else: message.reply_text("Could not un-gban due to: {}".format(excp.message)) bot.send_message(OWNER_ID, "Could not un-gban due to: {}".format(excp.message)) return except TelegramError: pass sql.ungban_user(user_id) send_to_list(bot, SUDO_USERS, "Un-gban complete!") message.reply_text("{} has been un-gbanned.".format(mention_html(user_chat.id, user_chat.first_name)), parse_mode=ParseMode.HTML)
def slap(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat reply_text = message.reply_to_message.reply_text if message.reply_to_message else message.reply_text curr_user = html.escape(message.from_user.first_name) user_id = extract_user(message, args) if user_id == bot.id: temp = random.choice(fun_strings.SLAP_alluka_TEMPLATES) if type(temp) == list: if temp[2] == "tmute": if is_user_admin(chat, message.from_user.id): reply_text(temp[1]) return mutetime = int(time.time() + 60) bot.restrict_chat_member(chat.id, message.from_user.id, until_date=mutetime, can_send_messages=False) reply_text(temp[0]) else: reply_text(temp) return if user_id: slapped_user = bot.get_chat(user_id) user1 = curr_user user2 = html.escape(slapped_user.first_name) else: user1 = bot.first_name user2 = curr_user temp = random.choice(fun_strings.SLAP_TEMPLATES) item = random.choice(fun_strings.ITEMS) hit = random.choice(fun_strings.HIT) throw = random.choice(fun_strings.THROW) reply = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw) reply_text(reply, parse_mode=ParseMode.HTML)
def addwhitelist(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat user_id = extract_user(message, args) user_member = bot.getChat(user_id) rt = "" reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ELEVATED_USERS_FILE, 'r') as infile: data = json.load(infile) if user_id in SUDO_USERS: rt += "This member is a SUDO, Demoting to SUDO." data['sudos'].remove(user_id) SUDO_USERS.remove(user_id) if user_id in SUPPORT_USERS: rt += "This user is already a SUPPORT, Demoting to SUPPORT" data['supports'].remove(user_id) SUPPORT_USERS.remove(user_id) if user_id in WHITELIST_USERS: message.reply_text("This user is already a WHITELIST USER.") return "" data['whitelists'].append(user_id) WHITELIST_USERS.append(user_id) with open(ELEVATED_USERS_FILE, 'w') as outfile: json.dump(data, outfile, indent=4) update.effective_message.reply_text( rt + f"\nSuccessfully promoted {user_member.first_name} to a Whitelist User!" ) log_message = ( f"#WHITELIST\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)} \n" f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}") if chat.type != 'private': log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message
def addsudo(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat user_id = extract_user(message, args) user_member = bot.getChat(user_id) rt = "" reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ALLUKA_FAMILY_LIST, 'r') as infile: data = json.load(infile) if user_id in SUDO_USERS: message.reply_text("This member is already my SUDO.") return "" if user_id in SUPPORT_USERS: rt += "This user is already a SUPPORT USER." data['supports'].remove(user_id) SUPPORT_USERS.remove(user_id) if user_id in WHITELIST_USERS: rt += "This user is already a WHITELIST USER." data['whitelists'].remove(user_id) WHITELIST_USERS.remove(user_id) data['sudos'].append(user_id) SUDO_USERS.append(user_id) with open(ALLUKA_FAMILY_LIST, 'w') as outfile: json.dump(data, outfile, indent=4) update.effective_message.reply_text( rt + "\nSuccessfully added this user {} to sudo!".format(user_member.first_name)) log_message = (f"#SUDO\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}") if chat.type != 'private': log_message = f"<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message
def caschecker(bot: Bot, update: Update, args: List[str]): #/info logic msg = update.effective_message # type: Optional[Message] user_id = extract_user(update.effective_message, args) if user_id and int(user_id) != 777000: user = bot.get_chat(user_id) elif user_id and int(user_id) == 777000: msg.reply_text( "This is Telegram. Unless you manually entered this reserved account's ID, it is likely a broadcast from a linked channel." ) return elif not msg.reply_to_message and not args: user = msg.from_user elif not msg.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities([MessageEntity.TEXT_MENTION]))): msg.reply_text("I can't extract a user from this.") return else: return text = "<b>CAS Check</b>:" \ "\nID: <code>{}</code>" \ "\nFirst Name: {}".format(user.id, html.escape(user.first_name)) if user.last_name: text += "\nLast Name: {}".format(html.escape(user.last_name)) if user.username: text += "\nUsername: @{}".format(html.escape(user.username)) text += "\n\nCAS Banned: " result = cas.banchecker(user.id) text += str(result) if result: parsing = cas.offenses(user.id) if parsing: text += "\nTotal of Offenses: " text += str(parsing) parsing = cas.timeadded(user.id) if parsing: parseArray = str(parsing).split(", ") text += "\nDay added: " text += str(parseArray[1]) text += "\nTime added: " text += str(parseArray[0]) text += "\n\nAll times are in UTC" update.effective_message.reply_text(text, parse_mode=ParseMode.HTML)
def addsupport(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat user_id = extract_user(message, args) user_member = bot.getChat(user_id) rt = "" reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ALLUKA_FAMILY_LIST, 'r') as infile: data = json.load(infile) if user_id in SUDO_USERS: rt += "Demoting status of this SUDO to SUPPORT" data['sudos'].remove(user_id) SUDO_USERS.remove(user_id) if user_id in SUPPORT_USERS: message.reply_text("This user is already a SUDO.") return "" if user_id in WHITELIST_USERS: rt += "Promoting Disaster level from WHITELIST USER to SUPPORT USER" data['whitelists'].remove(user_id) WHITELIST_USERS.remove(user_id) data['supports'].append(user_id) SUPPORT_USERS.append(user_id) with open(ALLUKA_FAMILY_LIST, 'w') as outfile: json.dump(data, outfile, indent=4) update.effective_message.reply_text(rt + f"\n{user_member.first_name} was added as a support user!") log_message = (f"#SUPPORT\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}") if chat.type != 'private': log_message = "<b>{html.escape(chat.title)}:</b>\n" + log_message return log_message
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return (f"<b>{html.escape(chat.title)}:</b>\n" f"#RESETWARNS\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(warned.id, warned.first_name)}") else: message.reply_text("No user has been designated!") return ""
def unmute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat chat_name = chat.title or chat.first or chat.username user = update.effective_user message = update.effective_message user_id = extract_user(message, args) if not user_id: message.reply_text( "You'll need to either give me a username to unmute, or reply to someone to be unmuted." ) return "" member = chat.get_member(int(user_id)) if member.status != 'kicked' and member.status != 'left': if (member.can_send_messages and member.can_send_media_messages and member.can_send_other_messages and member.can_add_web_page_previews): message.reply_text("This user already has the right to speak.") else: bot.restrict_chat_member(chat.id, int(user_id), can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage( chat.id, f"Yep, <b>{html.escape(member.user.first_name)}</b> can start talking again in " + f"{chat_name}", parse_mode=ParseMode.HTML) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#UNMUTE\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(member.user.id, member.user.first_name)}" ) else: message.reply_text( "This user isn't even in the chat, unmuting them won't make them talk more than they " "already do!") return ""
def about_bio(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if user_id: user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_bio(user.id) if info: update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = user.first_name update.effective_message.reply_text("{} No details about him have been added yet !".format(username)) else: update.effective_message.reply_text(" Your information about you has been added !")
def about_bio(bot: Bot, update: Update, args: List[str]): message = update.effective_message user_id = extract_user(message, args) if user_id: user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_bio(user.id) if info: update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = user.first_name update.effective_message.reply_text(f"{username} hasn't had a message set about themselves yet!") else: update.effective_message.reply_text("You haven't had a bio set about yourself yet!")
def about_me(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if user_id: user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_me_info(user.id) if info: update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = message.reply_to_message.from_user.first_name update.effective_message.reply_text(username + "Information about him is currently unavailable !") else: update.effective_message.reply_text("You have not added any information about yourself yet !")
def removesudo(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat user_id = extract_user(message, args) user_member = bot.getChat(user_id) reply = check_user_id(user_id, bot) if reply: message.reply_text(reply) return "" with open(ELEVATED_USERS_FILE, 'r') as infile: data = json.load(infile) if user_id in SUDO_USERS: message.reply_text("Demoting to normal user") SUDO_USERS.remove(user_id) data['sudos'].remove(user_id) with open(ELEVATED_USERS_FILE, 'w') as outfile: json.dump(data, outfile, indent=4) log_message = ( f"#UNSUDO\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(user_member.id, user_member.first_name)}" ) if chat.type != 'private': log_message = "<b>{}:</b>\n".format(html.escape( chat.title)) + log_message return log_message else: message.reply_text("This user is not a sudo!") return ""
def unbl_user(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user user_id = extract_user(message, args) if not user_id: message.reply_text("I doubt that's a user.") return "" if user_id == bot.id: message.reply_text("I always notice myself.") return "" try: target_user = bot.get_chat(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("I can't seem to find this user.") return "" else: raise if sql.is_user_blacklisted(user_id): sql.unblacklist_user(user_id) message.reply_text("*notices user*") log_message = "#UNBLACKLIST" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(mention_html(user.id, user.first_name), mention_html(target_user.id, target_user.first_name)) return log_message else: message.reply_text("I am not ignoring them at all though!") return ""
def info(bot: Bot, update: Update, args: List[str]): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user_id = extract_user(update.effective_message, args) if user_id: user = bot.get_chat(user_id) elif not msg.reply_to_message and not args: user = msg.from_user elif not msg.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities([MessageEntity.TEXT_MENTION]))): msg.reply_text("I can't extract a user from this.") return else: return text = "<b>Characteristics:</b>" \ "\nID: <code>{}</code>" \ "\nFirst Name: {}".format(user.id, html.escape(user.first_name)) if user.last_name: text += "\nLast Name: {}".format(html.escape(user.last_name)) if user.username: text += "\nUsername: @{}".format(html.escape(user.username)) text += "\nPermanent user link: {}".format(mention_html(user.id, "link")) disaster_level_present = False if user.id == OWNER_ID: text += "\n\nMoi creator!!💙 If you wanna know more about him visit his personal website anilchauhanxda.github.io" img = "https://telegra.ph/file/633307eb7b142003c096c.jpg" disaster_level_present = True elif user.id in HISOKA: text += "\n\nHe is Hisoka Morow (ヒソカ゠モロウ, Hisoka Morou) is a Hunter and former member #4 of the Phantom Troupe; his physical strength ranked third in the group. He is always in search for strong opponents, and would spare those who have great potential, such as Gon and Killua in order for them to get strong enough to actually challenge him. He originally served as the primary antagonist of the Hunter Exam arc and a secondary one of the Heavens Arena arc, before becoming a supporting character during the Yorknew City arc and Greed Island arc. During the 13th Hunter Chairman Election arc, he briefly reprises his role as a secondary antagonist.\n <i>'My greatest pleasure comes when such people crumple to their knees and I look down upon their disbelieving faces as their plans fail.♥'</i>" img = "https://telegra.ph/file/4aee5cfe2ba8a3fa503d0.jpg" disaster_level_present = True elif user.id in GING: text += "\n\nHe is Ging Freecss (ジン゠フリークス, Jin Furīkusu) is the father of Gon Freecss. He is a Double-Star Ruins Hunter (though he can apply for a Triple-Star License),and a former Zodiac with the codename 'Boar' (亥, I). Finding Ging was Gon's motivation for becoming a Hunter. \n <i>'I'm enjoying the journey. So if your destination is the same as mine, enjoy the side trips. A lot. Something more important than the thing you're hunting could be right there by the side of the road.'</i>" img = "https://telegra.ph/file/22a1c264865bd07af7556.png" disaster_level_present = True elif user.id in SHIZUKU: text += "\n\nHe is <b>Shizuku Murasaki</b> (シズク゠ムラサキ, Shizuku Murasaki) is member #8 of the Phantom Troupe, an infamous gang of thieves with class A bounties. Her physical strength ranks twelfth in the group. \n<i>'Breaking the rules means rejecting the Spiders, and Chrollo, too. That I never want to do.'</i> " img = "https://telegra.ph/file/31fcbda7396fb94d7fc62.png" disaster_level_present = True elif user.id in SILVA: text += "\n\nHe is my father Silva Zoldyck (シルバ゠ゾルディック, Shiruba Zorudikku) is the current head of the Zoldyck Family and the father of Killua.\n<i>'Never overreach your limits...! Make your move only when you're 100% positive you can make the kill. Otherwise, bide your time...!! It's foolish to show your hand when the odds are against you.'</i>" img = "https://telegra.ph/file/37bf67a10d77b9661bec1.png" disaster_level_present = True elif user.id in GON: text += "\n\nHe is Gon Freecss (ゴン゠フリークス, Gon Furīkusu) is a Rookie Hunter and the son of Ging Freecss. Finding his father is Gon's motivation in becoming a Hunter\n<i>'I can't stand being on the losing end forever!! '</i>" img = "https://telegra.ph/file/8f5d722e7f29da3226f03.png" disaster_level_present = True elif user.id in ILLUMI_ZOLDYCK: text += "\n\nHe is <b>Illumi Zoldyck</b> (イルミ゠ゾルディック, Irumi Zorudikku) is the eldest child of Silva and Kikyo Zoldyck. During the 287th Hunter Exam, he appeared under the guise of Gittarackur (ギタラクル, Gitarakuru). At Hisoka's request, Illumi joins the Phantom Troupe as Uvogin's replacement, becoming Troupe member #11. He served as a secondary antagonist of the Hunter Exam arc and the primary one of the 13th Hunter Chairman Election arc. \n<i>'Now I can tell you, that you would not make a good Hunter. Your calling is as an assassin. There's no fire in you, just darkness. It sustains you, drains you of any desire. Your only joy is in causing death, and even that is fleeting. That is how Dad and I molded you'</i>" img = "https://telegra.ph/file/689f2d3b1f5f2ae4d3005.png" disaster_level_present = True elif user.id in LEORIO: text += "\n\nHe is <b>Leorio Paradinight</b> (レオリオ゠パラディナイト, Reorio Paradinaito) is a Rookie Hunter and a member of the Zodiacs with the codename 'Boar' (亥, I). He is currently a medical student, with a goal to become a doctor.\n <i>'I'm a simple guy. Figured I'd become a doctor... so I could cure some kid with the same disease, tell his parents they owed me nothing! Me... A doctor! Now there's a joke!! Do you know how much it costs to even try to become a doctor? The mind boggles!! It's always about money! Always!! That's why I want it!'</i>" img = "https://telegra.ph/file/16cc60c94d7ff535e3957.png" disaster_level_present = True elif user.id in BISCUIT: text += "\n\nHe is <b>Biscuit Krueger</b> (ビスケット゠クルーガー, Bisuketto Kurūgā) is a Double-Star Stone Hunter[2] that enlisted in clearing the video game Greed Island following the auction for the game in Yorknew City. She prefers to be called 'Bisky' (ビスケ, Bisuke).\n <i>'After 50 years of lying through my teeth, I can tell whether someone's telling the truth.'</i>" img = "https://telegra.ph/file/f3439e1ea77e6f4a2d6bb.png" disaster_level_present = True elif user.id in CHROLLO: text += "\n\nHe is <b>Chrollo Lucilfer</b> (クロロ゠ルシルフル, Kuroro Rushirufuru) is the founder and leader and member #0[4] of the Phantom Troupe, an infamous gang of thieves with class A bounties. His physical strength ranks seventh in the group.\n <i>'Making the abilities yours while exploring the darkness within the soul of the original owner... that's the true pleasure of 'Skill Hunter'.'</i>" img = "https://telegra.ph/file/d4888fcbdeb3261a2a9cf.png" disaster_level_present = True elif user.id in KILLUA: text += "\n\nHe is my elder brother <b>Killua Zoldyck </b> (キルア゠ゾルディック, Kirua Zorudikku) is the third child of Silva and Kikyo Zoldyck and the heir of the Zoldyck Family, until he runs away from home and becomes a Rookie Hunter. He is the best friend of Gon Freecss, and is currently travelling with Alluka Zoldyck. \n <i>'I'm so tired of killing... I just want to be a kid. Hanging out, doing stuff with Gon. That's it'.'</i>" img = "https://telegra.ph/file/335efcdd8ffb462371582.png" disaster_level_present = True elif user.id in MERUEM: text += "\n\nHe is <b>Meruem </b>(メルエム, Meruemu) was the most powerful offspring of the Chimera Ant Queen. He was known as the 'King' (王, Ō) of the Chimera Ants, and served as the main antagonist of the Chimera Ant arc. \n <i>'Who am I? Why am I here? A king with no name. A borrowed castle. My subjects are mindless drones. If this is the mandate of Heaven I have been given... I fear... I fear nothing... except the tedium that it will bring!!!'.'</i>" img = "https://telegra.ph/file/348ae7fcba0116a9a4314.jpg" disaster_level_present = True elif user.id in KITE: text += """\n\nHe is <b>Kite (カイト)</b>, He is the very first Hunter introduced in the story. He is a disciple of Ging Freecss, Gon's father. After saving Gon from a foxbear on Whale Island, Kite revealed to him the truth about his father. Before he took his leave, Kite left Ging's Hunter License in Gon's hands. After leaving Greed Island, Gon runs into Kite again, while he is in the middle of a zoological survey, searching for new species, in the country of Kakin. At the time, he was leading a team of young would-be Hunters, seven children named Banana Kavaro, Lin Koshi, Monta Yuras, Podungo Lapoy, Spinner Clow, and Stick Dinner.""" img = "https://telegra.ph/file/520c4b38b71f82e312f5b.png" disaster_level_present = True if disaster_level_present: update.effective_message.reply_photo(img, text, parse_mode=ParseMode.HTML, disable_web_page_preview=True) return user_member = chat.get_member(user.id) if user_member.status == 'administrator': result = requests.post( f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}" ) result = result.json()["result"] if "custom_title" in result.keys(): custom_title = result['custom_title'] text += f"\n\nThis user holds the title <b>{custom_title}</b> here." for mod in USER_INFO: try: mod_info = mod.__user_info__(user.id).strip() except TypeError: mod_info = mod.__user_info__(user.id, chat.id).strip() if mod_info: text += "\n\n" + mod_info update.effective_message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def info(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat user_id = extract_user(update.effective_message, args) if user_id: user = bot.get_chat(user_id) elif not message.reply_to_message and not args: user = message.from_user elif not message.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not message.parse_entities([MessageEntity.TEXT_MENTION]))): message.reply_text("I can't extract a user from this.") return else: return text = (f"<b>Characteristics:</b>\n" f"ID: <code>{user.id}</code>\n" f"First Name: {html.escape(user.first_name)}") if user.last_name: text += f"\nLast Name: {html.escape(user.last_name)}" if user.username: text += f"\nUsername: @{html.escape(user.username)}" text += f"\nPermanent user link: {mention_html(user.id, 'link')}" num_chats = sql.get_user_num_chats(user.id) text += f"\nChat count: <code>{num_chats}</code>" try: user_member = chat.get_member(user.id) if user_member.status == 'administrator': result = requests.post( f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}" ) result = result.json()["result"] if "custom_title" in result.keys(): custom_title = result['custom_title'] text += f"\nThis user holds the title <b>{custom_title}</b> here." except BadRequest: pass if user.id == OWNER_ID: text += "\nThis person is my owner - I would never do anything against them!." elif user.id in DEV_USERS: text += "\nThis person is my dev - I would never do anything against them!." elif user.id in SUDO_USERS: text += "\nThis person is one of my sudo users! " \ "Nearly as powerful as my owner - so watch it.." elif user.id in SUPPORT_USERS: text += "\nThis person is one of my support users! " \ "Not quite a sudo user, but can still gban you off the map." elif user.id in WHITELIST_USERS: text += "\nThis person has been whitelisted! " \ "That means I'm not allowed to ban/kick them." text += "\n" for mod in USER_INFO: if mod.__mod_name__ == "Users": continue try: mod_info = mod.__user_info__(user.id) except TypeError: mod_info = mod.__user_info__(user.id, chat.id) if mod_info: text += "\n" + mod_info update.effective_message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def ungban(bot: Bot, update: Update, args: List[str]): message = update.effective_message user = update.effective_user chat = update.effective_chat log_message = "" user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return user_chat = bot.get_chat(user_id) if user_chat.type != 'private': message.reply_text("That's not a user!") return if not sql.is_user_gbanned(user_id): message.reply_text("This user is not gbanned!") return message.reply_text( f"I'll give {user_chat.first_name} a second chance, globally.") start_time = time.time() datetime_fmt = "%H:%M - %d-%m-%Y" current_time = datetime.utcnow().strftime(datetime_fmt) if chat.type != 'private': chat_origin = f"<b>{html.escape(chat.title)} ({chat.id})</b>\n" else: chat_origin = f"<b>{chat.id}</b>\n" log_message = ( f"#UNGBANNED\n" f"<b>Originated from:</b> {chat_origin}\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Unbanned User:</b> {mention_html(user_chat.id, user_chat.first_name)}\n" f"<b>Unbanned User ID:</b> {user_chat.id}\n" f"<b>Event Stamp:</b> {current_time}") if GBAN_LOGS: try: log = bot.send_message(GBAN_LOGS, log_message, parse_mode=ParseMode.HTML) except BadRequest as excp: log = bot.send_message( GBAN_LOGS, log_message + "\n\nFormatting has been disabled due to an unexpected error.") else: send_to_list(bot, SUDO_USERS + SUPPORT_USERS, log_message, html=True) chats = get_all_chats() ungbanned_chats = 0 for chat in chats: chat_id = chat.chat_id # Check if this group has disabled gbans if not sql.does_chat_gban(chat_id): continue try: member = bot.get_chat_member(chat_id, user_id) if member.status == 'kicked': bot.unban_chat_member(chat_id, user_id) ungbanned_chats += 1 except BadRequest as excp: if excp.message in UNGBAN_ERRORS: pass else: message.reply_text(f"Could not un-gban due to: {excp.message}") if GBAN_LOGS: bot.send_message( GBAN_LOGS, f"Could not un-gban due to: {excp.message}", parse_mode=ParseMode.HTML) else: bot.send_message( OWNER_ID, f"Could not un-gban due to: {excp.message}") return except TelegramError: pass sql.ungban_user(user_id) if GBAN_LOGS: log.edit_text(log_message + f"\n<b>Chats affected:</b> {ungbanned_chats}", parse_mode=ParseMode.HTML) else: send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "un-gban complete!") end_time = time.time() ungban_time = round((end_time - start_time), 2) if ungban_time > 60: ungban_time = round((ungban_time / 60), 2) message.reply_text( f"Person has been un-gbanned. Took {ungban_time} min") else: message.reply_text( f"Person has been un-gbanned. Took {ungban_time} sec")
def info(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat user_id = extract_user(update.effective_message, args) if user_id: user = bot.get_chat(user_id) elif not message.reply_to_message and not args: user = message.from_user elif not message.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not message.parse_entities([MessageEntity.TEXT_MENTION]))): message.reply_text("I can't extract a user from this.") return else: return text = (f"<b>Characteristics :-</b>\n\n" f"ID :- <code>{user.id}</code>\n" f"First Name :- {html.escape(user.first_name)}") if user.last_name: text += f"\nLast Name :- {html.escape(user.last_name)}" if user.username: text += f"\nUsername :- @{html.escape(user.username)}" text += f"\nUser Link :- {mention_html(user.id, ' Here 🤡')}" num_chats = sql.get_user_num_chats(user.id) text += f"\n\nMutual Chats :- <code>{num_chats}</code> \n" try: user_member = chat.get_member(user.id) if user_member.status == 'administrator': result = requests.post( f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}" ) result = result.json()["result"] if "custom_title" in result.keys(): custom_title = result['custom_title'] text += f"\nAdmin Title :- <b>{custom_title}</b> \n" except BadRequest: pass if user.id == OWNER_ID: text += "\nThis Person is my owner - I would never do anything against them!." elif user.id in DEV_USERS: text += "\nDEV USER : <b> YES </b> " elif user.id in SUDO_USERS: text += "\nSUDO USER : <b> YES </b> " elif user.id in SUPPORT_USERS: text += "\nSUPPORT USER : <b> YES </b>" elif user.id in WHITELIST_USERS: text += "\nWHITELIST USER : <b> YES </b>" update.effective_message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def info(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat user_id = extract_user(update.effective_message, args) if user_id: user = bot.get_chat(user_id) elif not message.reply_to_message and not args: user = message.from_user elif not message.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not message.parse_entities([MessageEntity.TEXT_MENTION]))): message.reply_text("I can't extract a user from this.") return else: return text = (f"<b>User Information:</b>\n" f"🆔: <code>{user.id}</code>\n" f"👤Name: {html.escape(user.first_name)}") if user.last_name: text += f"\n🚹Last Name: {html.escape(user.last_name)}" if user.username: text += f"\n♻️Username: @{html.escape(user.username)}" text += f"\n☣️Permanent user link: {mention_html(user.id, 'link🚪')}" num_chats = sql.get_user_num_chats(user.id) text += f"\n🌐Chat count: <code>{num_chats}</code>" text += "\n🎭Number of profile pics: {}".format( bot.get_user_profile_photos(user.id).total_count) try: user_member = chat.get_member(user.id) if user_member.status == 'administrator': result = requests.post( f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}" ) result = result.json()["result"] if "custom_title" in result.keys(): custom_title = result['custom_title'] text += f"\n🛡This user holds the title⚜️ <b>{custom_title}</b> here." except BadRequest: pass if user.id == OWNER_ID: text += "\n🚶🏻♂️Uff,This person is my Owner🤴\nI would never do anything against him!." elif user.id in DEV_USERS: text += "\n🚴♂️Pling,This person is my dev🤷♂️\nI would never do anything against him!." elif user.id in SUDO_USERS: text += "\n🚴♂️Pling,This person is one of my sudo users! " \ "Nearly as powerful as my owner🕊so watch it.." elif user.id in SUPPORT_USERS: text += "\n🚴♂️Pling,This person is one of my support users! " \ "Not quite a sudo user, but can still gban you off the map." elif user.id in WHITELIST_USERS: text += "\n🚴♂️Pling,This person has been whitelisted! " \ "That means I'm not allowed to ban/kick them." elif user.id == bot.id: text += "\n💃Lol🧞♂️It's Me😉" text += "\n" text += "\nCAS banned: " result = cas.banchecker(user.id) text += str(result) for mod in USER_INFO: if mod.__mod_name__ == "Users": continue try: mod_info = mod.__user_info__(user.id) except TypeError: mod_info = mod.__user_info__(user.id, chat.id) if mod_info: text += "\n" + mod_info try: profile = bot.get_user_profile_photos(user.id).photos[0][-1] bot.sendChatAction(chat.id, "upload_photo") bot.send_photo(chat.id, photo=profile, caption=(text), parse_mode=ParseMode.HTML, disable_web_page_preview=True) except IndexError: update.effective_message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def ungmute(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return user_chat = bot.get_chat(user_id) if user_chat.type != 'private': message.reply_text("That's not a user!") return if not sql.is_user_gmuted(user_id): message.reply_text("This user is not gmuted!") return muter = update.effective_user # type: Optional[User] message.reply_text("I'll let {} speak again, globally.".format(user_chat.first_name)) send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "<b>Regression of Global Mute</b>" \ "\n#UNGMUTE" \ "\n<b>Status:</b> <code>Ceased</code>" \ "\n<b>Sudo Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>ID:</b> <code>{}</code>".format(mention_html(muter.id, muter.first_name), mention_html(user_chat.id, user_chat.first_name), user_chat.id), html=True) chats = get_all_chats() for chat in chats: chat_id = chat.chat_id # Check if this group has disabled gmutes if not sql.does_chat_gmute(chat_id): continue try: member = bot.get_chat_member(chat_id, user_id) if member.status == 'restricted': bot.restrict_chat_member(chat_id, int(user_id), can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) except BadRequest as excp: if excp.message == "User is an administrator of the chat": pass elif excp.message == "Chat not found": pass elif excp.message == "Not enough rights to restrict/unrestrict chat member": pass elif excp.message == "User_not_participant": pass elif excp.message == "Method is available for supergroup and channel chats only": pass elif excp.message == "Not in the chat": pass elif excp.message == "Channel_private": pass elif excp.message == "Chat_admin_required": pass else: message.reply_text("Could not un-gmute due to: {}".format(excp.message)) bot.send_message(OWNER_ID, "Could not un-gmute due to: {}".format(excp.message)) return except TelegramError: pass sql.ungmute_user(user_id) send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "{} has been successfully un-gmuted!".format(mention_html(user_chat.id, user_chat.first_name)), html=True) message.reply_text("Person has been un-gmuted.")