初步实现:关键词筛选后排行 #20

This commit is contained in:
XuChenXu
2024-11-02 14:15:24 +08:00
parent a753305282
commit d42140cc95
2 changed files with 24 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ import httpx
import asyncio
import unicodedata
from typing import Dict, List
from typing import Dict, List, Optional
from sqlalchemy import or_, select
from sqlalchemy.sql import ColumnElement
@@ -77,7 +77,7 @@ async def persist_id2group_id(ids: List[str]) -> List[str]:
return [i.id2 for i in records]
def msg_counter(msg_list: List[MessageRecord]) -> Dict[str, int]:
def msg_counter(msg_list: List[MessageRecord],keyword:Optional[str]) -> Dict[str, int]:
"""### 计算每个人的消息量
Args:
@@ -92,6 +92,9 @@ def msg_counter(msg_list: List[MessageRecord]) -> Dict[str, int]:
logger.info("wow , there are {} msgs to count !!!".format(msg_len))
for i in msg_list:
if keyword:
if keyword not in i.plain_text:
continue
try:
lst[str(i.session_persist_id)] += 1
except KeyError: