Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bot = telebot.TeleBot(TOKEN)
- @bot.message_handler(commands=['start'])
- def start_message(message):
- """старт бота и переход в игру"""
- print("start")
- bot.send_message(message.chat.id, 'Привеt')
- a = [10, 3]
- b = [4, 8]
- c = [5, 4]
- result = a, b, c
- result = json.dumps(result)
- bot.send_message(message.chat.id, **show_button(result))
- print('qq')
- def show_button(a):
- """переход на выбор действия"""
- print("choice user")
- markup = types.InlineKeyboardMarkup(row_width=2)
- itembtn1 = types.InlineKeyboardButton('взять карту', callback_data="1")
- itembtn2 = types.InlineKeyboardButton('достаточно', callback_data="2")
- markup.add(itembtn1, itembtn2)
- print(a, "call_button)))")
- # json.dumps(a)
- return {"text": a,
- "reply_markup": markup}
- @bot.callback_query_handler(func=lambda c: True)
- def echo_all(c):
- """отслеживание выбор юзера"""
- hand = (c.message.text)
- print(hand, type(hand))
- if int(c.data) == 1:
- # json_hand = json.dumps(hand)
- print(hand, type(hand))
- bot.send_message(chat_id=c.message.chat.id, **show_button(continue_game(hand)))
- pass
- elif int(c.data) == 2:
- pass
- print("text hz")
- print(hand, 'hand before chat')
- print(c)
- def continue_game(hand):
- hand = json.loads(hand)
- print(hand, type(hand), "hand after decoder")
- hand.append([5, 8])
- json.dumps(hand)
- print(hand, type(hand), "hand after coder")
- return {"text": hand}
- pass
- if __name__ == "__main__":
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement