send tg
This commit is contained in:
parent
8dff524a92
commit
bf8d1f86de
10
app/main.py
10
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:
|
||||
|
|
Loading…
Reference in New Issue