Esempio n. 1
0
def amount_dec(query):
    bot.answer_callback_query(query.id)

    user_id = str(query.from_user.id)
    chat_id = query.message.chat.id
    item = query.data.split('_')[1]

    utils.remove_amount(user_id, item)
    if not utils.item_amount(user_id, item):
        utils.del_from_basket(user_id, item)
        if 'b<-' in query.data:
            bot.delete_message(chat_id, query.message.message_id)
            bot.send_message(chat_id, config.empty_basket)
        else:
            bot.edit_message_reply_markup(chat_id,
                                          query.message.message_id,
                                          reply_markup=amount_keyboard(
                                              user_id, item))
    elif 'b<-' in query.data:
        bot.edit_message_reply_markup(chat_id,
                                      query.message.message_id,
                                      reply_markup=amount_keyboard(
                                          user_id, item, basket=True))
    else:
        bot.edit_message_reply_markup(chat_id,
                                      query.message.message_id,
                                      reply_markup=amount_keyboard(
                                          user_id, item))
Esempio n. 2
0
def clear_basket(message):
    user_id = message.from_user.id
    user_basket = utils.get_basket(user_id)

    for item in user_basket:
        utils.del_from_basket(user_id, item)

    bot.send_message(message.chat.id, 'Корзина пуста!', menu_keyboard)
Esempio n. 3
0
def clear_basket(message):
    user_id = message.from_user.id
    user_basket = utils.get_basket(user_id)

    for item in user_basket:
        utils.del_from_basket(user_id, item)

    bot.send_message(message.chat.id, config.empty_basket)
Esempio n. 4
0
def got_payment(message):
    print('Пользователь', message.from_user.id, 'оформил заказ')
    for item in utils.get_basket(str(message.from_user.id)):
        utils.del_from_basket(str(message.from_user.id), item)
    bot.send_message(chat_id=message.chat.id,
                     text=config.successful_payment.format(
                         message.successful_payment.total_amount / 100,
                         message.successful_payment.currency),
                     parse_mode='Markdown',
                     reply_markup=main_menu_keyboard)
Esempio n. 5
0
def remove(query):
    bot.answer_callback_query(callback_query_id=query.id)

    utils.del_from_basket(str(query.from_user.id), query.data[7:])
    bot.delete_message(chat_id=query.from_user.id,
                       message_id=query.message.message_id)
    print(utils.get_basket(str(query.from_user.id)))
    if not utils.get_basket(str(query.from_user.id)):
        bot.send_message(chat_id=query.message.chat.id,
                         text=config.empty_basket)
Esempio n. 6
0
def more(query):
    bot.answer_callback_query(query.id)
    item = query.data[:-3]
    user_id = query.from_user.id

    try:
        utils.del_from_basket(user_id, item)
        bot.delete_message(query.message.chat.id, query.message.message_id)
    except:
        bot.send_message(query.message.chat.id, 'Вас давно не было!')