|
@@ -7,7 +7,7 @@ import sys
|
|
import os
|
|
import os
|
|
sys.path.append(os.curdir)
|
|
sys.path.append(os.curdir)
|
|
import configs
|
|
import configs
|
|
-from message import MessageChannel, Message
|
|
|
|
|
|
+from message import MessageChannel, Message, MessageType
|
|
from message_queue_backend import AliyunRocketMQQueueBackend
|
|
from message_queue_backend import AliyunRocketMQQueueBackend
|
|
from user_manager import MySQLUserRelationManager
|
|
from user_manager import MySQLUserRelationManager
|
|
|
|
|
|
@@ -34,6 +34,11 @@ def main():
|
|
has_consumer=False, has_producer=True
|
|
has_consumer=False, has_producer=True
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ message_type_map = {
|
|
|
|
+ 'MessageType.TEXT': MessageType.TEXT,
|
|
|
|
+ 'MessageType.VOICE': MessageType.VOICE,
|
|
|
|
+ }
|
|
|
|
+
|
|
"""
|
|
"""
|
|
log格式
|
|
log格式
|
|
2025-05-02 07:17:15,869 - agent _send_response[200] - WARNING - staff[1688857241615085] user[7881299501048462]: response[MessageType.TEXT] 早上好呀!感谢您的祝福~您这发送祝福信息的爱好真不错,您一般都喜欢给哪些人发祝福呀?
|
|
2025-05-02 07:17:15,869 - agent _send_response[200] - WARNING - staff[1688857241615085] user[7881299501048462]: response[MessageType.TEXT] 早上好呀!感谢您的祝福~您这发送祝福信息的爱好真不错,您一般都喜欢给哪些人发祝福呀?
|
|
@@ -52,13 +57,13 @@ def main():
|
|
log_name = '/var/log/agent_service/service.log'
|
|
log_name = '/var/log/agent_service/service.log'
|
|
processed_users = set()
|
|
processed_users = set()
|
|
target_tags = {"04W4-AA-1", "04W4-AA-2", "04W4-AA-3", "04W4-AA-4"}
|
|
target_tags = {"04W4-AA-1", "04W4-AA-2", "04W4-AA-3", "04W4-AA-4"}
|
|
- cutoff_time = datetime.strptime("2025-05-07 07:00:00", "%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
+ cutoff_time = datetime.strptime("2025-05-07 07:35:00", "%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
with open(log_name, "r", encoding="utf-8") as log_file:
|
|
with open(log_name, "r", encoding="utf-8") as log_file:
|
|
logs = log_file.readlines()[::-1] # Reverse the logs for backward processing
|
|
logs = log_file.readlines()[::-1] # Reverse the logs for backward processing
|
|
|
|
|
|
for i, log in enumerate(logs):
|
|
for i, log in enumerate(logs):
|
|
- if "response[" in log:
|
|
|
|
|
|
+ if ": response[" in log:
|
|
match = re.search(r"staff\[(\d+)\] user\[(\d+)\]", log)
|
|
match = re.search(r"staff\[(\d+)\] user\[(\d+)\]", log)
|
|
if not match:
|
|
if not match:
|
|
continue
|
|
continue
|
|
@@ -76,12 +81,13 @@ def main():
|
|
for prev_log in logs[i + 1:]:
|
|
for prev_log in logs[i + 1:]:
|
|
if f"staff[{staff_id}] user[{user_id}]: response[" in prev_log:
|
|
if f"staff[{staff_id}] user[{user_id}]: response[" in prev_log:
|
|
response_match = re.search(
|
|
response_match = re.search(
|
|
- r"response\[(.*?)\] (.*)", prev_log
|
|
|
|
|
|
+ r": response\[(.*?)\] (.*)", prev_log
|
|
)
|
|
)
|
|
if not response_match:
|
|
if not response_match:
|
|
break
|
|
break
|
|
|
|
|
|
message_type, response = response_match.groups()
|
|
message_type, response = response_match.groups()
|
|
|
|
+ message_type = message_type_map[message_type]
|
|
timestamp_match = re.search(r"(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})", prev_log)
|
|
timestamp_match = re.search(r"(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})", prev_log)
|
|
if not timestamp_match:
|
|
if not timestamp_match:
|
|
break
|
|
break
|
|
@@ -102,6 +108,9 @@ def main():
|
|
staff_id, user_id, response, int(timestamp.timestamp() * 1000))
|
|
staff_id, user_id, response, int(timestamp.timestamp() * 1000))
|
|
print(message)
|
|
print(message)
|
|
# Send the message
|
|
# Send the message
|
|
- # send_queue.produce(message)
|
|
|
|
|
|
+ send_queue.produce(message)
|
|
processed_users.add(user_id)
|
|
processed_users.add(user_id)
|
|
- break
|
|
|
|
|
|
+ break
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ main()
|