def unmute_user(client, message): args = extract_args(message) reply = message.reply_to_message edit(message, f'`{get_translation("unmuteProcess")}`') if args: try: user = client.get_users(args) except Exception: edit(message, f'`{get_translation("banFailUser")}`') return elif reply: user_id = reply.from_user.id user = client.get_users(user_id) else: edit(message, f'`{get_translation("banFailUser")}`') return try: replied_user = reply.from_user if replied_user.is_self: return edit(message, f'`{get_translation("cannotUnbanMyself")}`') except BaseException: pass try: chat_id = message.chat.id sql.unmute(chat_id, user.id) client.unban_chat_member(chat_id, user.id) edit( message, get_translation('unmuteResult', ['**', user.first_name, user.id, '`']), ) except Exception as e: edit(message, get_translation('banError', ['`', '**', e])) return
def unmute_user(message): try: from sedenecem.sql import mute_sql as sql except BaseException: edit(message, f'`{get_translation("nonSqlMode")}`') return args = extract_args_arr(message) if len(args) > 1: return edit(message, f'`{get_translation("wrongCommand")}`') reply = message.reply_to_message edit(message, f'`{get_translation("unmuteProcess")}`') find_user = extract_user(message) if len(find_user) < 1: return edit(message, f'`{get_translation("banFailUser")}`') try: replied_user = reply.from_user if replied_user.is_self: return edit(message, f'`{get_translation("cannotMuteMyself")}`') except BaseException: pass for user in find_user: try: chat = message.chat sql.unmute(chat.id, user.id) chat.unban_member(user.id) edit( message, get_translation('unmuteResult', ['**', user.first_name, user.id, '`']), ) except Exception as e: edit(message, get_translation('banError', ['`', '**', e])) return