Compare commits

..

No commits in common. "5b94bc0fffddffe7fca831b0228ff3e97bf0dc07" and "07f85be52786977dccd73d900587ad577f6f9428" have entirely different histories.

6 changed files with 20 additions and 41 deletions

View File

@ -19,7 +19,6 @@
"pygal",
"sqlalchemy",
"timecost",
"uninfo",
"userinfo",
"whereclause",
"xaxis",

View File

@ -54,20 +54,15 @@ nb plugin install nonebot-plugin-dialectlist
在 .env 中,可以添加以下配置项
```python
dialectlist__get_num: int = 5 # 获取人数数量
dialectlist__font: str = "SimHei" # 字体格式
dialectlist__suffix: bool = True # 是否显示后缀
dialectlist__excluded_self: bool = True # 是否排除自己
dialectlist__visualization: bool = True # 是否可视化
dialectlist__show_text_rank: bool = True # 是否显示文本排名
dialectlist__counting_cache: bool = False # 计数缓存(能够提高回复速度)
dialectlist__excluded_people: List[str] = [] # 排除的人的QQ号
dialectlist__use_user_info_cache: bool = False # 是否使用用户信息缓存
dialectlist__aggregate_transmission: bool = False # 是否聚合转发消息
dialectlist__timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
dialectlist__string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
dialectlist__template_path: str = "./template/rank_template.j2" # 模板路径
dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条消息\n" # 消息格式
dialectlist__string_format = "第{index}名:\n{nickname},{chatdatanum}条消息、\n" #消息格式
dialectlist__get_num = 10 #获取人数数量
dialectlist__visualization = True #是否可视化
# dialectlist__visualization_type = "圆环图" #可视化方案 (不再支持)
dialectlist__font = "SimHei" #字体格式
dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
dialectlist__excluded_self = True #是否排除机器人自己 QQ
dialectlist__suffix: bool = False # 是否显示后缀
dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式后缀
```
💭也可以不进行配置,这将会使插件按照默认配置运行
@ -131,9 +126,6 @@ __注意__
`/kkb 114514 1919810 ♂`
`/kkb @man -k ♂`
> [!IMPORTANT]
> 关键词支持正则表达式!
## 💪 目前支持的平台
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |

View File

@ -5,7 +5,6 @@ require("nonebot_plugin_apscheduler")
require("nonebot_plugin_htmlrender")
require("nonebot_plugin_userinfo")
require("nonebot_plugin_alconna")
require("nonebot_plugin_uninfo")
require("nonebot_plugin_cesaa")
import re
@ -34,7 +33,6 @@ from nonebot_plugin_alconna import (
)
from nonebot_plugin_chatrecorder import get_message_records
from nonebot_plugin_session import Session, SessionIdType, extract_session
from nonebot_plugin_uninfo import Uninfo
from .storage import get_cache, build_cache
from .config import Config, plugin_config
@ -95,19 +93,17 @@ b_cmd = on_alconna(
"看看B话",
Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")],
Option("-g|--group_id", Args["group_id?", str]),
Option("-k|--keyword", Args["keyword?", str]),
Option("-k|--keyword", Args["keyword?", str])
),
aliases={"kkb"},
use_cmd_start=True,
)
@b_cmd.handle()
async def handle_b_cmd(
at: Match[str | At],
at:Match[str|At],
group_id: Match[str],
keyword: Match[str],
uninfo: Uninfo,
session: Session = Depends(extract_session),
):
id = at.result
@ -117,10 +113,10 @@ async def handle_b_cmd(
gid = group_id.result
else:
gid = session.id2
if not gid:
await b_cmd.finish("请指定群号。")
if keyword.available:
keywords = keyword.result
else:
@ -137,14 +133,8 @@ async def handle_b_cmd(
)
d = msg_counter(messages, keywords)
rank = got_rank(d)
if not rank:
await b_cmd.finish(
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为0。"
)
await saa.Text(
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为{rank[0][1]}"
).send(reply=True)
await saa.Text(f"该用户在群{gid}的B话数量为{rank[0][1]}").send(reply=True)
rank_cmd = on_alconna(
@ -362,8 +352,8 @@ async def handle_rank(
msg += suffix
if not msg:
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
if plugin_config.aggregate_transmission:
await saa.AggregatedMessageFactory([msg]).finish()
await saa.AggregatedMessageFactory([msg]).finish(reply=True)
else:
await msg.finish(reply=True)

View File

@ -13,7 +13,7 @@ class ScopedConfig(BaseModel):
counting_cache: bool = False # 计数缓存(能够提高回复速度)
excluded_people: List[str] = [] # 排除的人的QQ号
use_user_info_cache: bool = False # 是否使用用户信息缓存
aggregate_transmission: bool = False # 是否聚合转发消息
aggregate_transmission:bool = False # 是否聚合转发消息
timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
string_suffix: str = "统计花费时间:{timecost}" # 消息格式后缀
template_path: str = "./template/rank_template.j2" # 模板路径

View File

@ -1,5 +1,4 @@
import os
import re
import httpx
import asyncio
import unicodedata
@ -97,8 +96,7 @@ def msg_counter(
for i in msg_list:
# logger.debug(f"processing msg {i.plain_text}")
if keyword:
match = re.search(keyword, i.plain_text)
if not match:
if keyword not in i.plain_text:
continue
try:
lst[str(i.session_persist_id)] += 1

View File

@ -1,6 +1,6 @@
[project]
name = "nonebot-plugin-dialectlist"
version = "2.6.0"
version = "2.5.1"
description = "看看你群群友有多能说"
authors = [
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},