diff --git a/SpreadsheetsService/app.py b/SpreadsheetsService/app.py index 7cff96c..5cbacde 100644 --- a/SpreadsheetsService/app.py +++ b/SpreadsheetsService/app.py @@ -1,4 +1,5 @@ from flask import Flask +import time app = Flask(__name__) @@ -8,5 +9,11 @@ def hello_world(): return "Hello world!\n" +@app.route("/auth") +def auth(): + is_auth = int(time.time()) + return f"{is_auth % 2 == 0}" + + if __name__ == "__main__": app.run(debug=True, host="0.0.0.0") diff --git a/TelegramBot/bot.py b/TelegramBot/bot.py index 9044c94..0dba322 100644 --- a/TelegramBot/bot.py +++ b/TelegramBot/bot.py @@ -2,12 +2,13 @@ import logging import os import platform import time +import requests from telegram.ext import Updater from telegram.ext import CommandHandler from telegram.ext import MessageHandler, Filters -TOKEN = "1903048555:AAFK-d7prKvOvwwXo0IPzeRwJ1ZcuOT5ty8" # os.environ["TOKEN"] +TOKEN = "1903048555:AAFK-d7prKvOvwwXo0IPzeRwJ1ZcuOT5ty8" # os.environ["TOKEN"] logging.basicConfig( format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO @@ -21,18 +22,19 @@ dispatcher = updater.dispatcher # Стартовое сообщение (к команде /start) def start(update, context): + p = context.args[0] if len(context.args) > 0 else None + + data = requests.get("http://127.0.0.1:5000/auth").text + context.bot.send_message( chat_id=update.effective_chat.id, - text=f"Hello World! It's {time.time()}\n" \ - f"{platform.platform()}\n\n" + text=f"Hello World! {context.args} Authorized? {data}", ) + # Ответ на не командное сообщение (отвечает тем же сообщением) def echo(update, context): - context.bot.send_message( - chat_id=update.effective_chat.id, - text=update.message.text - ) + context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text) # ==================================================================== HANDLERS