def welcome(update, context): chat = update.effective_chat # type: Optional[Chat] args = context.args # if no args, show current replies. if len(args) == 0 or args[0].lower() == "noformat": noformat = args and args[0].lower() == "noformat" pref, welcome_m, welcome_type = sql.get_welc_pref(chat.id) update.effective_message.reply_text( "This chat has it's welcome setting set to: `{}`.\n*The welcome message " "(not filling the {{}}) is:*".format(pref), parse_mode=ParseMode.MARKDOWN, ) if welcome_type == sql.Types.BUTTON_TEXT: buttons = sql.get_welc_buttons(chat.id) if noformat: welcome_m += revert_buttons(buttons) update.effective_message.reply_text(welcome_m) else: keyb = build_keyboard(buttons) keyboard = InlineKeyboardMarkup(keyb) send(update, welcome_m, keyboard, sql.DEFAULT_WELCOME) else: if noformat: ENUM_FUNC_MAP[welcome_type](chat.id, welcome_m) else: ENUM_FUNC_MAP[welcome_type](chat.id, welcome_m, parse_mode=ParseMode.MARKDOWN) elif len(args) >= 1: if args[0].lower() in ("on", "yes"): sql.set_welc_preference(str(chat.id), True) update.effective_message.reply_text("I'll be polite!") elif args[0].lower() in ("off", "no"): sql.set_welc_preference(str(chat.id), False) update.effective_message.reply_text( "I'm sulking, not gonna greet anymore.") else: # idek what you're writing, say yes or no update.effective_message.reply_text( "I understand 'on/yes' or 'off/no' only!")
def welcome(update: Update, context: CallbackContext): args = context.args chat = update.effective_chat # if no args, show current replies. if not args or args[0].lower() == "noformat": noformat = True pref, welcome_m, welcome_type = sql.get_welc_pref(chat.id) update.effective_message.reply_text( f"This chat has it's welcome setting set to: `{pref}`.\n" f"*The welcome message (not filling the {{}}) is:*", parse_mode=ParseMode.MARKDOWN) if welcome_type == sql.Types.BUTTON_TEXT: buttons = sql.get_welc_buttons(chat.id) if noformat: welcome_m += revert_buttons(buttons) update.effective_message.reply_text(welcome_m) else: keyb = build_keyboard(buttons) keyboard = InlineKeyboardMarkup(keyb) send(update, welcome_m, keyboard, sql.DEFAULT_WELCOME) else: if noformat: ENUM_FUNC_MAP[welcome_type](chat.id, welcome_m) else: ENUM_FUNC_MAP[welcome_type](chat.id, welcome_m, parse_mode=ParseMode.MARKDOWN) elif len(args) >= 1: if args[0].lower() in ("on", "yes"): sql.set_welc_preference(str(chat.id), True) update.effective_message.reply_text( "Okay! I'll greet members when they join.") elif args[0].lower() in ("off", "no"): sql.set_welc_preference(str(chat.id), False) update.effective_message.reply_text( "I'll go loaf around and not welcome anyone then.") else: update.effective_message.reply_text( "I understand 'on/yes' or 'off/no' only!")