Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. bot = telebot.TeleBot(TOKEN)
  2.  
  3.  
  4. @bot.message_handler(commands=['start'])
  5. def start_message(message):
  6. """старт бота и переход в игру"""
  7. print("start")
  8. bot.send_message(message.chat.id, 'Привеt')
  9. a = [10, 3]
  10. b = [4, 8]
  11. c = [5, 4]
  12. result = a, b, c
  13. result = json.dumps(result)
  14. bot.send_message(message.chat.id, **show_button(result))
  15. print('qq')
  16.  
  17.  
  18. def show_button(a):
  19. """переход на выбор действия"""
  20. print("choice user")
  21. markup = types.InlineKeyboardMarkup(row_width=2)
  22. itembtn1 = types.InlineKeyboardButton('взять карту', callback_data="1")
  23. itembtn2 = types.InlineKeyboardButton('достаточно', callback_data="2")
  24. markup.add(itembtn1, itembtn2)
  25. print(a, "call_button)))")
  26. # json.dumps(a)
  27. return {"text": a,
  28. "reply_markup": markup}
  29.  
  30.  
  31. @bot.callback_query_handler(func=lambda c: True)
  32. def echo_all(c):
  33. """отслеживание выбор юзера"""
  34. hand = (c.message.text)
  35. print(hand, type(hand))
  36. if int(c.data) == 1:
  37. # json_hand = json.dumps(hand)
  38. print(hand, type(hand))
  39. bot.send_message(chat_id=c.message.chat.id, **show_button(continue_game(hand)))
  40. pass
  41. elif int(c.data) == 2:
  42. pass
  43. print("text hz")
  44. print(hand, 'hand before chat')
  45. print(c)
  46.  
  47.  
  48. def continue_game(hand):
  49. hand = json.loads(hand)
  50. print(hand, type(hand), "hand after decoder")
  51. hand.append([5, 8])
  52. json.dumps(hand)
  53. print(hand, type(hand), "hand after coder")
  54. return {"text": hand}
  55. pass
  56.  
  57.  
  58. if __name__ == "__main__":
  59. bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement