def del_lockables(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] message = update.effective_message # type: Optional[Message] for lockable, filter in LOCK_TYPES.items(): if lockable == "rtl": if sql.is_locked(chat.id, lockable) and can_delete(chat, bot.id): if message.caption: check = ad.detect_alphabet(u'{}'.format(message.caption)) if 'ARABIC' in check: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") if message.text: check = ad.detect_alphabet(u'{}'.format(message.text)) if 'ARABIC' in check: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") break if filter(message) and sql.is_locked(chat.id, lockable) and can_delete( chat, bot.id): if lockable == "bots": new_members = update.effective_message.new_chat_members for new_mem in new_members: if new_mem.is_bot: if not is_bot_admin(chat, bot.id): message.reply_text( "Saya melihat bot, dan saya diberitahu untuk menghentikan mereka bergabung... " "tapi saya bukan admin!") return chat.kick_member(new_mem.id) message.reply_text( "Hanya admin yang diizinkan menambahkan bot ke obrolan ini! Keluar dari sini!" ) else: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") break
def del_lockables(update, context): chat = update.effective_chat # type: Optional[Chat] message = update.effective_message # type: Optional[Message] for lockable, filter in LOCK_TYPES.items(): if lockable == "rtl": if sql.is_locked(chat.id, lockable) and can_delete( chat, context.bot.id): if message.caption: check = ad.detect_alphabet(u'{}'.format(message.caption)) if 'ARABIC' in check: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") getconf = sql.get_lockconf(chat.id) if getconf: warn( update.effective_user, chat, tl( update.effective_message, "Mengirim 'Teks RTL' yang sedang di kunci saat ini" ), message, update.effective_user, conn=False) break if message.text: check = ad.detect_alphabet(u'{}'.format(message.text)) if 'ARABIC' in check: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") getconf = sql.get_lockconf(chat.id) if getconf: warn( update.effective_user, chat, tl( update.effective_message, "Mengirim 'Teks RTL' yang sedang di kunci saat ini" ), message, update.effective_user, conn=False) break continue if lockable == "button": if sql.is_locked(chat.id, lockable) and can_delete( chat, context.bot.id): if message.reply_markup and message.reply_markup.inline_keyboard: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") getconf = sql.get_lockconf(chat.id) if getconf: warn( update.effective_user, chat, tl( update.effective_message, "Mengirim 'Pesan Tombol' yang sedang di kunci saat ini" ), message, update.effective_user, conn=False) break continue if filter(update) and sql.is_locked(chat.id, lockable) and can_delete( chat, context.bot.id): if lockable == "bots": new_members = update.effective_message.new_chat_members for new_mem in new_members: if new_mem.is_bot: if not is_bot_admin(chat, context.bot.id): send_message( update.effective_message, tl( update.effective_message, "Saya melihat bot, dan saya diberitahu untuk menghentikan mereka bergabung... " "tapi saya bukan admin!")) return chat.kick_member(new_mem.id) send_message( update.effective_message, tl( update.effective_message, "Hanya admin yang diizinkan menambahkan bot ke obrolan ini! Keluar dari sini!" )) getconf = sql.get_lockconf(chat.id) if getconf: warn( update.effective_user, chat, tl( update.effective_message, "Memasukan 'Bot' yang sedang di kunci saat ini" ), message, update.effective_user, conn=False) break else: try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in lockables") getconf = sql.get_lockconf(chat.id) if getconf: warn(update.effective_user, chat, tl(update.effective_message, "Mengirim '{}' yang sedang di kunci saat ini"). format(lockable), message, update.effective_user, conn=False) break