From bf8d1f86de96360172f475b9d105f7809f55e3ca Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Tue, 7 May 2024 14:03:51 +0300 Subject: [PATCH] send tg --- app/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index d54d35f..3db1246 100644 --- a/app/main.py +++ b/app/main.py @@ -7,6 +7,10 @@ from app.constants import * app = FastAPI() +tg = { + 38: '@aarizona' +} +TOKEN = "7102273461:AAGi8RXCEvns2ONu3RcG9Up973vcLzTdCJg" @app.get("/") def read_root(): @@ -52,8 +56,10 @@ async def tg_intgr_get(request: Request): data_json = data.json() comment = data_json["result"]["POST_MESSAGE"] - mention = re.findall(r"\[USER=(\d*)\]", comment) - logger.info(mention) + mentions = re.findall(r"\[USER=(\d*)\]", comment) + for mention in mentions: + if tg[int(mention)]: + requests.get(f'https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={tg[int(mention)]}&text={comment}') return {"status": "success"} except: