feat: 添加回复情绪对好感度的影响,修改用户显示名字为群昵称

This commit is contained in:
tcmofashi
2025-03-02 08:24:00 +08:00
parent c24bf0cdcf
commit 97834e7a93
13 changed files with 77 additions and 14 deletions

View File

@@ -110,7 +110,11 @@ def get_cloest_chat_from_db(db, length: int, timestamp: str):
chat_record = list(db.db.messages.find({"time": {"$gt": closest_time}, "group_id": group_id}).sort('time', 1).limit(length))
for record in chat_record:
time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(record['time'])))
chat_text += f'[{time_str}] {record["user_nickname"] or "用户" + str(record["user_id"])}: {record["processed_plain_text"]}\n' # 添加发送者和时间信息
try:
displayname="[(%s)%s]%s" % (record["user_id"],record["user_nickname"],record["user_cardname"])
except:
displayname=record["user_nickname"] or "用户" + str(record["user_id"])
chat_text += f'[{time_str}] {displayname}: {record["processed_plain_text"]}\n' # 添加发送者和时间信息
return chat_text
return [] # 如果没有找到记录,返回空列表
@@ -170,6 +174,7 @@ def get_recent_group_detailed_plain_text(db, group_id: int, limit: int = 12,comb
"time": 1, # 返回时间字段
"user_id": 1, # 返回用户ID字段
"user_nickname": 1, # 返回用户昵称字段
"user_cardname": 1, #返回用户群昵称
"message_id": 1, # 返回消息ID字段
"detailed_plain_text": 1 # 返回处理后的文本字段
}