Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- import random
- bot = telebot.TeleBot("TOKEN")
- # greetings = ["cześć", "siema", "cze", "witaj", "serwus", "dzien dobry"]
- answer_pool = ["Rock", "Paper", "Scissors"]
- @bot.message_handler(commands=['game'])
- def game_reply(message):
- # bot.send_message(message.chat.id, "GRAMYYY")
- # bot.send_animation(message.chat.id, "https://i0.wp.com/www.printmag.com/wp-content/uploads/2021/02/4cbe8d_f1ed2800a49649848102c68fc5a66e53mv2.gif?fit=476%2C280&ssl=1")
- markup = types.InlineKeyboardMarkup()
- itembtn1 = types.InlineKeyboardButton(text='Rock', callback_data='Rock')
- itembtn2 = types.InlineKeyboardButton(text='Paper', callback_data='Paper')
- itembtn3 = types.InlineKeyboardButton(text='Scissors', callback_data='Scissors')
- markup.add(itembtn1, itembtn2, itembtn3)
- bot.send_message(message.chat.id, "Select an answer:", reply_markup=markup)
- @bot.callback_query_handler(func=lambda call: True)
- def answering(call):
- BOT = random.randint(0,2)
- MY = 0
- bot_answer = answer_pool[BOT]
- # CO WYBRAŁEM
- if call.data == "Rock":
- bot.send_message(call.message.chat.id, "You choose: Rock")
- MY = 0
- elif call.data == "Paper":
- bot.send_message(call.message.chat.id, "You choose: Paper")
- MY = 1
- else:
- MY = 2
- bot.send_message(call.message.chat.id, "You choose: Scissors")
- # CO WYBRAŁ BOT
- bot.send_message(call.message.chat.id, "My move: " + bot_answer)
- # KTO WYGRAŁ
- WIN_LOOSE_DRAW = MY - BOT
- if WIN_LOOSE_DRAW == 0:
- bot.send_message(call.message.chat.id, "DRAW")
- elif WIN_LOOSE_DRAW == -1 or WIN_LOOSE_DRAW == 2:
- bot.send_message(call.message.chat.id, "YOU LOOSE")
- elif WIN_LOOSE_DRAW == 1 or WIN_LOOSE_DRAW == -2:
- bot.send_message(call.message.chat.id, "YOU WIN")
- # @bot.message_handler(func=lambda message: True)
- # def greeting(message):
- # if(message.text in greetings):
- # bot.reply_to(message, "Hello Human")
- # else:
- # bot.reply_to(message, message.text + " co ty do mnie rozmawiasz")
- # @bot.message_handler(content_types=['photo'])
- # def photo_callback(message):
- # bot.reply_to(message, "Nice pic! Send me more!!!")
- bot.infinity_polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement