diff --git a/app/task.py b/app/task.py index a53a51e..24ee86a 100644 --- a/app/task.py +++ b/app/task.py @@ -8,7 +8,13 @@ from celery import Task from app.utils.utils import * from app.utils.yd_utils import get_token, get_activity_info -from app.utils.feishu import create_doc, get_doc_block, create_doc_block, get_messages, send_groud_message +from app.utils.feishu import ( + create_doc, + get_doc_block, + create_doc_block, + get_messages, + send_groud_message, +) from app.utils.utils import update_record, add_record from app.utils.yd_utils import new_blank_robot, new_blank_activity @@ -31,8 +37,11 @@ def parse_history_message(data): print(f"raw msg: {item}") print("***************") + try: + item_content = json.loads(item.get("body").get("content")) + except Exception as e: + continue - item_content = json.loads(item.get("body").get("content")) print(item_content) print("***************") diff --git a/app/test/test_parse_message.py b/app/test/test_parse_message.py index fbf4346..c0b848b 100644 --- a/app/test/test_parse_message.py +++ b/app/test/test_parse_message.py @@ -3,233 +3,141 @@ import itertools data = { "has_more": False, + "page_token": "", "items": [ { - "body": { - "content": '{"title":"🚩新增在线RPA流转问题:官方应用,TikTok关键词抓取红人信息,运行一段时间报错,未监听到响应数据","elements":[[{"tag":"text","text":"1、客户端版本:5.19.22\\n2、问题描述:官方应用,TikTok关键词抓取红人信息,运行一段时间报错,未监听到响应数据\\n3、公司名称:安徽米莱诺贸易有限公司\\n4、复现频率:必现\\n5、截图或录屏:"}],[{"tag":"img","image_key":"img_v3_02d9_a1932223-b776-43b9-a9c7-dba4ad27cdcg"}],[{"tag":"text","text":"6、优先级和紧急原因:紧急,客户说上次反馈过,但是工单总表里并没有记录\\n7、排查情况:无\\n8、日志文件:请"},{"tag":"at","user_id":"@_user_1","user_name":"星云"},{"tag":"text","text":"继续补充日志等文件\\nps:直接拖动文件至话题内"}],[{"tag":"hr"}],[{"tag":"text","text":"来自 "},{"tag":"a","href":"https://ying-dao.feishu.cn/base/KMoSbOwZXazlCVslCzgcpKU1nBh?ccm_open_type=im_card_automation_link","text":"在线RPA_流转产研"}]]}' - }, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722330254498", - "deleted": False, - "mentions": [ - { - "id": "ou_57ab29dded5d4cd4fe9d8e472fdd8b25", - "id_type": "open_id", - "key": "@_user_1", - "name": "星云", - "tenant_key": "11cf67642edc175f", - } - ], - "message_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "msg_type": "interactive", - "sender": { - "id": "cli_a6d7c68aeeb9900d", - "id_type": "app_id", - "sender_type": "app", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722330254498", - "updated": False, - }, - { - "body": {"content": '{"text":"@_user_1 记录问题"}'}, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722330268207", - "deleted": False, - "mentions": [ - { - "id": "ou_76322e169bb6bb8f6e1c8b6631b54d72", - "id_type": "open_id", - "key": "@_user_1", - "name": "官方应用指令", - "tenant_key": "11cf67642edc175f", - } - ], - "message_id": "om_9e914b1e2e0b6194b441c1de1642126c", - "msg_type": "text", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "sender": { - "id": "ou_57ab29dded5d4cd4fe9d8e472fdd8b25", - "id_type": "open_id", - "sender_type": "user", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722330268207", - "updated": False, - }, - { - "body": { - "content": '{"text":"问题已经记录到多维表格, 及时更新工单状态💕"}' - }, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722330273266", - "deleted": False, - "message_id": "om_718be013df88017356dec6811d34f5c0", - "msg_type": "text", - "parent_id": "om_9e914b1e2e0b6194b441c1de1642126c", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "sender": { - "id": "cli_a5110cd1da70900b", - "id_type": "app_id", - "sender_type": "app", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722330273266", - "updated": False, - }, - { - "body": {"content": '{"text":"@_user_1"}'}, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414346354", - "deleted": False, - "mentions": [ - { - "id": "ou_776e7cb5f800181ce0d4eb4a66c9e9c8", - "id_type": "open_id", - "key": "@_user_1", - "name": "驿站", - "tenant_key": "11cf67642edc175f", - } - ], - "message_id": "om_1b78f3fda48541bddbd0de9e7e38fa72", - "msg_type": "text", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "sender": { - "id": "ou_d542891996bf1961f9a94563e6bd4d49", - "id_type": "open_id", - "sender_type": "user", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414346354", - "updated": False, - }, - { - "body": {"content": '{"text":"@_user_1 远程一下"}'}, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414368335", - "deleted": False, - "mentions": [ - { - "id": "ou_57ab29dded5d4cd4fe9d8e472fdd8b25", - "id_type": "open_id", - "key": "@_user_1", - "name": "星云", - "tenant_key": "11cf67642edc175f", - } - ], - "message_id": "om_2b981b6611ac9216670d2bf006924d3e", - "msg_type": "text", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "sender": { - "id": "ou_776e7cb5f800181ce0d4eb4a66c9e9c8", - "id_type": "open_id", - "sender_type": "user", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414368335", - "updated": False, - }, - { - "body": { - "content": '{"text":"好的,客户说要运行十分钟左右才会出现这个错误"}' - }, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414475340", - "deleted": False, - "message_id": "om_3a6676adc1516bfa075076690327065f", - "msg_type": "text", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "sender": { - "id": "ou_57ab29dded5d4cd4fe9d8e472fdd8b25", - "id_type": "open_id", - "sender_type": "user", - "tenant_key": "11cf67642edc175f", - }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414475340", - "updated": False, - }, - { - "body": { - "content": '{"title":"","content":[[{"tag":"img","image_key":"img_v3_02da_e7d68292-eab6-422d-9037-370eaf8cae0g","width":770,"height":520}]]}' - }, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414504441", - "deleted": False, - "message_id": "om_5a9e6ae5901e1c6154b7172a2fc47e42", + "message_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", "msg_type": "post", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", + "create_time": "1733392340398", + "update_time": "1733392340398", + "deleted": False, + "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", "sender": { - "id": "ou_57ab29dded5d4cd4fe9d8e472fdd8b25", + "id": "ou_78dea0fe3f208b9ca4fdc6d72f3fdc21", "id_type": "open_id", "sender_type": "user", "tenant_key": "11cf67642edc175f", }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414504441", - "updated": False, + "body": { + "content": '{"title":"","content":[[{"tag":"text","text":"【小红书视频批量上传】上传部分22行的元素丢了,看样子上传页面有一点变化","style":[]}],[{"tag":"img","image_key":"img_v3_02h9_e54f66b7-9f02-4c59-a5e1-2a72266ff44g","width":1495,"height":983}]]}' + }, }, { - "body": {"content": '{"text":"@_user_1 记录问题"}'}, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414646073", + "message_id": "om_126def20d32d737a5e2aa70cd49c81dc", + "root_id": "om_885b87c75f7ea6507e264e4327bed94d", + "parent_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", + "msg_type": "text", + "create_time": "1733392353985", + "update_time": "1733392373315", + "deleted": True, + "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", + "sender": { + "id": "ou_78dea0fe3f208b9ca4fdc6d72f3fdc21", + "id_type": "open_id", + "sender_type": "user", + "tenant_key": "11cf67642edc175f", + }, + "body": {"content": "This message was recalled"}, + }, + { + "message_id": "om_92a9f1eda1ace09595264aafce612d27", + "root_id": "om_885b87c75f7ea6507e264e4327bed94d", + "parent_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", + "msg_type": "text", + "create_time": "1733392386484", + "update_time": "1733392386484", "deleted": False, + "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", + "sender": { + "id": "ou_b67dbdb19cf6e143cc05db7ab42dbbff", + "id_type": "open_id", + "sender_type": "user", + "tenant_key": "11cf67642edc175f", + }, + "body": {"content": '{"text":"@_user_1 记录问题"}'}, "mentions": [ { + "key": "@_user_1", "id": "ou_76322e169bb6bb8f6e1c8b6631b54d72", "id_type": "open_id", - "key": "@_user_1", "name": "官方应用指令", "tenant_key": "11cf67642edc175f", } ], - "message_id": "om_d5b9f34ce296f06ca30d3c4728c6cd83", + }, + { + "message_id": "om_e61af96d00a9b8885b9bf9cc6a45357e", + "root_id": "om_885b87c75f7ea6507e264e4327bed94d", + "parent_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", "msg_type": "text", - "parent_id": "om_45c9b5c6900534ffe59b146c5104c70f", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", + "create_time": "1733392402690", + "update_time": "1733392402690", + "deleted": False, + "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", "sender": { - "id": "ou_d542891996bf1961f9a94563e6bd4d49", + "id": "ou_78dea0fe3f208b9ca4fdc6d72f3fdc21", "id_type": "open_id", "sender_type": "user", "tenant_key": "11cf67642edc175f", }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414646073", - "updated": False, + "body": {"content": '{"text":"让我来试试[看]"}'}, }, { - "body": { - "content": '{"text":"问题已经记录到多维表格, 及时更新工单状态💕"}' - }, - "chat_id": "oc_483b96fe46b2523126d0407808088e4a", - "create_time": "1722414652433", - "deleted": False, - "message_id": "om_bf8f3d909dbe536168e5ee12bccd5f18", + "message_id": "om_6f57da0ecde182abdbc1d81971bdc9d2", + "root_id": "om_885b87c75f7ea6507e264e4327bed94d", + "parent_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", "msg_type": "text", - "parent_id": "om_d5b9f34ce296f06ca30d3c4728c6cd83", - "root_id": "om_45c9b5c6900534ffe59b146c5104c70f", + "create_time": "1733392637857", + "update_time": "1733392637857", + "deleted": False, + "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", "sender": { - "id": "cli_a5110cd1da70900b", - "id_type": "app_id", - "sender_type": "app", + "id": "ou_78dea0fe3f208b9ca4fdc6d72f3fdc21", + "id_type": "open_id", + "sender_type": "user", "tenant_key": "11cf67642edc175f", }, - "thread_id": "omt_15cd24470f69575f", - "update_time": "1722414652433", + "body": {"content": '{"text":"机器人怎么回事,没生效吗"}'}, + }, + { + "message_id": "om_059402a754f659afd2b229ef5306329c", + "root_id": "om_885b87c75f7ea6507e264e4327bed94d", + "parent_id": "om_885b87c75f7ea6507e264e4327bed94d", + "thread_id": "omt_1434ff1d6b481758", + "msg_type": "text", + "create_time": "1733392687005", + "update_time": "1733392687005", + "deleted": False, "updated": False, + "chat_id": "oc_44af63f29196dd5792e82ccfe65ce695", + "sender": { + "id": "ou_b67dbdb19cf6e143cc05db7ab42dbbff", + "id_type": "open_id", + "sender_type": "user", + "tenant_key": "11cf67642edc175f", + }, + "body": {"content": '{"text":"@_user_1 记录问题"}'}, + "mentions": [ + { + "key": "@_user_1", + "id": "ou_76322e169bb6bb8f6e1c8b6631b54d72", + "id_type": "open_id", + "name": "官方应用指令", + "tenant_key": "11cf67642edc175f", + } + ], }, ], - "page_token": "", } @@ -252,7 +160,11 @@ def parse_history_message(data): print("***************") - item_content = json.loads(item.get("body").get("content")) + try: + item_content = json.loads(item.get("body").get("content")) + except Exception as e: + continue + print(item_content) print("***************")