From 3f8e0acaba18d1e30a256270405dc96191432671 Mon Sep 17 00:00:00 2001 From: "serafim.urukov" Date: Sat, 24 Jul 2021 12:25:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20=D1=81=20=D0=B2?= =?UTF-8?q?=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=D0=BC=20=D0=B4=D0=B2=D1=83=D1=85=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpreadsheetsService/app.py | 7 +++++++ TelegramBot/bot.py | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) 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