def gbanChat(update: Update, context: CallbackContext): bot = context.bot args = context.args if args and len(args) == 1: chat_id = str(args[0]) del args[0] try: banner = update.effective_user send_to_list( bot, SUDO_USERS, "<b>Chat Blacklist</b>" "\n#BLCHAT" "\n<b>Status:</b> <code>Blacklisted</code>" "\n<b>Sudo Admin:</b> {}" "\n<b>Chat Name:</b> {}" "\n<b>ID:</b> <code>{}</code>".format( mention_html(banner.id, banner.first_name), userssql.get_chat_name(chat_id), chat_id, ), html=True, ) sql.blacklistChat(chat_id) update.effective_message.reply_text( "Chat has been successfully blacklisted!") try: bot.leave_chat(int(chat_id)) except: pass except: update.effective_message.reply_text("Error blacklisting chat!") else: update.effective_message.reply_text("Give me a valid chat id!")
def ungbanChat(bot: Bot, update: Update, args: List[str]): if args and len(args) == 1: chat_id = str(args[0]) del args[0] try: banner = update.effective_user send_to_list(bot, SUDO_USERS, "<b>Regression of Chat Blacklist</b>" \ "\n#UNBLCHAT" \ "\n<b>Status:</b> <code>Un-Blacklisted</code>" \ "\n<b>Sudo Admin:</b> {}" \ "\n<b>Chat Name:</b> {}" \ "\n<b>ID:</b> <code>{}</code>".format(mention_html(banner.id, banner.first_name),userssql.get_chat_name(chat_id),chat_id), html=True) sql.unblacklistChat(chat_id) update.effective_message.reply_text( "Chat has been successfully un-blacklisted!") except: update.effective_message.reply_text("Error unblacklisting chat!") else: update.effective_message.reply_text("Give me a valid chat id!")