mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2026-04-19 16:15:47 +00:00
✨ 初步实现:关键词筛选后排行 #20
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user