mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2026-01-26 13:42:00 +00:00
Compare commits
13 Commits
V2.5.2
...
0348a5d66c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0348a5d66c | ||
|
|
aff02f2666 | ||
|
|
2f725e0808 | ||
|
|
3434a5352f | ||
|
|
0954eb4f3e | ||
|
|
5b94bc0fff | ||
|
|
e1a20922c4 | ||
|
|
5e00605dfb | ||
|
|
833cdb4a75 | ||
|
|
29b4598e5f | ||
|
|
10cc5cf278 | ||
|
|
ed167a56b5 | ||
|
|
b40c7be1f9 |
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -19,6 +19,7 @@
|
|||||||
"pygal",
|
"pygal",
|
||||||
"sqlalchemy",
|
"sqlalchemy",
|
||||||
"timecost",
|
"timecost",
|
||||||
|
"uninfo",
|
||||||
"userinfo",
|
"userinfo",
|
||||||
"whereclause",
|
"whereclause",
|
||||||
"xaxis",
|
"xaxis",
|
||||||
|
|||||||
71
README.md
71
README.md
@@ -54,15 +54,20 @@ nb plugin install nonebot-plugin-dialectlist
|
|||||||
|
|
||||||
在 .env 中,可以添加以下配置项
|
在 .env 中,可以添加以下配置项
|
||||||
```python
|
```python
|
||||||
dialectlist__string_format = "第{index}名:\n{nickname},{chatdatanum}条消息、\n" #消息格式
|
dialectlist__get_num: int = 5 # 获取人数数量
|
||||||
dialectlist__get_num = 10 #获取人数数量
|
dialectlist__font: str = "SimHei" # 字体格式
|
||||||
dialectlist__visualization = True #是否可视化
|
dialectlist__suffix: bool = True # 是否显示后缀
|
||||||
# dialectlist__visualization_type = "圆环图" #可视化方案 (不再支持)
|
dialectlist__excluded_self: bool = True # 是否排除自己
|
||||||
dialectlist__font = "SimHei" #字体格式
|
dialectlist__visualization: bool = True # 是否可视化
|
||||||
dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
|
dialectlist__show_text_rank: bool = True # 是否显示文本排名
|
||||||
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
dialectlist__counting_cache: bool = False # 计数缓存(能够提高回复速度)
|
||||||
dialectlist__suffix: bool = False # 是否显示后缀
|
dialectlist__excluded_people: List[str] = [] # 排除的人的QQ号
|
||||||
dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式后缀
|
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" # 消息格式
|
||||||
```
|
```
|
||||||
💭也可以不进行配置,这将会使插件按照默认配置运行
|
💭也可以不进行配置,这将会使插件按照默认配置运行
|
||||||
|
|
||||||
@@ -70,6 +75,8 @@ dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式
|
|||||||
|
|
||||||
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
||||||
|
|
||||||
|
> 由于插件依赖chatrecord多次引入爆炸性修改,建议在遇到问题后优先尝试降级chatrecord插件
|
||||||
|
|
||||||
## 🗨命令
|
## 🗨命令
|
||||||
__!!注意!!__
|
__!!注意!!__
|
||||||
新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
|
新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
|
||||||
@@ -126,6 +133,9 @@ __!!注意!!__
|
|||||||
`/kkb 114514 1919810 ♂`
|
`/kkb 114514 1919810 ♂`
|
||||||
`/kkb @man -k ♂`
|
`/kkb @man -k ♂`
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> 关键词支持正则表达式!
|
||||||
|
|
||||||
## 💪 目前支持的平台
|
## 💪 目前支持的平台
|
||||||
|
|
||||||
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |
|
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |
|
||||||
@@ -195,49 +205,6 @@ __!!注意!!__
|
|||||||
|
|
||||||
待补充。.....
|
待补充。.....
|
||||||
|
|
||||||
## 📖版本日志
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>点我展开</summary>
|
|
||||||
|
|
||||||
### V1.0
|
|
||||||
|
|
||||||
- 看看群里群友能有多话痨
|
|
||||||
|
|
||||||
### V1.1
|
|
||||||
|
|
||||||
- 支持频道咯!(*^_^*)
|
|
||||||
|
|
||||||
### V1.2
|
|
||||||
|
|
||||||
- 排行榜可视化
|
|
||||||
|
|
||||||
### V1.3
|
|
||||||
|
|
||||||
- 添加了一些可配置项
|
|
||||||
|
|
||||||
### V1.4
|
|
||||||
|
|
||||||
- 适配新版本的 chatrecorder, 暂时停止频道支持
|
|
||||||
|
|
||||||
### V2.0
|
|
||||||
|
|
||||||
- 理论支持全平台!暂停图片支持。
|
|
||||||
|
|
||||||
|
|
||||||
### V2.1
|
|
||||||
|
|
||||||
- 恢复图片支持。
|
|
||||||
|
|
||||||
### V2.2
|
|
||||||
|
|
||||||
- 优化代码,添加一些新的可配置项。
|
|
||||||
|
|
||||||
### V2.4
|
|
||||||
|
|
||||||
- 添加一些新的可配置项。
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### 👾题外话
|
### 👾题外话
|
||||||
~~整个项目快被我写成屎山了~~
|
~~整个项目快被我写成屎山了~~
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ require("nonebot_plugin_apscheduler")
|
|||||||
require("nonebot_plugin_htmlrender")
|
require("nonebot_plugin_htmlrender")
|
||||||
require("nonebot_plugin_userinfo")
|
require("nonebot_plugin_userinfo")
|
||||||
require("nonebot_plugin_alconna")
|
require("nonebot_plugin_alconna")
|
||||||
|
require("nonebot_plugin_uninfo")
|
||||||
require("nonebot_plugin_cesaa")
|
require("nonebot_plugin_cesaa")
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@@ -33,6 +34,7 @@ from nonebot_plugin_alconna import (
|
|||||||
)
|
)
|
||||||
from nonebot_plugin_chatrecorder import get_message_records
|
from nonebot_plugin_chatrecorder import get_message_records
|
||||||
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
||||||
|
from nonebot_plugin_uninfo import Uninfo
|
||||||
|
|
||||||
from .storage import get_cache, build_cache
|
from .storage import get_cache, build_cache
|
||||||
from .config import Config, plugin_config
|
from .config import Config, plugin_config
|
||||||
@@ -93,17 +95,19 @@ b_cmd = on_alconna(
|
|||||||
"看看B话",
|
"看看B话",
|
||||||
Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")],
|
Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")],
|
||||||
Option("-g|--group_id", Args["group_id?", str]),
|
Option("-g|--group_id", Args["group_id?", str]),
|
||||||
Option("-k|--keyword", Args["keyword?", str])
|
Option("-k|--keyword", Args["keyword?", str]),
|
||||||
),
|
),
|
||||||
aliases={"kkb"},
|
aliases={"kkb"},
|
||||||
use_cmd_start=True,
|
use_cmd_start=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@b_cmd.handle()
|
@b_cmd.handle()
|
||||||
async def handle_b_cmd(
|
async def handle_b_cmd(
|
||||||
at: Match[str | At],
|
at: Match[str | At],
|
||||||
group_id: Match[str],
|
group_id: Match[str],
|
||||||
keyword: Match[str],
|
keyword: Match[str],
|
||||||
|
uninfo: Uninfo,
|
||||||
session: Session = Depends(extract_session),
|
session: Session = Depends(extract_session),
|
||||||
):
|
):
|
||||||
id = at.result
|
id = at.result
|
||||||
@@ -133,8 +137,14 @@ async def handle_b_cmd(
|
|||||||
)
|
)
|
||||||
d = msg_counter(messages, keywords)
|
d = msg_counter(messages, keywords)
|
||||||
rank = got_rank(d)
|
rank = got_rank(d)
|
||||||
|
if not rank:
|
||||||
|
await b_cmd.finish(
|
||||||
|
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为0。"
|
||||||
|
)
|
||||||
|
|
||||||
await saa.Text(f"该用户在群{gid}的B话数量为{rank[0][1]}。").send(reply=True)
|
await saa.Text(
|
||||||
|
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为{rank[0][1]}。"
|
||||||
|
).send(reply=True)
|
||||||
|
|
||||||
|
|
||||||
rank_cmd = on_alconna(
|
rank_cmd = on_alconna(
|
||||||
@@ -354,6 +364,6 @@ async def handle_rank(
|
|||||||
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
|
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
|
||||||
|
|
||||||
if plugin_config.aggregate_transmission:
|
if plugin_config.aggregate_transmission:
|
||||||
await saa.AggregatedMessageFactory([msg]).finish(reply=True)
|
await saa.AggregatedMessageFactory([msg]).finish()
|
||||||
else:
|
else:
|
||||||
await msg.finish(reply=True)
|
await msg.finish(reply=True)
|
||||||
|
|||||||
61
nonebot_plugin_dialectlist/migrations/873ad3421460_.py
Normal file
61
nonebot_plugin_dialectlist/migrations/873ad3421460_.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
迁移 ID: 873ad3421460
|
||||||
|
父迁移:
|
||||||
|
创建时间: 2025-03-29 14:30:11.910461
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision: str = "873ad3421460"
|
||||||
|
down_revision: str | Sequence[str] | None = None
|
||||||
|
branch_labels: str | Sequence[str] | None = ("nonebot_plugin_dialectlist",)
|
||||||
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(name: str = "") -> None:
|
||||||
|
if name:
|
||||||
|
return
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table(
|
||||||
|
"nonebot_plugin_dialectlist_messagecountcache",
|
||||||
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||||
|
sa.Column("time", sa.DateTime(), nullable=False),
|
||||||
|
sa.Column("session_id", sa.Integer(), nullable=False),
|
||||||
|
sa.Column("session_bnum", sa.Integer(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint(
|
||||||
|
"id", name=op.f("pk_nonebot_plugin_dialectlist_messagecountcache")
|
||||||
|
),
|
||||||
|
info={"bind_key": "nonebot_plugin_dialectlist"},
|
||||||
|
)
|
||||||
|
with op.batch_alter_table(
|
||||||
|
"nonebot_plugin_dialectlist_messagecountcache", schema=None
|
||||||
|
) as batch_op:
|
||||||
|
batch_op.create_index(
|
||||||
|
batch_op.f("ix_nonebot_plugin_dialectlist_messagecountcache_session_id"),
|
||||||
|
["session_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(name: str = "") -> None:
|
||||||
|
if name:
|
||||||
|
return
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table(
|
||||||
|
"nonebot_plugin_dialectlist_messagecountcache", schema=None
|
||||||
|
) as batch_op:
|
||||||
|
batch_op.drop_index(
|
||||||
|
batch_op.f("ix_nonebot_plugin_dialectlist_messagecountcache_session_id")
|
||||||
|
)
|
||||||
|
|
||||||
|
op.drop_table("nonebot_plugin_dialectlist_messagecountcache")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import httpx
|
import httpx
|
||||||
import asyncio
|
import asyncio
|
||||||
import unicodedata
|
import unicodedata
|
||||||
@@ -96,7 +97,8 @@ def msg_counter(
|
|||||||
for i in msg_list:
|
for i in msg_list:
|
||||||
# logger.debug(f"processing msg {i.plain_text}")
|
# logger.debug(f"processing msg {i.plain_text}")
|
||||||
if keyword:
|
if keyword:
|
||||||
if keyword not in i.plain_text:
|
match = re.search(keyword, i.plain_text)
|
||||||
|
if not match:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
lst[str(i.session_persist_id)] += 1
|
lst[str(i.session_persist_id)] += 1
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "nonebot-plugin-dialectlist"
|
name = "nonebot-plugin-dialectlist"
|
||||||
version = "2.5.1"
|
version = "2.6.2"
|
||||||
description = "看看你群群友有多能说"
|
description = "看看你群群友有多能说"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nonebot-plugin-chatrecorder>=0.6.0",
|
"nonebot-plugin-chatrecorder>=0.6.0,<0.7.0",
|
||||||
"nonebot-plugin-orm[default]",
|
"nonebot-plugin-orm[default]",
|
||||||
"nonebot-plugin-apscheduler>=0.4.0",
|
"nonebot-plugin-apscheduler>=0.4.0",
|
||||||
"nonebot-plugin-alconna>=0.50.2",
|
"nonebot-plugin-alconna>=0.50.2",
|
||||||
@@ -17,7 +17,7 @@ dependencies = [
|
|||||||
"pillow>=10.4.0",
|
"pillow>=10.4.0",
|
||||||
"nonebot-plugin-uninfo>=0.1.1",
|
"nonebot-plugin-uninfo>=0.1.1",
|
||||||
]
|
]
|
||||||
requires-python = ">=3.9,<3.13"
|
requires-python = ">=3.9,<4.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user