def goodbye(update, context): chat = update.effective_chat # type: Optional[Chat] args = context.args if len(args) == 0 or args[0] == "noformat": noformat = args and args[0] == "noformat" pref, goodbye_m, goodbye_type = sql.get_gdbye_pref(chat.id) update.effective_message.reply_text( "This chat has it's goodbye setting set to: `{}`.\n*The goodbye message " "(not filling the {{}}) is:*".format(pref), parse_mode=ParseMode.MARKDOWN, ) if goodbye_type == sql.Types.BUTTON_TEXT: buttons = sql.get_gdbye_buttons(chat.id) if noformat: goodbye_m += revert_buttons(buttons) update.effective_message.reply_text(goodbye_m) else: keyb = build_keyboard(buttons) keyboard = InlineKeyboardMarkup(keyb) send(update, goodbye_m, keyboard, sql.DEFAULT_GOODBYE) else: if noformat: ENUM_FUNC_MAP[goodbye_type](chat.id, goodbye_m) else: ENUM_FUNC_MAP[goodbye_type](chat.id, goodbye_m, parse_mode=ParseMode.MARKDOWN) elif len(args) >= 1: if args[0].lower() in ("on", "yes"): sql.set_gdbye_preference(str(chat.id), True) update.effective_message.reply_text( "I'll be sorry when people leave!") elif args[0].lower() in ("off", "no"): sql.set_gdbye_preference(str(chat.id), False) update.effective_message.reply_text( "They leave, they're dead to me.") else: # idek what you're writing, say yes or no update.effective_message.reply_text( "I understand 'on/yes' or 'off/no' only!")
def goodbye(update: Update, context: CallbackContext): args = context.args chat = update.effective_chat if not args or args[0] == "noformat": noformat = True pref, goodbye_m, goodbye_type = sql.get_gdbye_pref(chat.id) update.effective_message.reply_text( f"This chat has it's goodbye setting set to: `{pref}`.\n" f"*The goodbye message (not filling the {{}}) is:*", parse_mode=ParseMode.MARKDOWN) if goodbye_type == sql.Types.BUTTON_TEXT: buttons = sql.get_gdbye_buttons(chat.id) if noformat: goodbye_m += revert_buttons(buttons) update.effective_message.reply_text(goodbye_m) else: keyb = build_keyboard(buttons) keyboard = InlineKeyboardMarkup(keyb) send(update, goodbye_m, keyboard, sql.DEFAULT_GOODBYE) else: if noformat: ENUM_FUNC_MAP[goodbye_type](chat.id, goodbye_m) else: ENUM_FUNC_MAP[goodbye_type](chat.id, goodbye_m, parse_mode=ParseMode.MARKDOWN) elif len(args) >= 1: if args[0].lower() in ("on", "yes"): sql.set_gdbye_preference(str(chat.id), True) update.effective_message.reply_text("Ok!") elif args[0].lower() in ("off", "no"): sql.set_gdbye_preference(str(chat.id), False) update.effective_message.reply_text("Ok!") else: # idek what you're writing, say yes or no update.effective_message.reply_text( "I understand 'on/yes' or 'off/no' only!")