新闻更新

This commit is contained in:
2025-02-06 16:39:14 +08:00
parent 19c94364a4
commit a173bc203a
5 changed files with 11 additions and 14 deletions

View File

@@ -41,9 +41,6 @@ if __name__ == "__main__":
"### 分类1" \
"1.#标题1" \
"2.#标题2" \
"### 分类2" \
"1.#标题3" \
"2.#标题4" \
"分类之间使用--号进行分割,无内容则忽略该分组" \
"当前日期2024年12月16日 星期一" \
"1. 标题: 安徽监狱回应李铁可否在监狱踢球" \

View File

@@ -39,10 +39,10 @@ logging:
handlers: [console, info_file_handler, error_file_handler]
groups:
enable: [45317011307@chatroom,49571962306@chatroom] # 允许响应的群 roomId大概长这样2xxxxxxxxx3@chatroom
enable: [45317011307@chatroom,49571962306@chatroom,43687793133@chatroom] # 允许响应的群 roomId大概长这样2xxxxxxxxx3@chatroom
news:
receivers: [45317011307@chatroom,49571962306@chatroom] # 定时新闻接收人roomid 或者 wxid
receivers: [45317011307@chatroom,49571962306@chatroom,43687793133@chatroom] # 定时新闻接收人roomid 或者 wxid
report_reminder:
receivers: [] # 定时日报周报月报提醒roomid 或者 wxid

View File

@@ -27,7 +27,7 @@ def write_to_db():
# 遍历Redis中所有与昨天日期相关的key并写入数据库
for key in r.keys(f"*:*:{yesterday}:count"):
# print('user key' + key)
print('user key' + key)
parts = key.decode('utf-8').split(':')
group_id, wx_id, _date = parts[0], parts[1], parts[2] # _date应该是yesterday但这里为了完整性还是保留
count = int(r.hget(key, 'count')) if isinstance(r.hget(key, 'count'), bytes) else 0 # 处理可能的None或空值情况
@@ -48,11 +48,11 @@ def generate_and_send_ranking(groupId, allContacts: dict):
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
# 编写SQL查询来获取发言数量前20的用户
query = """
SELECT group_id,wx_id, COUNT(*) AS speech_count
SELECT wx_id, count AS speech_count
FROM speech_counts
WHERE DATE(date) = DATE('now', '-1 day')
AND group_id = ?
GROUP BY group_id,wx_id
GROUP BY wx_id
ORDER BY count DESC
LIMIT 20
"""
@@ -71,3 +71,6 @@ def generate_and_send_ranking(groupId, allContacts: dict):
# 这里我们没有实际“发送”排名,只是返回字符串
# 如果需要发送,可以在此添加发送逻辑
return ranking_str
if __name__ == '__main__':
write_to_db()

View File

@@ -20,4 +20,5 @@ protobuf~=5.29.1
beautifulsoup4~=4.12.3
httpx~=0.28.1
pyttsx3~=2.98
redis~=5.2.1
redis~=5.2.1
PyMySQL~=1.1.1

View File

@@ -306,11 +306,7 @@ class Robot(Job):
"### 分类1" \
"1.#标题1" \
"2.#标题2" \
"### 分类2" \
"1.#标题3" \
"2.#标题4" \
"分类之间使用--号进行分割,无内容则忽略该分组" \
+ news)
"分类之间使用--号进行分割,无内容则忽略该分组" )+ news
rsp = self.chat.get_answer(news)
for r in receivers: