async def _(event): xx = await edit_or_reply(event, "`Searching Participant Lists...`") p = 0 title = (await event.get_chat()).title async for i in event.client.iter_participants( event.chat_id, filter=ChannelParticipantsKicked, aggressive=True, ): try: await event.client.edit_permissions(event.chat_id, i, view_messages=True) p += 1 except ChatAdminRequiredError: pass except BaseException as er: LOGS.exception(er) await xx.edit(f"**Berhasil unbanned** `{p}` **Orang di Grup {title}**")
async def wrapper(check): if check.edit_date and check.is_channel and not check.is_group: # Messages sent in channels can be edited by other users. # Ignore edits that take place in channels. return if group_only and not check.is_group: await check.respond("`Are you sure this is a group?`") return if check.via_bot_id and not insecure and check.out: # Ignore outgoing messages via inline bots for security reasons return try: await func(check) # # HACK HACK HACK # Raise StopPropagation to Raise StopPropagation # This needed for AFK to working properly # TODO # Rewrite events to not passing all exceptions # except events.StopPropagation: raise events.StopPropagation # This is a gay exception and must be passed out. # So that it doesnt spam chats except KeyboardInterrupt: pass except BaseException as e: # Check if we have to disable error logging. if not disable_errors: LOGS.exception(e) # Log the error in console date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) text = "**Sorry, I encountered a error!**\n" link = "https://git.io/JfSry" text += "If you wanna you can report it" text += f"- just open an issue on {link}.\n" text += "I won't log anything except the error and date\n" ftext = "\nDisclaimer:\nThis file uploaded ONLY here, " ftext += "we logged only fact of error and date, " ftext += "we respect your privacy, " ftext += "you may not report this error if you've " ftext += "any confidential data here, no one will see your data " ftext += "if you choose not to do so.\n\n" ftext += "--------BEGIN USERBOT TRACEBACK LOG--------" ftext += "\nDate: " + date ftext += "\nGroup ID: " + str(check.chat_id) ftext += "\nSender ID: " + str(check.sender_id) ftext += "\n\nEvent Trigger:\n" ftext += str(check.text) ftext += "\n\nTraceback info:\n" ftext += str(format_exc()) ftext += "\n\nError text:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------END USERBOT TRACEBACK LOG--------" command = "git log --pretty=format:\"%an: %s\" -10" ftext += "\n\n\nLast 10 commits:\n" process = await asyncsubshell(command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE) stdout, stderr = await process.communicate() result = str(stdout.decode().strip()) \ + str(stderr.decode().strip()) ftext += result file = open("error.log", "w+") file.write(ftext) file.close() if BOTLOG: await check.client.send_file( BOTLOG_CHATID, "error.log", caption=text, ) else: await check.client.send_file( check.chat_id, "error.log", caption=text, ) remove("error.log") else: pass
async def wrapper(check): if check.edit_date and check.is_channel and not check.is_group: # Messages sent in channels can be edited by other users. # Ignore edits that take place in channels. return if not is_chat_allowed(check): return if check.via_bot_id and check.out: return try: await func(check) # Thanks to @kandnub for this HACK. # Raise StopPropagation to Raise StopPropagation # This needed for AFK to working properly except events.StopPropagation: raise events.StopPropagation # This is a gay exception and must be passed out. So that it doesnt # spam chats except KeyboardInterrupt: pass except BaseException as e: # Check if we have to disable error logging. if not disable_errors: LOGS.exception(e) # Log the error in console date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) link = "[Support Chat](https://t.me/KensurOT)" text = ( "**USERBOT ERROR REPORT**\n" "If you want to, you can report it" f"- just forward this message to {link}.\n" "I won't log anything except the fact of error and date\n" ) command = 'git log --pretty=format:"%an: %s" -10' process = await asyncsubshell(command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE) stdout, stderr = await process.communicate() ftext = ( "\nDisclaimer:\nThis file uploaded ONLY here, we " "logged only fact of error and date, we respect your " "privacy, you may not report this error if you've any " "confidential data here, no one will see your data if " "you choose not to do so.\n\n" "--------BEGIN USERBOT TRACEBACK LOG--------" f"\nDate: {date}\nChat ID: {check.chat_id}" f"\nSender ID: {check.sender_id}\n\nEvent Trigger:\n" f"{check.text}\n\nTraceback info:\n{format_exc()}" f"\n\nError text:\n{exc_info()[1]}" "\n\n--------END USERBOT TRACEBACK LOG--------" "\n\n\nLast 10 commits:\n" f"{stdout.decode().strip()}{stderr.decode().strip()}") with open("error.log", "w+") as file: file.write(ftext) if LOGSPAMMER: await check.client.send_file( BOTLOG_CHATID, "error.log", caption=text, ) else: await check.client.send_file( check.chat_id, "error.log", caption=text, ) remove("error.log") else: pass
async def wrapper(check): if check.edit_date and check.is_channel and not check.is_group: # Messages sent in channels can be edited by other users. # Ignore edits that take place in channels. return if not LOGSPAMMER: check.chat_id else: pass if not trigger_on_fwd and check.fwd_from: return if groups_only and not check.is_group: await check.respond("`I don't think this is a group.`") return if check.via_bot_id and not insecure and check.out: return try: await func(check) # Thanks to @kandnub for this HACK. # Raise StopPropagation to Raise StopPropagation # This needed for AFK to working properly except events.StopPropagation: raise events.StopPropagation # This is a gay exception and must be passed out. So that it doesnt # spam chats except KeyboardInterrupt: pass except BaseException as e: # Check if we have to disable error logging. if not disable_errors: LOGS.exception(e) # Log the error in console date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) text = "**USERBOT ERROR REPORT**\n" link = "[Support Chat](https://t.me/KenVerseChat)" text += "If you want to, you can report it" text += f"- just forward this message to {link}.\n" text += "I won't log anything except the fact of error and date\n" ftext = "\nDisclaimer:\nThis file uploaded ONLY here, " ftext += "we logged only fact of error and date, " ftext += "we respect your privacy, " ftext += "you may not report this error if you've " ftext += "any confidential data here, no one will see your data " ftext += "if you choose not to do so.\n\n" ftext += "--------BEGIN USERBOT TRACEBACK LOG--------" ftext += "\nDate: " + date ftext += "\nChat ID: " + str(check.chat_id) ftext += "\nSender ID: " + str(check.sender_id) ftext += "\n\nEvent Trigger:\n" ftext += str(check.text) ftext += "\n\nTraceback info:\n" ftext += str(format_exc()) ftext += "\n\nError text:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------END USERBOT TRACEBACK LOG--------" command = 'git log --pretty=format:"%an: %s" -10' ftext += "\n\n\nLast 10 commits:\n" process = await asyncsubshell(command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE) stdout, stderr = await process.communicate() result = str(stdout.decode().strip()) + str( stderr.decode().strip()) ftext += result file = open("error.log", "w+") file.write(ftext) file.close() if LOGSPAMMER: await check.client.send_file( BOTLOG_CHATID, "error.log", caption=text, ) else: await check.client.send_file( check.chat_id, "error.log", caption=text, ) remove("error.log") else: pass
async def wrapper(check): if check.edit_date and check.is_channel and not check.is_group: # Messages sent in channels can be edited by other users. # Ignore edits that take place in channels. return if not trigger_on_fwd and check.fwd_from: return if groups_only and not check.is_group: await check.respond("`I don't think this is a group.`") return if check.via_bot_id and not insecure and check.out: return try: await func(check) # Thanks to @kandnub for this HACK. # Raise StopPropagation to Raise StopPropagation # This needed for AFK to working properly except events.StopPropagation: raise events.StopPropagation # This is a gay exception and must be passed out. So that it doesnt # spam chats except KeyboardInterrupt: pass except BaseException as e: # Check if we have to disable error logging. if not disable_errors: LOGS.exception(e) # Log the error in console date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) text = "**USERBOT ERROR REPORT**\n" text += "Nothing is logged except the fact of error and date\n\n" ftext = "========== DISCLAIMER ==========" ftext += "\nThis file uploaded ONLY here," ftext += "\nwe logged only fact of error and date," ftext += "\nwe respect your privacy," ftext += "\nyou may not report this error if you've" ftext += "\nany confidential data here, no one will see your data\n" ftext += "================================\n\n" ftext += "--------BEGIN USERBOT TRACEBACK LOG--------\n" ftext += "\nDate: " + date ftext += "\nChat ID: " + str(check.chat_id) ftext += "\nSender ID: " + str(check.sender_id) ftext += "\n\nEvent Trigger:\n" ftext += str(check.text) ftext += "\n\nTraceback info:\n" ftext += str(format_exc()) ftext += "\n\nError text:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------END USERBOT TRACEBACK LOG--------" command = 'git log --pretty=format:"%an: %s" -10' ftext += "\n\n\nLast 10 commits:\n" process = await asyncsubshell(command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE) stdout, stderr = await process.communicate() result = str(stdout.decode().strip()) + str( stderr.decode().strip()) ftext += result with open("error.txt", "w+") as file: file.write(ftext) if LOGSPAMMER: await check.respond("`Sorry, my userbot has crashed.\ \nThe error logs are stored in the userbot's log chat.`" ) log = codecs.open("error.txt", "r", encoding="utf-8") data = log.read() key = (requests.post( "https://nekobin.com/api/documents", json={ "content": data }, ).json().get("result").get("key")) url = f"https://nekobin.com/raw/{key}" anu = f"{text}Pasted to: [Nekobin]({url})" await check.client.send_file(send_to, "error.txt", caption=anu) remove("error.txt") else: pass
async def wrapper(check): if check.edit_date and check.is_channel and not check.is_group: # Messages sent in channels can be edited by other users. # Ignore edits that take place in channels. return if not trigger_on_fwd and check.fwd_from: return if groups_only and not check.is_group: await check.respond("`Eu não acho que isso seja um grupo.`") return try: from userbot.modules.sql_helper.blacklist_sql import get_blacklist for blacklisted in get_blacklist(): if str(check.chat_id) == blacklisted.chat_id: return except Exception: pass if check.via_bot_id and not insecure and check.out: return try: await func(check) # Thanks to @kandnub for this HACK. # Raise StopPropagation to Raise StopPropagation # This needed for AFK to working properly except events.StopPropagation: raise events.StopPropagation # This is a gay exception and must be passed out. So that it doesnt # spam chats except KeyboardInterrupt: pass except BaseException as e: # Check if we have to disable error logging. if not disable_errors: LOGS.exception(e) # Log the error in console date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) text = "**RELATÓRIO DE ERRO DO USERBOT**\n" link = "[SUPORTE](https://t.me/Kircheiss)" text += "Caso queira" text += f"- encaminhe esta mensagem para {link}.\n" text += "Nada será registrado, exceto o módulo do erro e a data\n" ftext = "\nALERTA:\nEste arquivo foi carregado SOMENTE aqui, " ftext += "registramos apenas o motivo do erro e a data, " ftext += "Nós respeitamos sua privacidade, " ftext += "você não deve relatar este erro caso existam " ftext += "quaisquer dados confidenciais aqui, ninguém vai ver seus dados " ftext += "se você escolher não fazer isso.\n\n" ftext += "--------INÍCIO DO RELATÓRIO--------" ftext += "\nData: " + date ftext += "\nChat ID: " + str(check.chat_id) ftext += "\nUser ID: " + str(check.sender_id) ftext += "\n\nComando:\n" ftext += str(check.text) ftext += "\n\nInformações de traceback:\n" ftext += str(format_exc()) ftext += "\n\nTexto de erro:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------FIM DO RELATÓRIO--------" command = 'git log --pretty=format:"%an: %s" -10' ftext += "\n\n\nÚltimos 10 commits:\n" process = await asyncsubshell(command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE) stdout, stderr = await process.communicate() result = str(stdout.decode().strip()) + str( stderr.decode().strip()) ftext += result with open("error.log", "w+") as file: file.write(ftext) if LOGSPAMMER: await check.client.send_file( BOTLOG_CHATID, "error.log", caption=text, ) else: await check.client.send_file( check.chat_id, "error.log", caption=text, ) remove("error.log") else: pass
async def wrapper(event): if not allow_sudo: if not event.out: return if not event.out and (str(event.sender_id) not in SUDO_USERS): return chat = await event.get_chat() naam = get_display_name(chat) if event.fwd_from: return if groups_only and event.is_private: return await eor(event, "`Use this in group/channel.`") if admins_only and not chat.admin_rights: return await eor(event, "`I am not an admin.`") try: await func(event) except FloodWaitError as fwerr: await petercord_bot.send_message( int(BOTLOG_CHATID), f"`FloodWaitError:\n{str(fwerr)}\n\nSleeping for {time_formatter((fwerr.seconds + 10)*1000)}`", ) sleep(fwerr.seconds + 10) await petercord_bot.send_message( int(BOTLOG_CHATID), "`Bot is working again`", ) await petercord_bot.send_message( int(BOTLOG_CHATID), "`Bot is working again`", ) except ChatSendInlineForbiddenError: return await eor(event, "`Inline Locked In This Chat.`") except events.StopPropagation: raise events.StopPropagation except KeyboardInterrupt: pass except BaseException as e: LOGS.exception(e) date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) ftext = "**Petercord Client Error:** `Forward this to` @TEAMSquadUserbotSupport\n\n" ftext += "`Py-Petercord Version: " + str(telever) ftext += "\n Petercord Version: " + str(telever) ftext += "\nTelethon Version: " + str(telever) + "\n\n" ftext += "--------START Petercord CRASH LOG--------" ftext += "\nDate: " + date ftext += "\nGroup: " + str(event.chat_id) + " " + str(naam) ftext += "\nSender ID: " + str(event.sender_id) ftext += "\nReplied: " + str(event.is_reply) ftext += "\n\nEvent Trigger:\n" ftext += str(event.text) ftext += "\n\nTraceback info:\n" ftext += str(format_exc()) ftext += "\n\nError text:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------END Petercord CRASH LOG--------" ftext += "\n\n\nLast 5 commits:\n" stdout, stderr = await bash( 'git log --pretty=format:"%an: %s" -5') result = str(stdout.strip()) + str(stderr.strip()) ftext += result + "`" await petercord_bot.send_message( int(BOTLOG_CHATID), ftext, )
async def wrapper(event): chat = event.chat if admins_only: if event.is_private: return await edit_delete( event, "**Perintah ini hanya bisa digunakan di grup.**", 10) if not (chat.admin_rights or chat.creator): return await edit_delete( event, f"**Maaf anda bukan admin di {chat.title}**", 10) if group_only and not event.is_group: return await edit_delete( event, "**Perintah ini hanya bisa digunakan di grup.**", 10) if private_only and not event.is_private: return await edit_delete( event, "**Perintah ini hanya bisa digunakan di private chat.**", 10) try: await func(event) # Credits: @mrismanaziz # FROM Man-Userbot <https://github.com/mrismanaziz/Man-Userbot> # t.me/SharingUserbot & t.me/Lunatic0de except MessageNotModifiedError as er: LOGS.error(er) except MessageIdInvalidError as er: LOGS.error(er) except BotInlineDisabledError: await edit_delete( event, "**Silahkan aktifkan mode Inline untuk bot**", 10) except ChatSendStickersForbiddenError: await edit_delete( event, "**Tidak dapat mengirim stiker di obrolan ini**", 10) except BotResponseTimeoutError: await edit_delete( event, "**The bot didnt answer to your query in time**") except ChatSendMediaForbiddenError: await edit_delete( event, "**Tidak dapat mengirim media dalam obrolan ini**", 10) except AlreadyInConversationError: await edit_delete( event, "**Percakapan sudah terjadi dengan obrolan yang diberikan. coba lagi setelah beberapa waktu.**", ) except ChatSendInlineForbiddenError: await edit_delete( event, "**Tidak dapat mengirim pesan inline dalam obrolan ini.**", 10, ) except FloodWaitError as e: LOGS.error( f"Telah Terjadi flood wait error tunggu {e.seconds} detik dan coba lagi" ) await event.delete() await asyncio.sleep(e.seconds + 5) except events.StopPropagation: raise events.StopPropagation except KeyboardInterrupt: pass except BaseException as e: LOGS.exception(e)