def _log_wrapper(bot, update): username, user_id, query = get_meta_from_update(update) log.debug('Processing: "{text}" from user {username} ({id})'.format( text=query, username=username, id=user_id)) return func(bot, update)
def _log_wrapper(bot, update): username, user_id, command = get_meta_from_update(update) log.debug('Command: "{command}" from user {username} ({id})'.format( command=command, username=username, id=user_id)) return func(bot, update)
def ask_for_eta(bot, update): """TODO""" ASK_ETA_MESSAGE = ("Cool. When do you think you'll be done?") username, user_id, message_text = get_meta_from_update(update) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=ASK_ETA_MESSAGE)
def on_inline_query(update, context) -> None: """ Forward the query to the controller method and respond """ username, user_id, query_text = get_meta_from_update(update) if not query_text: update.inline_query.answer(inline_query_transform('')) return update.inline_query.answer( inline_query_transform(generate_cate_response(query_text=query_text)))
def next_step(bot, update): """TODO""" NEXT_STEP_MESSAGE = ( "Cool. Keep typin' in more steps (one per message) to keep " "addin' to the list, or send `/done` if you're done.") username, user_id, message_text = get_meta_from_update(update) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=NEXT_STEP_MESSAGE)
def on_command_help(bot, update): """ Provides the user with information about the bot. """ HELP_COMMAND_TEXT = ("/start -- Creates a new series of steps to track!\n") username, user_id, message_text = get_meta_from_update(update) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=HELP_COMMAND_TEXT)
def on_command_start(bot, update): """Welcome message handler for /start""" WELCOME_MESSAGE_TEXT = ( "Yo! My name is **UnderwayBot.** I can help you send ETAs " "to your friends to tell 'em __when you'll be ready,__ as " "well as track steps along your way.\n\n" "Start typin' the first step on your journey to get started.") username, user_id, message_text = get_meta_from_update(update) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=WELCOME_MESSAGE_TEXT)
def on_message_text(bot, update) -> None: """ Forward the message text to the controller method and respond """ username, user_id, message_text = get_meta_from_update(update) if not message_text: return bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=generate_inline_response(query_text=message_text))
def confirm_start(bot, update): """TODO""" username, user_id, message_text = get_meta_from_update(update) CONFIRM_MESSAGE = ( "Nice! Your progress has begun bein' tracked. Others can " f"follow it by typing in `@underway_bot {username}`.\n\n" "Here's what it looks like right now:\n\n" f"TODO_FUNC_CALL\n\n" "To move forward a step, send me `/step`. To move backwards, `/unstep`." ) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=CONFIRM_MESSAGE)
def on_command_help(update, context): """ Provides the user with information about the bot. """ HELP_COMMAND_TEXT = ( "To use inwine qwueries,pwease use the fowwowing format:" # noqa "\n`@cateify_bot your message text here`" "\nthen sewect your option fwom the dwopdown menu!! o3o;;" "\n\nYou can also just pwivatewy message me, or repwy to me in gwoup chats," # noqa "\nand Ill cateify your messages!!!₍˄·͈༝·͈˄₎ ") username, user_id, message_text = get_meta_from_update(update) bot = context.bot bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=HELP_COMMAND_TEXT)
def on_command_start(update, context): """ Welcomes the user to Cateify bot! """ WELCOME_STICKER_ID = "CAADAQADBQADw8wxE34vqjVrXNMoAg" WELCOME_MESSAGE_TEXT = ("Hewwo!! (=ↀωↀ=)✧ ;;" "\nWelcome to Jinhai\'s Cateify Bot" "\n\nFor more info, try: /help") username, user_id, message_text = get_meta_from_update(update) bot = context.bot bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendSticker(chat_id=user_id, sticker=WELCOME_STICKER_ID, disable_notification=True) bot.sendMessage(chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=WELCOME_MESSAGE_TEXT)
def on_command_debug(bot, update): username, user_id, message_text = get_meta_from_update(update) env = Environment(loader=FileSystemLoader(join(getcwd(), 'templates'))) bot.send_chat_action(user_id, ChatAction.TYPING) bot.sendMessage( chat_id=user_id, parse_mode=ParseMode.MARKDOWN, text=env.get_template('response_template.j2').render({ 'username': '******', 'status': 'is *in transit*', 'time_notes': 'ETA 11:30 PM PT', 'completion_percent': 75, 'steps': [ { 'completed': True, 'description': 'Gym stuff' }, { 'completed': True, 'description': 'I gotta do a quick shower, and also test how this thing handles really long lines!' }, { 'completed': True, 'description': 'Gonna MAKE SOME FISH. Gonna add BONITO FLAKES AND CAROT ✨' }, { 'completed': False, 'description': 'Gonna do 2.5 relaxes.' }, ] }))
def _log_wrapper(update, context): username, user_id, *_ = get_meta_from_update(update) # Don't log query for privacy log.debug(f'Cateifying text from user {username} ({user_id})') return func(update, context)