def unban_user(message): 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("unbanProcess")}`') 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("cannotUnbanMyself")}`') except BaseException: pass for user in find_user: try: chat = message.chat chat.unban_member(user.id) edit( message, get_translation('unbanResult', ['**', user.first_name, user.id, '`']), ) except Exception as e: edit(message, get_translation('banError', ['`', '**', e])) return
def picspam(message): arr = extract_args_arr(message) if len(arr) < 2 or not arr[0].isdigit(): edit(message, f'`{get_translation("spamWrong")}`') return message.delete() if not spam_allowed(): return count = int(arr[0]) url = arr[1] for i in range(0, count): reply_img(message, url) limit = increment_spam_count() if not limit: break send_log(get_translation('picspamLog'))
def picspam(message): arr = extract_args_arr(message) if len(arr) < 2 or not arr[0].isdigit(): edit(message, f'`{get_translation("spamWrong")}`') return message.delete() if not spam_allowed(): return miktar = int(arr[0]) link = arr[1] for i in range(0, miktar): reply_img(message, link) count = increment_spam_count() if not count: break send_log(f'{get_translation("picspamLog")}')
def demote_user(message): 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("demoteProcess")}`') 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("cannotDemoteMyself")}`') except BaseException: pass for user in find_user: try: chat = message.chat chat.promote_member( user.id, privileges=ChatPrivileges( can_manage_chat=False, can_delete_messages=False, can_manage_video_chats=False, can_restrict_members=False, can_change_info=False, can_invite_users=False, can_pin_messages=False, can_promote_members=False, ), ) edit( message, get_translation('demoteResult', ['**', user.first_name, user.id, '`']), ) except Exception as e: edit(message, get_translation('banError', ['`', '**', e])) return
def ungmute_user(client, message): 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("cannotUnmuteMyself")}`') except BaseException: pass for user in find_user: try: if not sql2.is_gmuted(user.id): return edit(message, f'`{get_translation("alreadyUnmuted")}`') sql2.ungmute(user.id) try: common_chats = client.get_common_chats(user.id) for i in common_chats: i.unban_member(user.id) except BaseException: pass 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
def ungban_user(client, message): 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("unbanProcess")}`') 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("cannotUnbanMyself")}`') except BaseException: pass for user in find_user: try: if not sql.is_gbanned(user.id): return edit(message, f'`{get_translation("alreadyUnbanned")}`') sql.ungban(user.id) def find_me(dialog): try: return (dialog.chat.get_member(me_id).privileges and dialog.chat.get_member( me_id).privileges.can_restrict_members) except BaseException: return False def find_member(dialog): try: return (dialog.chat.get_member(user.id) and dialog.chat.get_member(user.id).restricted_by and dialog.chat.get_member( user.id).restricted_by.id == me_id) except BaseException: return False try: dialogs = client.get_dialogs() me_id = TEMP_SETTINGS['ME'].id chats = [ dialog.chat for dialog in dialogs if (dialog.chat.type in [enums.ChatType.SUPERGROUP, enums.ChatType.GROUP] and find_me(dialog) and find_member(dialog)) ] for chat in chats: chat.unban_member(user.id) except BaseException: pass edit( message, get_translation('unbanResult', ['**', user.first_name, user.id, '`']), ) except Exception as e: edit(message, get_translation('banError', ['`', '**', e])) return