コード例 #1
0
def start(bot, update, motlin_token, redis_conn):
    current_page = redis_conn.get_value(update.message.chat_id, 'current_page')
    show_store_menu(bot,
                    update.message.chat_id,
                    motlin_token,
                    page=current_page)
    return 'HANDLE_MENU'
コード例 #2
0
def handle_description(bot, update, motlin_token, params):
    query = update.callback_query
    chat_id = query.message.chat_id
    if query.data == 'HANDLE_MENU':
        current_page = params['redis_conn'].get_value(chat_id, 'current_page')
        show_store_menu(bot, chat_id, motlin_token, query.message.message_id,
                        current_page)
        return query.data
    elif query.data == str(chat_id):
        show_products_in_cart(bot, chat_id, motlin_token,
                              query.message.message_id)
        return 'HANDLE_CART'
    else:
        add_product_to_cart(chat_id, motlin_token, query.data, query)
        return 'HANDLE_DESCRIPTION'
コード例 #3
0
def start(bot, update, motlin_token, params):
    if motlin_lib.get_address(motlin_token, 'pizzeria', 'telegramid',
                              update.message.chat_id):
        clear_settings_and_task_queue(update.message.chat_id, params)
        bot.send_message(chat_id=update.message.chat_id,
                         text='Добро пожаловать! Ожидайте заказы на доставку!')
        return 'HANDLE_DELIVERY'
    else:
        current_page = params['redis_conn'].get_value(update.message.chat_id,
                                                      'current_page')
        show_store_menu(bot,
                        update.message.chat_id,
                        motlin_token,
                        page=current_page)
        return 'HANDLE_MENU'
コード例 #4
0
def handle_menu(bot, update, motlin_token, params):
    query = update.callback_query
    chat_id = query.message.chat_id
    if query.data == str(chat_id):
        show_products_in_cart(bot, chat_id, motlin_token,
                              query.message.message_id)
        return 'HANDLE_CART'
    elif query.data.isdecimal():
        params['redis_conn'].add_value(chat_id, 'current_page', query.data)
        show_store_menu(bot, chat_id, motlin_token, query.message.message_id,
                        query.data)
        return 'HANDLE_MENU'
    else:
        show_product_card(bot, chat_id, motlin_token, query.data,
                          query.message.message_id)
        return 'HANDLE_DESCRIPTION'
コード例 #5
0
def handle_cart(bot, update, motlin_token, redis_conn):
    query = update.callback_query
    chat_id = query.message.chat_id
    if query.data == 'HANDLE_MENU':
        current_page = redis_conn.get_value(chat_id, 'current_page')
        show_store_menu(bot, chat_id, motlin_token, query.message.message_id,
                        current_page)
        return query.data
    elif query.data == str(chat_id):
        bot.send_message(chat_id=chat_id,
                         text='Пришлите, пожалуйста, Ваш email')
        return 'WAITING_EMAIL'
    else:
        motlin_lib.delete_from_cart(motlin_token, chat_id, query.data)
        show_products_in_cart(bot, chat_id, motlin_token,
                              query.message.message_id)
        return 'HANDLE_CART'
コード例 #6
0
def handle_cart(bot, update, motlin_token, params):
    query = update.callback_query
    chat_id = query.message.chat_id
    if query.data == 'HANDLE_MENU':
        current_page = params['redis_conn'].get_value(chat_id, 'current_page')
        show_store_menu(bot, chat_id, motlin_token, query.message.message_id,
                        current_page)
        return query.data
    elif query.data == str(chat_id):
        show_customers_menu(bot, chat_id, motlin_token)
        delete_messages(bot, chat_id, query.message.message_id)
        return 'HANDLE_CUSTOMERS'
    else:
        motlin_lib.delete_from_cart(motlin_token, chat_id, query.data)
        show_products_in_cart(bot, chat_id, motlin_token,
                              query.message.message_id)
        return 'HANDLE_CART'