import json
from enum import Enum
import requests
def send_message(token, chat_id, message):
url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}&text={message}"
response = requests.get(url)
return response.status_code == 200, response.text
class Gesture(Enum):
Paper = "✋"
Scissors = "✌️"
Stone = "👊"
@staticmethod
def list():
return list(map(lambda g: g.name, Gesture))
@staticmethod
def get_number(gesture):
if gesture == Gesture.Paper.name:
return 0
elif gesture == Gesture.Scissors.name:
return 1
elif gesture == Gesture.Stone.name:
return 2
def play_paper_scissors_stone(token, chat_id, message):
reply_markup = {
"inline_keyboard": [[
{
"text": Gesture.Paper.value,
"callback_data": Gesture.Paper.name,
},
{
"text": Gesture.Scissors.value,
"callback_data": Gesture.Scissors.name,
},
{
"text": Gesture.Stone.value,
"callback_data": Gesture.Stone.name,
},
],]
}
reply_markup = json.dumps(reply_markup)
url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}&text={message}&reply_markup={reply_markup}"
response = requests.get(url)
return response.status_code == 200, response.text
def edit_message_test(token, chat_id, message_id, message):
url = f"https://api.telegram.org/bot{token}/editMessageText?chat_id={chat_id}&message_id={message_id}&text={message}"
response = requests.get(url)
return response.status_code == 200, response.text