nonebot-plugin-dialectlist 2.2.4__tar.gz → 2.3.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.
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/PKG-INFO +18 -12
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/README.md +14 -10
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/__init__.py +25 -68
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/config.py +1 -1
- nonebot_plugin_dialectlist-2.3.1/nonebot_plugin_dialectlist/model.py +27 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/rank_template.j2 +1 -1
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/time.py +0 -1
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/utils.py +75 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +18 -12
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -1
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/requires.txt +3 -1
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/pyproject.toml +8 -17
- nonebot_plugin_dialectlist-2.2.4/nonebot_plugin_dialectlist/model.py +0 -17
- nonebot_plugin_dialectlist-2.2.4/nonebot_plugin_dialectlist/template/avatar/master.jpg +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/MANIFEST.in +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/storage.py +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.2.4 → nonebot_plugin_dialectlist-2.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -15,12 +15,14 @@ Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
|
15
15
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.4
|
|
16
16
|
Requires-Dist: nonebot-plugin-htmlrender>=0.3.3
|
|
17
17
|
Requires-Dist: nonebot2>=2.3.2
|
|
18
|
-
Requires-Dist:
|
|
18
|
+
Requires-Dist: pillow>=10.4.0
|
|
19
|
+
Requires-Dist: nonebot-plugin-uninfo>=0.1.1
|
|
19
20
|
Provides-Extra: dev
|
|
20
21
|
Requires-Dist: ruff>=0.5.5; extra == "dev"
|
|
21
22
|
Requires-Dist: setuptools>=71.1.0; extra == "dev"
|
|
22
23
|
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
23
24
|
Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
25
|
+
Requires-Dist: py-spy>=0.3.14; extra == "dev"
|
|
24
26
|
Provides-Extra: test
|
|
25
27
|
Requires-Dist: nonebot-adapter-onebot>=2.4.4; extra == "test"
|
|
26
28
|
|
|
@@ -64,12 +66,15 @@ nonebot-plugin-dialectlist
|
|
|
64
66
|
|
|
65
67
|
### ✅ 插件依赖于
|
|
66
68
|
|
|
67
|
-
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore)
|
|
69
|
+
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————本地化储存
|
|
68
70
|
2. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
69
71
|
3. [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) ————定时发送排行榜信息
|
|
70
72
|
4. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
71
|
-
5. [nonebot-plugin-
|
|
72
|
-
|
|
73
|
+
5. [nonebot-plugin-chatrecorder](https://github.com/noneplugin/nonebot-plugin-chatrecorder) ————实现消息储存
|
|
74
|
+
6. [nonebot-plugin-cesaa](https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere) ————实现多平台
|
|
75
|
+
|
|
76
|
+
**⚠注意** 若先前没有安装过```nonebot-plugin-chatrecorder```或者```nonebot-plugin-orm```,则会在启动时报错,请按报错的提示安装数据库!
|
|
77
|
+
|
|
73
78
|
## ⚙ 配置
|
|
74
79
|
|
|
75
80
|
需要**提前配置**本插件所**依赖的插件**!
|
|
@@ -173,22 +178,23 @@ __!!注意!!__
|
|
|
173
178
|
|
|
174
179
|
- [x] 适配全平台
|
|
175
180
|
|
|
176
|
-
- [x]
|
|
177
|
-
|
|
178
|
-
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
181
|
+
- [x] 更好看的图片渲染
|
|
179
182
|
|
|
180
183
|
- [x] 添加一些全新的可配置项
|
|
184
|
+
|
|
185
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
181
186
|
|
|
182
|
-
- [x]
|
|
187
|
+
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
183
188
|
|
|
184
189
|
- [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
|
|
185
|
-
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
186
|
-
|
|
187
|
-
- [ ] 查询带某关键词的消息量
|
|
188
190
|
|
|
189
191
|
- [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
|
|
190
192
|
|
|
193
|
+
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
194
|
+
|
|
191
195
|
- [ ] 特殊的储存方案优化消息统计
|
|
196
|
+
|
|
197
|
+
- [ ] 查询带某关键词的消息量
|
|
192
198
|
|
|
193
199
|
待补充。.....
|
|
194
200
|
|
|
@@ -38,12 +38,15 @@ nonebot-plugin-dialectlist
|
|
|
38
38
|
|
|
39
39
|
### ✅ 插件依赖于
|
|
40
40
|
|
|
41
|
-
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore)
|
|
41
|
+
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————本地化储存
|
|
42
42
|
2. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
43
43
|
3. [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) ————定时发送排行榜信息
|
|
44
44
|
4. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
45
|
-
5. [nonebot-plugin-
|
|
46
|
-
|
|
45
|
+
5. [nonebot-plugin-chatrecorder](https://github.com/noneplugin/nonebot-plugin-chatrecorder) ————实现消息储存
|
|
46
|
+
6. [nonebot-plugin-cesaa](https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere) ————实现多平台
|
|
47
|
+
|
|
48
|
+
**⚠注意** 若先前没有安装过```nonebot-plugin-chatrecorder```或者```nonebot-plugin-orm```,则会在启动时报错,请按报错的提示安装数据库!
|
|
49
|
+
|
|
47
50
|
## ⚙ 配置
|
|
48
51
|
|
|
49
52
|
需要**提前配置**本插件所**依赖的插件**!
|
|
@@ -147,22 +150,23 @@ __!!注意!!__
|
|
|
147
150
|
|
|
148
151
|
- [x] 适配全平台
|
|
149
152
|
|
|
150
|
-
- [x]
|
|
151
|
-
|
|
152
|
-
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
153
|
+
- [x] 更好看的图片渲染
|
|
153
154
|
|
|
154
155
|
- [x] 添加一些全新的可配置项
|
|
156
|
+
|
|
157
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
155
158
|
|
|
156
|
-
- [x]
|
|
159
|
+
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
157
160
|
|
|
158
161
|
- [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
|
|
159
|
-
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
160
|
-
|
|
161
|
-
- [ ] 查询带某关键词的消息量
|
|
162
162
|
|
|
163
163
|
- [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
|
|
164
164
|
|
|
165
|
+
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
166
|
+
|
|
165
167
|
- [ ] 特殊的储存方案优化消息统计
|
|
168
|
+
|
|
169
|
+
- [ ] 查询带某关键词的消息量
|
|
166
170
|
|
|
167
171
|
待补充。.....
|
|
168
172
|
|
|
@@ -8,22 +8,18 @@ require("nonebot_plugin_alconna")
|
|
|
8
8
|
require("nonebot_plugin_cesaa")
|
|
9
9
|
|
|
10
10
|
import re
|
|
11
|
-
import os
|
|
12
|
-
import cn2an
|
|
13
11
|
import time as t
|
|
14
12
|
import nonebot_plugin_saa as saa
|
|
15
13
|
|
|
16
|
-
from typing import Union, Optional
|
|
14
|
+
from typing import Union, Optional
|
|
17
15
|
from datetime import datetime, timedelta
|
|
18
16
|
from arclet.alconna import ArparmaBehavior
|
|
19
17
|
from arclet.alconna.arparma import Arparma
|
|
20
18
|
|
|
21
19
|
from nonebot.log import logger
|
|
22
20
|
from nonebot.typing import T_State
|
|
23
|
-
from nonebot.compat import model_dump
|
|
24
21
|
from nonebot.params import Arg, Depends
|
|
25
22
|
from nonebot.adapters import Bot, Event
|
|
26
|
-
from nonebot.permission import SUPERUSER
|
|
27
23
|
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
|
28
24
|
from nonebot_plugin_alconna import (
|
|
29
25
|
Args,
|
|
@@ -31,9 +27,6 @@ from nonebot_plugin_alconna import (
|
|
|
31
27
|
Alconna,
|
|
32
28
|
on_alconna,
|
|
33
29
|
)
|
|
34
|
-
|
|
35
|
-
from nonebot_plugin_apscheduler import scheduler
|
|
36
|
-
from nonebot_plugin_userinfo import get_user_info
|
|
37
30
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
38
31
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
39
32
|
|
|
@@ -46,12 +39,12 @@ from .time import (
|
|
|
46
39
|
get_datetime_now_with_timezone,
|
|
47
40
|
parse_datetime,
|
|
48
41
|
)
|
|
49
|
-
from .model import UserRankInfo
|
|
50
42
|
from .utils import (
|
|
51
43
|
got_rank,
|
|
52
44
|
msg_counter,
|
|
53
45
|
get_rank_image,
|
|
54
46
|
persist_id2user_id,
|
|
47
|
+
get_user_infos,
|
|
55
48
|
# get_user_info2,
|
|
56
49
|
)
|
|
57
50
|
|
|
@@ -193,7 +186,7 @@ async def _group_message(
|
|
|
193
186
|
state["stop"] = state["start"] + timedelta(days=1)
|
|
194
187
|
except ValueError:
|
|
195
188
|
await rank_cmd.finish("请输入正确的日期,不然我没法理解呢!")
|
|
196
|
-
|
|
189
|
+
|
|
197
190
|
logger.debug(f"命令解析花费时间:{t.time() - t1}")
|
|
198
191
|
|
|
199
192
|
|
|
@@ -216,7 +209,7 @@ async def handle_rank(
|
|
|
216
209
|
start: datetime = Arg(),
|
|
217
210
|
stop: datetime = Arg(),
|
|
218
211
|
):
|
|
219
|
-
|
|
212
|
+
|
|
220
213
|
if id := state["group_id"]:
|
|
221
214
|
id = str(id)
|
|
222
215
|
logger.debug(f"group_id: {id}")
|
|
@@ -227,70 +220,35 @@ async def handle_rank(
|
|
|
227
220
|
if not id:
|
|
228
221
|
await saa.Text("没有指定群哦").finish()
|
|
229
222
|
|
|
230
|
-
|
|
231
|
-
|
|
223
|
+
if plugin_config.counting_cache:
|
|
224
|
+
raise Exception("我草缓存功能还没端上来呢,你怎么就先用上了")
|
|
225
|
+
else:
|
|
226
|
+
messages = await get_message_records(
|
|
227
|
+
id2s=[id],
|
|
228
|
+
id_type=SessionIdType.GROUP,
|
|
229
|
+
include_bot_id=False,
|
|
230
|
+
include_bot_type=False,
|
|
231
|
+
types=["message"], # 排除机器人自己发的消息
|
|
232
|
+
time_start=start,
|
|
233
|
+
time_stop=stop,
|
|
234
|
+
exclude_id1s=plugin_config.excluded_people,
|
|
235
|
+
)
|
|
232
236
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
id_type=SessionIdType.GROUP,
|
|
236
|
-
include_bot_id=False,
|
|
237
|
-
include_bot_type=False,
|
|
238
|
-
types=["message"], # 排除机器人自己发的消息
|
|
239
|
-
time_start=start,
|
|
240
|
-
time_stop=stop,
|
|
241
|
-
exclude_id1s=plugin_config.excluded_people,
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
logger.debug(f"获取群聊消息花费时间:{t.time() - t1}")
|
|
245
|
-
t1 = t.time()
|
|
246
|
-
|
|
247
|
-
if not messages:
|
|
248
|
-
await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish()
|
|
237
|
+
if not messages:
|
|
238
|
+
await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish()
|
|
249
239
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
240
|
+
raw_rank = msg_counter(messages)
|
|
241
|
+
|
|
242
|
+
rank = got_rank(raw_rank)
|
|
253
243
|
logger.debug(rank)
|
|
254
|
-
rank2: List[UserRankInfo] = []
|
|
255
244
|
ids = await persist_id2user_id([int(i[0]) for i in rank])
|
|
256
245
|
for i in range(len(rank)):
|
|
257
246
|
rank[i][0] = str(ids[i])
|
|
258
247
|
logger.debug(rank[i])
|
|
259
248
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if user_info := await get_user_info(bot, event, user_id=str(i[0])):
|
|
264
|
-
logger.debug(user_info)
|
|
265
|
-
user_nickname = (
|
|
266
|
-
user_info.user_displayname
|
|
267
|
-
if user_info.user_displayname
|
|
268
|
-
else user_info.user_name if user_info.user_name else user_info.user_id
|
|
269
|
-
)
|
|
270
|
-
user_avatar = (
|
|
271
|
-
await user_info.user_avatar.get_image()
|
|
272
|
-
if user_info.user_avatar
|
|
273
|
-
else open(
|
|
274
|
-
os.path.dirname(os.path.abspath(__file__))
|
|
275
|
-
+ "/template/avatar/default.jpg",
|
|
276
|
-
"rb",
|
|
277
|
-
).read()
|
|
278
|
-
)
|
|
279
|
-
user = UserRankInfo(
|
|
280
|
-
**model_dump(user_info),
|
|
281
|
-
user_bnum=i[1],
|
|
282
|
-
user_proportion=round(i[1] / total * 100, 2),
|
|
283
|
-
user_index=index,
|
|
284
|
-
user_nickname=user_nickname,
|
|
285
|
-
user_avatar_bytes=user_avatar,
|
|
286
|
-
)
|
|
287
|
-
user.user_gender = (
|
|
288
|
-
"♀"
|
|
289
|
-
if user_info.user_gender == "female"
|
|
290
|
-
else "♂" if user_info.user_gender == "male" else ""
|
|
291
|
-
)
|
|
292
|
-
rank2.append(user)
|
|
293
|
-
index += 1
|
|
249
|
+
t1 = t.time()
|
|
250
|
+
rank2 = await get_user_infos(bot, event, rank)
|
|
251
|
+
logger.debug(f"获取用户信息花费时间:{t.time() - t1}")
|
|
294
252
|
|
|
295
253
|
string: str = ""
|
|
296
254
|
for i in rank2:
|
|
@@ -304,7 +262,6 @@ async def handle_rank(
|
|
|
304
262
|
string += str_example
|
|
305
263
|
|
|
306
264
|
msg = saa.Text(string)
|
|
307
|
-
logger.debug(f"群聊消息渲染文字花费时间:{t.time() - t1}")
|
|
308
265
|
t1 = t.time()
|
|
309
266
|
|
|
310
267
|
if plugin_config.visualization:
|
|
@@ -9,7 +9,7 @@ class ScopedConfig(BaseModel):
|
|
|
9
9
|
suffix: bool = False # 是否显示后缀
|
|
10
10
|
excluded_self: bool = True
|
|
11
11
|
visualization: bool = True # 是否可视化
|
|
12
|
-
counting_cache: bool =
|
|
12
|
+
counting_cache: bool = False # 计数缓存(没有完工)
|
|
13
13
|
excluded_people: List[str] = [] # 排除的人的QQ号
|
|
14
14
|
timezone: Optional[str] = "Asia/Shanghai"
|
|
15
15
|
string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Union
|
|
3
|
+
from sqlalchemy import Integer
|
|
4
|
+
from nonebot_plugin_orm import Model
|
|
5
|
+
from nonebot_plugin_userinfo import UserInfo
|
|
6
|
+
from sqlalchemy.orm import Mapped, mapped_column
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UserRankInfo(UserInfo):
|
|
10
|
+
user_bnum: int
|
|
11
|
+
user_proportion: float
|
|
12
|
+
user_nickname: str
|
|
13
|
+
user_index: Union[int, str]
|
|
14
|
+
user_avatar_bytes: bytes
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# class MsgCountDayData(BaseModel):
|
|
18
|
+
# session_id: str
|
|
19
|
+
# session_bnum: int
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MessageCountCache(Model):
|
|
23
|
+
__table_args__ = {"extend_existing": True}
|
|
24
|
+
id: Mapped[int] = mapped_column(primary_key=True)
|
|
25
|
+
time: Mapped[datetime]
|
|
26
|
+
session_id: Mapped[int] = mapped_column(Integer)
|
|
27
|
+
session_bnum: Mapped[int] = mapped_column(Integer)
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</div>
|
|
40
40
|
|
|
41
41
|
<div class="card2 glow">
|
|
42
|
-
<img class="profile2" src="
|
|
42
|
+
<img class="profile2" src="https://q2.qlogo.cn/headimg_dl?dst_uin=1964324406&spec=100"/>
|
|
43
43
|
<p class="center_text2">Designed By ChenXu233</p>
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import asyncio
|
|
2
3
|
import unicodedata
|
|
3
4
|
|
|
4
5
|
from typing import Dict, List
|
|
@@ -7,10 +8,13 @@ from sqlalchemy.sql import ColumnElement
|
|
|
7
8
|
|
|
8
9
|
from nonebot.log import logger
|
|
9
10
|
from nonebot.params import Depends
|
|
11
|
+
from nonebot.compat import model_dump
|
|
10
12
|
from nonebot.matcher import Matcher
|
|
13
|
+
from nonebot.adapters import Bot, Event
|
|
11
14
|
|
|
12
15
|
from nonebot_plugin_orm import get_session
|
|
13
16
|
from nonebot_plugin_session import Session, SessionLevel, extract_session
|
|
17
|
+
from nonebot_plugin_userinfo import get_user_info, UserInfo
|
|
14
18
|
from nonebot_plugin_localstore import get_cache_dir
|
|
15
19
|
from nonebot_plugin_htmlrender import template_to_pic
|
|
16
20
|
from nonebot_plugin_session_orm import SessionModel
|
|
@@ -180,3 +184,74 @@ async def get_rank_image(rank: List[UserRankInfo]) -> bytes:
|
|
|
180
184
|
},
|
|
181
185
|
pages={"viewport": {"width": 1000, "height": 10}},
|
|
182
186
|
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _get_user_nickname(user_info: UserInfo) -> str:
|
|
190
|
+
user_nickname = (
|
|
191
|
+
user_info.user_displayname
|
|
192
|
+
if user_info.user_displayname
|
|
193
|
+
else user_info.user_name if user_info.user_name else user_info.user_id
|
|
194
|
+
)
|
|
195
|
+
return user_nickname
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
async def _get_user_default_avatar() -> bytes:
|
|
199
|
+
img = open(
|
|
200
|
+
os.path.dirname(os.path.abspath(__file__)) + "/template/avatar/default.jpg",
|
|
201
|
+
"rb",
|
|
202
|
+
).read()
|
|
203
|
+
return img
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def get_default_user_info() -> UserInfo:
|
|
207
|
+
user_info = UserInfo(
|
|
208
|
+
user_id="114514",
|
|
209
|
+
user_name="鬼知道这谁,bot获取不了",
|
|
210
|
+
)
|
|
211
|
+
return user_info
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
async def get_user_infos(
|
|
215
|
+
bot: Bot, event: Event, rank: List, use_cache: bool = True
|
|
216
|
+
) -> List[UserRankInfo]:
|
|
217
|
+
|
|
218
|
+
user_ids = [i[0] for i in rank]
|
|
219
|
+
pool = [get_user_info(bot, event, id, use_cache) for id in user_ids]
|
|
220
|
+
user_infos = await asyncio.gather(*pool)
|
|
221
|
+
|
|
222
|
+
pool = []
|
|
223
|
+
for i in user_infos:
|
|
224
|
+
if not i:
|
|
225
|
+
pool.append(_get_user_default_avatar())
|
|
226
|
+
continue
|
|
227
|
+
if i.user_avatar:
|
|
228
|
+
pool.append(i.user_avatar.get_image())
|
|
229
|
+
user_avatars = await asyncio.gather(*pool)
|
|
230
|
+
for i in user_avatars:
|
|
231
|
+
if not i:
|
|
232
|
+
user_avatars[user_avatars.index(i)] = await _get_user_default_avatar()
|
|
233
|
+
|
|
234
|
+
total = sum([i[1] for i in rank])
|
|
235
|
+
rank2 = []
|
|
236
|
+
for i in range(len(rank)):
|
|
237
|
+
|
|
238
|
+
user_info = user_infos[i]
|
|
239
|
+
if not user_info:
|
|
240
|
+
user_info = get_default_user_info()
|
|
241
|
+
|
|
242
|
+
user = UserRankInfo(
|
|
243
|
+
**model_dump(user_info),
|
|
244
|
+
user_bnum=rank[i][1],
|
|
245
|
+
user_proportion=round(rank[i][1] / total * 100, 2),
|
|
246
|
+
user_index=i + 1,
|
|
247
|
+
user_nickname=_get_user_nickname(user_info),
|
|
248
|
+
user_avatar_bytes=user_avatars[i],
|
|
249
|
+
)
|
|
250
|
+
user.user_gender = (
|
|
251
|
+
"♂"
|
|
252
|
+
if user.user_gender == "male"
|
|
253
|
+
else "♀" if user.user_gender == "female" else ""
|
|
254
|
+
)
|
|
255
|
+
rank2.append(user)
|
|
256
|
+
|
|
257
|
+
return rank2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -15,12 +15,14 @@ Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
|
15
15
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.4
|
|
16
16
|
Requires-Dist: nonebot-plugin-htmlrender>=0.3.3
|
|
17
17
|
Requires-Dist: nonebot2>=2.3.2
|
|
18
|
-
Requires-Dist:
|
|
18
|
+
Requires-Dist: pillow>=10.4.0
|
|
19
|
+
Requires-Dist: nonebot-plugin-uninfo>=0.1.1
|
|
19
20
|
Provides-Extra: dev
|
|
20
21
|
Requires-Dist: ruff>=0.5.5; extra == "dev"
|
|
21
22
|
Requires-Dist: setuptools>=71.1.0; extra == "dev"
|
|
22
23
|
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
23
24
|
Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
25
|
+
Requires-Dist: py-spy>=0.3.14; extra == "dev"
|
|
24
26
|
Provides-Extra: test
|
|
25
27
|
Requires-Dist: nonebot-adapter-onebot>=2.4.4; extra == "test"
|
|
26
28
|
|
|
@@ -64,12 +66,15 @@ nonebot-plugin-dialectlist
|
|
|
64
66
|
|
|
65
67
|
### ✅ 插件依赖于
|
|
66
68
|
|
|
67
|
-
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore)
|
|
69
|
+
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————本地化储存
|
|
68
70
|
2. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
69
71
|
3. [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) ————定时发送排行榜信息
|
|
70
72
|
4. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
71
|
-
5. [nonebot-plugin-
|
|
72
|
-
|
|
73
|
+
5. [nonebot-plugin-chatrecorder](https://github.com/noneplugin/nonebot-plugin-chatrecorder) ————实现消息储存
|
|
74
|
+
6. [nonebot-plugin-cesaa](https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere) ————实现多平台
|
|
75
|
+
|
|
76
|
+
**⚠注意** 若先前没有安装过```nonebot-plugin-chatrecorder```或者```nonebot-plugin-orm```,则会在启动时报错,请按报错的提示安装数据库!
|
|
77
|
+
|
|
73
78
|
## ⚙ 配置
|
|
74
79
|
|
|
75
80
|
需要**提前配置**本插件所**依赖的插件**!
|
|
@@ -173,22 +178,23 @@ __!!注意!!__
|
|
|
173
178
|
|
|
174
179
|
- [x] 适配全平台
|
|
175
180
|
|
|
176
|
-
- [x]
|
|
177
|
-
|
|
178
|
-
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
181
|
+
- [x] 更好看的图片渲染
|
|
179
182
|
|
|
180
183
|
- [x] 添加一些全新的可配置项
|
|
184
|
+
|
|
185
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
181
186
|
|
|
182
|
-
- [x]
|
|
187
|
+
- [x] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
183
188
|
|
|
184
189
|
- [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
|
|
185
|
-
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
186
|
-
|
|
187
|
-
- [ ] 查询带某关键词的消息量
|
|
188
190
|
|
|
189
191
|
- [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
|
|
190
192
|
|
|
193
|
+
- [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
194
|
+
|
|
191
195
|
- [ ] 特殊的储存方案优化消息统计
|
|
196
|
+
|
|
197
|
+
- [ ] 查询带某关键词的消息量
|
|
192
198
|
|
|
193
199
|
待补充。.....
|
|
194
200
|
|
|
@@ -15,5 +15,4 @@ nonebot_plugin_dialectlist.egg-info/requires.txt
|
|
|
15
15
|
nonebot_plugin_dialectlist.egg-info/top_level.txt
|
|
16
16
|
nonebot_plugin_dialectlist/template/rank_template.j2
|
|
17
17
|
nonebot_plugin_dialectlist/template/avatar/default.jpg
|
|
18
|
-
nonebot_plugin_dialectlist/template/avatar/master.jpg
|
|
19
18
|
nonebot_plugin_dialectlist/template/css/style.css
|
|
@@ -7,7 +7,8 @@ nonebot-plugin-cesaa>=0.4.0
|
|
|
7
7
|
nonebot-plugin-userinfo>=0.2.4
|
|
8
8
|
nonebot-plugin-htmlrender>=0.3.3
|
|
9
9
|
nonebot2>=2.3.2
|
|
10
|
-
|
|
10
|
+
pillow>=10.4.0
|
|
11
|
+
nonebot-plugin-uninfo>=0.1.1
|
|
11
12
|
|
|
12
13
|
[Test]
|
|
13
14
|
nonebot-adapter-onebot>=2.4.4
|
|
@@ -17,3 +18,4 @@ ruff>=0.5.5
|
|
|
17
18
|
setuptools>=71.1.0
|
|
18
19
|
twine>=5.1.0
|
|
19
20
|
nb-cli>=0.7.6
|
|
21
|
+
py-spy>=0.3.14
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-dialectlist"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.1"
|
|
4
4
|
description = "看看你群群友有多能说"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
|
@@ -15,7 +15,8 @@ dependencies = [
|
|
|
15
15
|
"nonebot-plugin-userinfo>=0.2.4",
|
|
16
16
|
"nonebot-plugin-htmlrender>=0.3.3",
|
|
17
17
|
"nonebot2>=2.3.2",
|
|
18
|
-
"
|
|
18
|
+
"pillow>=10.4.0",
|
|
19
|
+
"nonebot-plugin-uninfo>=0.1.1",
|
|
19
20
|
]
|
|
20
21
|
requires-python = ">=3.9,<4.0"
|
|
21
22
|
readme = "README.md"
|
|
@@ -27,7 +28,8 @@ dev = [
|
|
|
27
28
|
"ruff>=0.5.5",
|
|
28
29
|
"setuptools>=71.1.0",
|
|
29
30
|
"twine>=5.1.0",
|
|
30
|
-
"nb-cli>=0.7.6"
|
|
31
|
+
"nb-cli>=0.7.6",
|
|
32
|
+
"py-spy>=0.3.14",
|
|
31
33
|
]
|
|
32
34
|
Test = [
|
|
33
35
|
"nonebot-adapter-onebot>=2.4.4",
|
|
@@ -38,21 +40,10 @@ distribution = true
|
|
|
38
40
|
|
|
39
41
|
[tool.ruff]
|
|
40
42
|
line-length = 80
|
|
43
|
+
|
|
41
44
|
[tool.ruff.format]
|
|
42
45
|
quote-style = "single"
|
|
43
46
|
indent-style = "tab"
|
|
44
47
|
|
|
45
|
-
[tool.
|
|
46
|
-
|
|
47
|
-
build = 'pdm run setup.py sdist'
|
|
48
|
-
publish = 'pdm run python -m twine upload dist/*'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# 以下为智普 AI 生成,还不知道这玩意有啥用。
|
|
52
|
-
# [tool.pdm.dev-dependencies]
|
|
53
|
-
# black = "^23.1.0"
|
|
54
|
-
# isort = "^5.10.1"
|
|
55
|
-
# pre-commit = "^2.20.0"
|
|
56
|
-
|
|
57
|
-
# [tool.pdm.global-options]
|
|
58
|
-
# --no-pip-version-check = true
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
ignore = ["E402"]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
from pydantic import BaseModel
|
|
3
|
-
from nonebot_plugin_orm import Model
|
|
4
|
-
from nonebot_plugin_userinfo import UserInfo
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class UserRankInfo(UserInfo):
|
|
8
|
-
user_bnum: int
|
|
9
|
-
user_proportion: float
|
|
10
|
-
user_nickname: str
|
|
11
|
-
user_index: Union[int, str]
|
|
12
|
-
user_avatar_bytes: bytes
|
|
13
|
-
|
|
14
|
-
class MsgCountDayData(BaseModel):
|
|
15
|
-
user_id:str
|
|
16
|
-
# class MsgCountData(Model):
|
|
17
|
-
# __tablename__ = 'dialectlist_msg_data'
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|