def admin(client: Client, message: Message): global connection, constants # Checking if the message have the correct syntax if message.text.startswith("@admin") is False or len(message.matches) != 1: return message.text = message.text[len("@admin"):] if message.text != "" and message.text[0] not in list([" ", "\n", "\t"]): return # Retrieving the admins match = message.matches.pop(0) with connection.cursor() as cursor: cursor.execute("SELECT `id`, `username` FROM `Admins`") admins = cursor.fetchall() text = "\n@{} needs your help".format(message.from_user.username) # Retrieving the eventual message for the admins if match.group(2) != "": text += " for {}".format(match.group(2)) text += "." # Tagging the admins await message.reply_to_message.reply_text(" ".join(list(map(lambda n: "@{}".format(n["username"]), admins))), quote=True) await message.delete(revoke=True) for i in admins: await client.send_message(i["id"], "@{}{}".format(i["username"], text)) logger.info("I sent @{}\'s request to the competent admin.".format(message.from_user.username))
def same_word(client: Client, message: Message, command: str, word: str, word_type_list: Set[str], mid: int) -> bool: # Same word try: for word_type in word_type_list: message.text = f"{command} {word_type} {word}" if command in glovar.add_commands: text, markup = word_add(client, message) thread(send_message, (client, glovar.regex_group_id, text, mid, markup)) else: text, cc_list_unit = word_remove(client, message) thread(send_message, (client, glovar.regex_group_id, text, mid)) return True except Exception as e: logger.warning(f"Same word error: {e}", exc_info=True) return False
async def default_message_handler(client: Client, message: Message): message.text = "/" + "leech@Leech2vid_bot" + " " + message.text return await leech_handler.func(client, message)
async def func(client: Client, message: Message): message.text = "/" + COMMAND.LEECH + " " + message.text return await leech_handler.func(client, message)