nonebot-plugin-dialectlist 1.4.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. nonebot_plugin_dialectlist-2.0.1/PKG-INFO +150 -0
  2. nonebot_plugin_dialectlist-2.0.1/README.md +129 -0
  3. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist/__init__.py +255 -0
  4. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist/config.py +29 -0
  5. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist/usage.py +9 -0
  6. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist/utils.py +441 -0
  7. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist.egg-info/PKG-INFO +150 -0
  8. {nonebot-plugin-dialectlist-1.4.0 → nonebot_plugin_dialectlist-2.0.1}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +3 -1
  9. nonebot_plugin_dialectlist-2.0.1/nonebot_plugin_dialectlist.egg-info/requires.txt +13 -0
  10. nonebot_plugin_dialectlist-2.0.1/pyproject.toml +37 -0
  11. nonebot_plugin_dialectlist-2.0.1/setup.py +3 -0
  12. nonebot-plugin-dialectlist-1.4.0/PKG-INFO +0 -12
  13. nonebot-plugin-dialectlist-1.4.0/README.md +0 -114
  14. nonebot-plugin-dialectlist-1.4.0/nonebot_plugin_dialectlist/__init__.py +0 -218
  15. nonebot-plugin-dialectlist-1.4.0/nonebot_plugin_dialectlist/config.py +0 -19
  16. nonebot-plugin-dialectlist-1.4.0/nonebot_plugin_dialectlist/function.py +0 -124
  17. nonebot-plugin-dialectlist-1.4.0/nonebot_plugin_dialectlist.egg-info/PKG-INFO +0 -12
  18. nonebot-plugin-dialectlist-1.4.0/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -5
  19. nonebot-plugin-dialectlist-1.4.0/setup.py +0 -18
  20. {nonebot-plugin-dialectlist-1.4.0 → nonebot_plugin_dialectlist-2.0.1}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
  21. {nonebot-plugin-dialectlist-1.4.0 → nonebot_plugin_dialectlist-2.0.1}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
  22. {nonebot-plugin-dialectlist-1.4.0 → nonebot_plugin_dialectlist-2.0.1}/setup.cfg +0 -0
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.1
2
+ Name: nonebot_plugin_dialectlist
3
+ Version: 2.0.1
4
+ Summary: Default template for PDM package
5
+ Author-email: Chen_Xu233 <woyerpa@outlook.com>
6
+ License: MIT
7
+ Requires-Python: <4.0,>=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: nonebot2>=2.3.1
10
+ Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
11
+ Requires-Dist: pygal>=3.0.4
12
+ Requires-Dist: requests>=2.32.3
13
+ Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
14
+ Requires-Dist: nonebot-plugin-alconna>=0.46.6
15
+ Requires-Dist: nonebot-plugin-cesaa>=0.4.0
16
+ Requires-Dist: nonebot-plugin-userinfo>=0.2.4
17
+ Provides-Extra: dev
18
+ Requires-Dist: ruff>=0.4.9; extra == "dev"
19
+ Requires-Dist: setuptools>=70.0.0; extra == "dev"
20
+ Requires-Dist: twine>=5.1.0; extra == "dev"
21
+
22
+ <div align="center">
23
+ <a href="https://v2.nonebot.dev/store"><img src="https://s2.loli.net/2022/06/16/opBDE8Swad5rU3n.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
24
+ <br>
25
+ <p><img src="https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png" width="240" alt="NoneBotPluginText"></p>
26
+ </div>
27
+
28
+ <div align="center">
29
+
30
+ # 话痨排行榜
31
+ nonebot-plugin-dialectlist
32
+
33
+ \>💬**看看群友们这些天在群里水了多少话**💬<
34
+ </div>
35
+
36
+ ## 💿安装
37
+
38
+ 通过`pip`或`nb`安装;
39
+
40
+ >**通过 pip **安装
41
+
42
+ `pip install nonebot-plugin-dialectlist`
43
+
44
+ >**通过 nb **安装
45
+
46
+ `nb plugin install nonebot-plugin-dialectlist`
47
+
48
+ ### ✅插件依赖于
49
+
50
+ 1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————储存历史的消息
51
+ 2. saa 和 定时管理 (下次写个更清晰的)
52
+
53
+ ## ⚙配置
54
+
55
+ 需要**提前配置**本插件所**依赖的插件**!
56
+
57
+ 在 .env 中,可以添加以下配置项
58
+ ```python
59
+ dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
60
+ dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
61
+ dialectlist__get_num = 10 #获取人数数量
62
+ dialectlist__visualization = True #是否可视化
63
+ dialectlist__visualization_type = '圆环图' #可视化方案
64
+ dialectlist__font = 'SimHei'#字体格式
65
+ dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
66
+ dialectlist__excluded_self = True #是否排除机器人自己 QQ
67
+ ```
68
+ 💭也可以不进行配置,这将会使插件按照默认配置运行
69
+
70
+ ### ⚠ 注意!!
71
+
72
+ 需要提前安装好 [GTK+](https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer)(仅 Windows 环境下需要安装 GTK+)
73
+
74
+ 在 Windows 以外的环境中可能不存在插件默认的字体!请自行改为系统中拥有的字体!
75
+
76
+ ## 🗨命令
77
+ __!!注意!!__
78
+ 新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
79
+ 所以下面的调用需要把群话痨改成 B 话,排行榜改成榜。
80
+ 即 群话痨 -> B 话 , 排行榜 -> 榜
81
+ 比如 今日群话痨排行榜 -> 今日 B 话榜
82
+ 以此类推。
83
+
84
+ -`/群话痨排行榜` ————看看有史以来(机器人存在以来)群友们发了多少消息!
85
+
86
+ -`/今日群话痨排行榜` ————看看今天的群友发了多少消息!
87
+
88
+ -`/昨日群话痨排行榜` ————看看昨天的群友发了多少消息!
89
+
90
+ -`/前日群话痨排行榜` ————看看前天的群友发了多少消息!
91
+
92
+ -`/本周群话痨排行榜` ————看看本周的群友发了多少消息!
93
+
94
+ -`/上周群话痨排行榜` ————看看上周的群友发了多少消息!
95
+
96
+ -`/本月群话痨排行榜` ————看看这个月的群友发了多少消息!
97
+
98
+ -`/年度群话痨排行榜` ————看看今年的群友发了多少消息!
99
+
100
+ -`/历史群话痨排行榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
101
+
102
+
103
+ ## 📖版本
104
+
105
+ ### V1.0
106
+
107
+ - 看看群里群友能有多话痨
108
+
109
+ ### V1.1
110
+
111
+ - 支持频道咯!(*^_^*)
112
+
113
+ ### V1.2
114
+
115
+ - 排行榜可视化
116
+
117
+ ### V1.3
118
+
119
+ - 添加了一些可配置项
120
+
121
+ ### V1.4
122
+
123
+ - 适配新版本的 chatrecorder, 暂时停止频道支持
124
+
125
+ ### V2.0
126
+
127
+ - 理论支持全平台!暂停图片支持。
128
+
129
+ ## 💧另外
130
+
131
+ ### 感谢
132
+
133
+ 本插件的__init__.py 中的处理函数参考了词云中的方法 ~~(其实大部分都是 Ctrl+C Ctr+V)~~
134
+
135
+ [nonebot-plugin-wordcloud](https://github.com/he0119/nonebot-plugin-wordcloud)
136
+
137
+ ## TODO
138
+
139
+ - [x] 适配全平台
140
+
141
+ - [ ] 私聊的查询(超级用户可以任意查询群聊的信息)
142
+
143
+ - [ ] 关键词查询
144
+
145
+ - [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
146
+
147
+ 待补充。.....
148
+
149
+ ## 题外话
150
+ ~~整个项目快被我写成屎山了~~
@@ -0,0 +1,129 @@
1
+ <div align="center">
2
+ <a href="https://v2.nonebot.dev/store"><img src="https://s2.loli.net/2022/06/16/opBDE8Swad5rU3n.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
3
+ <br>
4
+ <p><img src="https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png" width="240" alt="NoneBotPluginText"></p>
5
+ </div>
6
+
7
+ <div align="center">
8
+
9
+ # 话痨排行榜
10
+ nonebot-plugin-dialectlist
11
+
12
+ \>💬**看看群友们这些天在群里水了多少话**💬<
13
+ </div>
14
+
15
+ ## 💿安装
16
+
17
+ 通过`pip`或`nb`安装;
18
+
19
+ >**通过 pip **安装
20
+
21
+ `pip install nonebot-plugin-dialectlist`
22
+
23
+ >**通过 nb **安装
24
+
25
+ `nb plugin install nonebot-plugin-dialectlist`
26
+
27
+ ### ✅插件依赖于
28
+
29
+ 1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————储存历史的消息
30
+ 2. saa 和 定时管理 (下次写个更清晰的)
31
+
32
+ ## ⚙配置
33
+
34
+ 需要**提前配置**本插件所**依赖的插件**!
35
+
36
+ 在 .env 中,可以添加以下配置项
37
+ ```python
38
+ dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
39
+ dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
40
+ dialectlist__get_num = 10 #获取人数数量
41
+ dialectlist__visualization = True #是否可视化
42
+ dialectlist__visualization_type = '圆环图' #可视化方案
43
+ dialectlist__font = 'SimHei'#字体格式
44
+ dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
45
+ dialectlist__excluded_self = True #是否排除机器人自己 QQ
46
+ ```
47
+ 💭也可以不进行配置,这将会使插件按照默认配置运行
48
+
49
+ ### ⚠ 注意!!
50
+
51
+ 需要提前安装好 [GTK+](https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer)(仅 Windows 环境下需要安装 GTK+)
52
+
53
+ 在 Windows 以外的环境中可能不存在插件默认的字体!请自行改为系统中拥有的字体!
54
+
55
+ ## 🗨命令
56
+ __!!注意!!__
57
+ 新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
58
+ 所以下面的调用需要把群话痨改成 B 话,排行榜改成榜。
59
+ 即 群话痨 -> B 话 , 排行榜 -> 榜
60
+ 比如 今日群话痨排行榜 -> 今日 B 话榜
61
+ 以此类推。
62
+
63
+ -`/群话痨排行榜` ————看看有史以来(机器人存在以来)群友们发了多少消息!
64
+
65
+ -`/今日群话痨排行榜` ————看看今天的群友发了多少消息!
66
+
67
+ -`/昨日群话痨排行榜` ————看看昨天的群友发了多少消息!
68
+
69
+ -`/前日群话痨排行榜` ————看看前天的群友发了多少消息!
70
+
71
+ -`/本周群话痨排行榜` ————看看本周的群友发了多少消息!
72
+
73
+ -`/上周群话痨排行榜` ————看看上周的群友发了多少消息!
74
+
75
+ -`/本月群话痨排行榜` ————看看这个月的群友发了多少消息!
76
+
77
+ -`/年度群话痨排行榜` ————看看今年的群友发了多少消息!
78
+
79
+ -`/历史群话痨排行榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
80
+
81
+
82
+ ## 📖版本
83
+
84
+ ### V1.0
85
+
86
+ - 看看群里群友能有多话痨
87
+
88
+ ### V1.1
89
+
90
+ - 支持频道咯!(*^_^*)
91
+
92
+ ### V1.2
93
+
94
+ - 排行榜可视化
95
+
96
+ ### V1.3
97
+
98
+ - 添加了一些可配置项
99
+
100
+ ### V1.4
101
+
102
+ - 适配新版本的 chatrecorder, 暂时停止频道支持
103
+
104
+ ### V2.0
105
+
106
+ - 理论支持全平台!暂停图片支持。
107
+
108
+ ## 💧另外
109
+
110
+ ### 感谢
111
+
112
+ 本插件的__init__.py 中的处理函数参考了词云中的方法 ~~(其实大部分都是 Ctrl+C Ctr+V)~~
113
+
114
+ [nonebot-plugin-wordcloud](https://github.com/he0119/nonebot-plugin-wordcloud)
115
+
116
+ ## TODO
117
+
118
+ - [x] 适配全平台
119
+
120
+ - [ ] 私聊的查询(超级用户可以任意查询群聊的信息)
121
+
122
+ - [ ] 关键词查询
123
+
124
+ - [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
125
+
126
+ 待补充。.....
127
+
128
+ ## 题外话
129
+ ~~整个项目快被我写成屎山了~~
@@ -0,0 +1,255 @@
1
+ from nonebot import require
2
+
3
+ require("nonebot_plugin_chatrecorder")
4
+ require("nonebot_plugin_apscheduler")
5
+ require("nonebot_plugin_userinfo")
6
+ require("nonebot_plugin_alconna")
7
+ require("nonebot_plugin_cesaa")
8
+
9
+ import re
10
+
11
+ import nonebot_plugin_saa as saa
12
+
13
+ from typing import Union, Optional, List
14
+ from datetime import datetime, timedelta
15
+ from arclet.alconna import ArparmaBehavior
16
+ from arclet.alconna.arparma import Arparma
17
+
18
+ from nonebot.log import logger
19
+ from nonebot.params import Arg, Depends
20
+ from nonebot.typing import T_State
21
+ from nonebot.adapters import Bot, Event, Message
22
+ from nonebot.params import Arg, Depends
23
+ from nonebot.permission import SUPERUSER
24
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters
25
+ from nonebot.typing import T_State
26
+ from nonebot_plugin_alconna import (
27
+ Alconna,
28
+ AlconnaMatch,
29
+ AlconnaMatcher,
30
+ AlconnaQuery,
31
+ Args,
32
+ Match,
33
+ Option,
34
+ Query,
35
+ image_fetch,
36
+ on_alconna,
37
+ )
38
+
39
+ from nonebot_plugin_chatrecorder import get_message_records
40
+ from nonebot_plugin_userinfo import get_user_info
41
+ from nonebot_plugin_session import Session, SessionIdType, extract_session
42
+
43
+ # from . import migrations #抄词云的部分代码,还不知道这有什么用
44
+ # from .function import *
45
+ from .config import Config, plugin_config
46
+ from .usage import __usage__
47
+ from .utils import (
48
+ get_datetime_fromisoformat_with_timezone,
49
+ get_datetime_now_with_timezone,
50
+ got_rank,
51
+ msg_counter,
52
+ persist_id2user_id,
53
+ )
54
+
55
+ __plugin_meta__ = PluginMetadata(
56
+ name="B话排行榜",
57
+ description="调查群U的B话数量,以一定的顺序排序后排序出来。",
58
+ usage=__usage__,
59
+ homepage="https://github.com/ChenXu233/nonebot_plugin_dialectlist",
60
+ type="application",
61
+ supported_adapters=inherit_supported_adapters(
62
+ "nonebot_plugin_chatrecorder", "nonebot_plugin_saa", "nonebot_plugin_alconna"
63
+ ),
64
+ config=Config,
65
+ # extra={"orm_version_location": migrations},
66
+ )
67
+
68
+
69
+ # 抄的词云,不过真的很适合B话榜。
70
+ class SameTime(ArparmaBehavior):
71
+ def operate(self, interface: Arparma):
72
+ type = interface.query("type")
73
+ time = interface.query("time")
74
+ if type is None and time:
75
+ interface.behave_fail()
76
+
77
+
78
+ rank_cmd = on_alconna(
79
+ Alconna(
80
+ "B话榜",
81
+ Args["type?", ["今日", "昨日", "本周", "上周", "本月", "上月", "年度", "历史"]][
82
+ "time?", str
83
+ ],
84
+ behaviors=[SameTime()],
85
+ ),
86
+ use_cmd_start=True,
87
+ )
88
+
89
+
90
+ def wrapper(slot: Union[int, str], content: Optional[str]) -> str:
91
+ if slot == "type" and content:
92
+ return content
93
+ return "" # pragma: no cover
94
+
95
+
96
+ rank_cmd.shortcut(
97
+ r"(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)B话榜",
98
+ {
99
+ "prefix": True,
100
+ "command": "B话榜 ",
101
+ "wrapper": wrapper,
102
+ "args": ["{type}"],
103
+ },
104
+ )
105
+
106
+
107
+ def parse_datetime(key: str):
108
+ """解析数字,并将结果存入 state 中"""
109
+
110
+ async def _key_parser(
111
+ matcher: AlconnaMatcher,
112
+ state: T_State,
113
+ input: Union[datetime, Message] = Arg(key),
114
+ ):
115
+ if isinstance(input, datetime):
116
+ return
117
+
118
+ plaintext = input.extract_plain_text()
119
+ try:
120
+ state[key] = get_datetime_fromisoformat_with_timezone(plaintext)
121
+ except ValueError:
122
+ await matcher.reject_arg(key, "请输入正确的日期,不然我没法理解呢!")
123
+
124
+ return _key_parser
125
+
126
+
127
+ # TODO 处理函数更新
128
+ # 参考词云
129
+
130
+
131
+ # 这段函数完全抄的词云
132
+ @rank_cmd.handle()
133
+ async def _group_message(
134
+ state: T_State,
135
+ type: Optional[str] = None,
136
+ time: Optional[str] = None,
137
+ ):
138
+
139
+ dt = get_datetime_now_with_timezone()
140
+
141
+ if not type:
142
+ await rank_cmd.finish(__plugin_meta__.usage)
143
+
144
+ dt = get_datetime_now_with_timezone()
145
+
146
+ if type == "今日":
147
+ state["start"] = dt.replace(hour=0, minute=0, second=0, microsecond=0)
148
+ state["stop"] = dt
149
+ elif type == "昨日":
150
+ state["stop"] = dt.replace(hour=0, minute=0, second=0, microsecond=0)
151
+ state["start"] = state["stop"] - timedelta(days=1)
152
+ elif type == "本周":
153
+ state["start"] = dt.replace(
154
+ hour=0, minute=0, second=0, microsecond=0
155
+ ) - timedelta(days=dt.weekday())
156
+ state["stop"] = dt
157
+ elif type == "上周":
158
+ state["stop"] = dt.replace(
159
+ hour=0, minute=0, second=0, microsecond=0
160
+ ) - timedelta(days=dt.weekday())
161
+ state["start"] = state["stop"] - timedelta(days=7)
162
+ elif type == "本月":
163
+ state["start"] = dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
164
+ state["stop"] = dt
165
+ elif type == "上月":
166
+ state["stop"] = dt.replace(
167
+ day=1, hour=0, minute=0, second=0, microsecond=0
168
+ ) - timedelta(microseconds=1)
169
+ state["start"] = state["stop"].replace(
170
+ day=1, hour=0, minute=0, second=0, microsecond=0
171
+ )
172
+ elif type == "年度":
173
+ state["start"] = dt.replace(
174
+ month=1, day=1, hour=0, minute=0, second=0, microsecond=0
175
+ )
176
+ state["stop"] = dt
177
+ elif type == "历史":
178
+ if time:
179
+ plaintext = time
180
+ if match := re.match(r"^(.+?)(?:~(.+))?$", plaintext):
181
+ start = match[1]
182
+ stop = match[2]
183
+ try:
184
+ state["start"] = get_datetime_fromisoformat_with_timezone(start)
185
+ if stop:
186
+ state["stop"] = get_datetime_fromisoformat_with_timezone(stop)
187
+ else:
188
+ # 如果没有指定结束日期,则认为是所给日期的当天的词云
189
+ state["start"] = state["start"].replace(
190
+ hour=0, minute=0, second=0, microsecond=0
191
+ )
192
+ state["stop"] = state["start"] + timedelta(days=1)
193
+ except ValueError:
194
+ await rank_cmd.finish("请输入正确的日期,不然我没法理解呢!")
195
+
196
+
197
+ @rank_cmd.got(
198
+ "start",
199
+ prompt="请输入你要查询的起始日期(如 2022-01-01)",
200
+ parameterless=[Depends(parse_datetime("start"))],
201
+ )
202
+ @rank_cmd.got(
203
+ "stop",
204
+ prompt="请输入你要查询的结束日期(如 2022-02-22)",
205
+ parameterless=[Depends(parse_datetime("stop"))],
206
+ )
207
+ async def handle_rank(
208
+ bot: Bot,
209
+ event: Event,
210
+ session: Session = Depends(extract_session),
211
+ start: datetime = Arg(),
212
+ stop: datetime = Arg(),
213
+ ):
214
+ """生成词云"""
215
+ messages = await get_message_records(
216
+ session=session,
217
+ id_type=SessionIdType.GROUP,
218
+ include_bot_id=False,
219
+ include_bot_type=False,
220
+ types=["message"], # 排除机器人自己发的消息
221
+ time_start=start,
222
+ time_stop=stop,
223
+ exclude_id1s=plugin_config.excluded_people,
224
+ )
225
+
226
+ rank = got_rank(msg_counter(messages))
227
+ ids = await persist_id2user_id([int(i[0]) for i in rank])
228
+ for i in range(len(rank)):
229
+ rank[i][0] = str(ids[i])
230
+
231
+ string: str = ""
232
+ nicknames: List = []
233
+ for i in rank:
234
+ if user_info := await get_user_info(bot, event, user_id=str(i[0])):
235
+ (
236
+ nicknames.append(user_info.user_displayname)
237
+ if user_info.user_displayname
238
+ else (
239
+ nicknames.append(user_info.user_name)
240
+ if user_info.user_name
241
+ else nicknames.append(user_info.user_id)
242
+ )
243
+ )
244
+ else:
245
+ nicknames.append(None)
246
+ logger.debug(nicknames)
247
+ for i in range(len(rank)):
248
+ index = i + 1
249
+ nickname, chatdatanum = nicknames[i], rank[i][1]
250
+ str_example = plugin_config.string_format.format(
251
+ index=index, nickname=nickname, chatdatanum=chatdatanum
252
+ )
253
+ string += str_example
254
+
255
+ await saa.Text(string).finish(reply=True)
@@ -0,0 +1,29 @@
1
+ from typing import Optional, Literal, List
2
+ from nonebot import get_driver, get_plugin_config
3
+ from pydantic import BaseModel, field_validator
4
+
5
+
6
+ class ScopedConfig(BaseModel):
7
+ font: str = "SimHei" # 字体格式
8
+ get_num: int = 5 # 获取人数数量
9
+ timezone: Optional[str] = "Asia/Shanghai"
10
+ excluded_self: bool = True
11
+ string_format: str = "第{index}名:\n{nickname},{chatdatanum}条消息\n" # 消息格式
12
+ visualization: bool = True # 是否可视化
13
+ excluded_people: List[str] = [] # 排除的人的QQ号
14
+ visualization_type: Literal["饼图", "圆环图", "柱状图"] = "圆环图" # 可视化方案
15
+
16
+ @field_validator("get_num")
17
+ @classmethod
18
+ def check_priority(cls, v: int) -> int:
19
+ if v >= 1:
20
+ return v
21
+ raise ValueError("表中的人数必须大于一")
22
+
23
+
24
+ class Config(BaseModel):
25
+ dialectlist: ScopedConfig = ScopedConfig()
26
+
27
+
28
+ global_config = get_driver().config
29
+ plugin_config = get_plugin_config(Config).dialectlist
@@ -0,0 +1,9 @@
1
+ from inspect import cleandoc
2
+
3
+ __usage__ = cleandoc(
4
+ """
5
+ /今日B话榜 查看今天群里谁B话最多。
6
+ /昨日B话榜 顾名思义。
7
+ 以此类推,有本周,本月,上周,上月,年度排行榜。
8
+ """
9
+ )