import requests
token = ""
URL = "https://api.telegram.org/bot" + token + "/"
def get_updates():
url = URL + "getupdates"
r = requests.get(url)
return r.json()
def get_updates_photo():
url = URL + "update"
#TODO
def get_photo():
file = get_updates_photo()
def get_message():
data = get_updates()
chat_id = data["result"][-1]["message"]["chat"]["id"]
message = data["result"][-1]["message"]["text"]
message = {"chat_id": chat_id,
"text": message}
return message
def send_message(chat_id, text="..."):
url = URL + 'sendmessage?chat_id={}&text={}'.format(chat_id, text)
requests.get(url)
def main():
answer = get_message()
chat_id = answer["chat_id"]
text = answer["text"]
if (text == "Проверить подпись"):
send_message(chat_id, "Отправьте фото")
get_photo()
else:
send_message(chat_id, "Я вас не понимаю")
if __name__ == '__main__':
main()