test escape

This commit is contained in:
Kseninia Mikhaylova 2024-06-18 09:13:12 +03:00
parent 831cacbf37
commit 0cfdce0d4a
1 changed files with 14 additions and 4 deletions

View File

@ -55,13 +55,23 @@ async def tg_intgr_get(request: Request):
)
data = requests.get(get_comment_hook)
data_json = data.json()
comment = ' '.join(re.sub(r"((\[)(.*?)(]))", "", data_json["result"]["POST_MESSAGE"]).split(' ')[:100])
comment = f"\nhttps://crm.svs-tech.pro/company/personal/user/{bx_id}/tasks/task/view/{task_id}/"
comment += " ".join(
re.sub(
r"((\[)(.*?)(]))",
"",
re.escape(data_json["result"]["POST_MESSAGE"].split(" ")[:100]),
)
)
comment += f'\nот {data_json["result"]["AUTHOR_NAME"]}'
comment += f'\nhttps://crm.svs-tech.pro/company/personal/user/{bx_id}/tasks/task/view/{task_id}/'
mentions = re.findall(rf"\[USER=({bx_id})\]", data_json["result"]["POST_MESSAGE"])
mentions = re.findall(
rf"\[USER=({bx_id})\]", data_json["result"]["POST_MESSAGE"]
)
for _ in mentions:
logger.info("https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={tg_id}&text={comment}")
logger.info(
"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={tg_id}&text={comment}"
)
requests.get(
f"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={tg_id}&text={comment}"
)