Ejemplo n.º 1
0
def handle_start_cmd(bot, update) -> int:
    chat_id = update.message.chat_id
    bot.send_message(
        chat_id=chat_id,
        text='Choose one of the following options or enter your request',
        reply_markup=create_main_reply_markup())
    return MenuEntry.START_MENU.value
def handle_detailed_mode_cmd(bot, update) -> int:
    db.session.query(User).filter_by(
        telegram_id=update.message.from_user.id).update({'simple_mode': False})
    db.session.commit()
    bot.send_message(chat_id=update.message.chat_id,
                     text='Switched to detailed mode',
                     reply_markup=create_main_reply_markup())
    return MenuEntry.START_MENU.value
Ejemplo n.º 3
0
def handle_unknown_message(bot, update) -> int:
    chat_id = update.message.chat_id
    bot.send_message(text='I don\'t know what to say. '
                     'Anyway catch the sticker 😉',
                     chat_id=chat_id,
                     reply_markup=create_main_reply_markup())
    sticker_file_id = 'CAADAgADigIAAvilfQKsvnIfLjgE8QI'
    bot.send_sticker(chat_id, sticker_file_id)
    return MenuEntry.START_MENU.value
def handle_wolfram_request(bot, update, prefix: str = '') -> int:
    chat_id = update.message.chat_id
    reply_markup = create_main_reply_markup()
    request = f'{prefix} {update.message.text}'.strip()
    current_user = db.session.query(User).filter_by(
        telegram_id=update.message.from_user.id).first()
    if current_user.simple_mode:
        return handle_simple_wolfram_request(bot, chat_id, request,
                                             reply_markup)
    return handle_detailed_wolfram_request(bot, chat_id, request, reply_markup)
Ejemplo n.º 5
0
def handle_examples_cmd(bot, update) -> int:
    chat_id = update.message.chat_id
    reply_markup = create_main_reply_markup()
    bot.send_message(chat_id=chat_id,
                     text='Solve equation: solve x^2 + 2x + 1 = 0\n'
                     'Maximize function: maximize x(1-x)e^x\n'
                     'Minimize function: minimize x^2 + 2x + 1\n'
                     'Compute an indefinite integral: integrate sin(x)\n'
                     'Compute an definite integral: integrate sin(x) '
                     'from 0 to pi\n'
                     'Calculate a derivative: derivative of sin(x)\n'
                     'Solve differential equation: y\'\' + y = 0\n'
                     'Build a function graph: plot e^x\n'
                     'To learn more examples visit '
                     '[this site](http://www.wolframalpha.com/examples/math/)',
                     parse_mode='Markdown',
                     disable_web_page_preview=True,
                     reply_markup=reply_markup)
    return MenuEntry.START_MENU.value