This commit is contained in:
Kseninia Mikhaylova 2024-05-07 14:03:51 +03:00
parent 8dff524a92
commit bf8d1f86de
1 changed files with 8 additions and 2 deletions

View File

@ -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: