def list_nsfw_chats(update: Update, context: CallbackContext): chats = sql.get_all_nsfw_chats() text = "<b>NSFW Activated Chats</b>\n" for chat in chats: try: x = context.bot.get_chat(int(*chat)) name = x.title if x.title else x.first_name text += f"• <code>{name}</code>\n" except BadRequest: sql.rem_nsfw(*chat) except Unauthorized: sql.rem_nsfw(*chat) except RetryAfter as e: sleep(e.retry_after) update.effective_message.reply_text(text, parse_mode="HTML")
def rem_nsfw(update: Update, context: CallbackContext): msg = update.effective_message chat = update.effective_chat user = update.effective_user is_nsfw = sql.is_nsfw(chat.id) if not is_nsfw: msg.reply_text("NSFW Mode is already Deactivated") return "" else: sql.rem_nsfw(chat.id) msg.reply_text("Rolled Back to SFW Mode!") message = ( f"<b>{html.escape(chat.title)}:</b>\n" f"DEACTIVATED_NSFW\n" f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n" ) return message