Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. @bot.callback_query_handler(func=lambda call: call.data.split('_')[0] == 'category')
  2. def show_product(call)
  3.         ....
  4.         some code
  5.         ....
  6.         bot.send_photo(call.message.chat.id, product.img.read(), caption=f'Вы вибрали продукт {product.title}\n\n'
  7.                                                                          f'Описание: \n'
  8.                                                                          f'{product.description} \n\n'
  9.                                                                          f'Цена: <b>{product.price}</b>',
  10.                                                                          reply_markup=keyboard,
  11.                                                                          parse_mode='HTML')
  12.  
  13. @bot.callback_query_handler(func=lambda call: call.data.split('_')[0] == 'back')
  14. def go_back(call):
  15.  
  16.     try:
  17.         ...
  18.         some awesome code
  19.         ...
  20.  
  21.         bot.edit_message_text(...)
  22.  
  23.     expect teleport.apihelper.ApiExeption:
  24.  
  25.         bot.delete_message(...)
  26.  
  27. @bot.callback_query_handler(func=lambda call: call.data.split('_')[0] == 'back')
  28. def buy_product(call):
  29.  
  30.     ...
  31.     some useful code
  32.     ...
  33.  
  34.     db.Cart.objects(user=user).add_product(product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement