From 0cfdce0d4a3689b607ab926ef5bbfca715ba5853 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Tue, 18 Jun 2024 09:13:12 +0300 Subject: [PATCH] test escape --- app/main.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index 8c0cc50..a19ec2d 100644 --- a/app/main.py +++ b/app/main.py @@ -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}" )