nonebot-plugin-dialectlist 2.1.7__tar.gz → 2.2.0__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.1.7 → nonebot_plugin_dialectlist-2.2.0}/PKG-INFO +29 -16
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/README.md +19 -7
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/__init__.py +76 -37
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/model.py +2 -2
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/utils.py +50 -18
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +29 -16
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -1
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist.egg-info/requires.txt +9 -7
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/pyproject.toml +11 -9
- nonebot_plugin_dialectlist-2.1.7/setup.py +0 -3
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/MANIFEST.in +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/config.py +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/storage.py +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/template/avatar/master.jpg +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/time.py +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.1.7 → nonebot_plugin_dialectlist-2.2.0}/setup.cfg +0 -0
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
7
|
-
Requires-Python: <4.0,>=3.
|
|
7
|
+
Requires-Python: <4.0,>=3.9
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
|
-
Requires-Dist: nonebot2>=2.3.1
|
|
10
9
|
Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
|
|
11
|
-
Requires-Dist: pygal>=3.0.4
|
|
12
10
|
Requires-Dist: requests>=2.32.3
|
|
13
11
|
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
14
|
-
Requires-Dist: nonebot-plugin-alconna>=0.
|
|
12
|
+
Requires-Dist: nonebot-plugin-alconna>=0.50.2
|
|
15
13
|
Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
16
14
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.4
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: nonebot-plugin-htmlrender>=0.3.3
|
|
16
|
+
Requires-Dist: nonebot2>=2.3.2
|
|
17
|
+
Requires-Dist: cn2an>=0.5.22
|
|
19
18
|
Provides-Extra: dev
|
|
20
|
-
Requires-Dist: ruff>=0.
|
|
21
|
-
Requires-Dist: setuptools>=
|
|
19
|
+
Requires-Dist: ruff>=0.5.5; extra == "dev"
|
|
20
|
+
Requires-Dist: setuptools>=71.1.0; extra == "dev"
|
|
22
21
|
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
23
22
|
Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: nonebot-adapter-onebot>=2.4.4; extra == "test"
|
|
24
25
|
|
|
25
26
|
<div align="center">
|
|
26
27
|
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
@@ -34,8 +35,8 @@ Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
|
34
35
|
nonebot-plugin-dialectlist
|
|
35
36
|
|
|
36
37
|
<p align="center">
|
|
37
|
-
<a href="https://pypi.python.org/pypi/nonebot-plugin-
|
|
38
|
-
<img src="https://img.shields.io/pypi/v/nonebot-plugin-
|
|
38
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-dialectlist">
|
|
39
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
39
40
|
</a>
|
|
40
41
|
|
|
41
42
|
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
@@ -79,8 +80,8 @@ dialectlist__string_suffix_format = '你们的职业是水群吗?————M
|
|
|
79
80
|
dialectlist__get_num = 10 #获取人数数量
|
|
80
81
|
dialectlist__visualization = True #是否可视化
|
|
81
82
|
dialectlist__visualization_type = '圆环图' #可视化方案
|
|
82
|
-
dialectlist__font = 'SimHei'#字体格式
|
|
83
|
-
dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
|
|
83
|
+
dialectlist__font = 'SimHei' #字体格式
|
|
84
|
+
dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
|
|
84
85
|
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
|
85
86
|
```
|
|
86
87
|
💭也可以不进行配置,这将会使插件按照默认配置运行
|
|
@@ -191,11 +192,23 @@ __!!注意!!__
|
|
|
191
192
|
|
|
192
193
|
- [x] 适配全平台
|
|
193
194
|
|
|
194
|
-
- [
|
|
195
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
195
196
|
|
|
196
|
-
- [ ]
|
|
197
|
+
- [ ] 更好看的图片渲染
|
|
198
|
+
|
|
199
|
+
- [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
|
|
200
|
+
- [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
201
|
+
|
|
202
|
+
- [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
203
|
+
|
|
204
|
+
- [ ] 查询带某关键词的消息量
|
|
205
|
+
|
|
206
|
+
- [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
|
|
207
|
+
|
|
208
|
+
- [ ] 特殊的储存方案优化消息统计
|
|
209
|
+
|
|
210
|
+
- [ ] 添加一些全新的可配置项
|
|
197
211
|
|
|
198
|
-
- [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
|
|
199
212
|
|
|
200
213
|
待补充。.....
|
|
201
214
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
nonebot-plugin-dialectlist
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
-
<a href="https://pypi.python.org/pypi/nonebot-plugin-
|
|
14
|
-
<img src="https://img.shields.io/pypi/v/nonebot-plugin-
|
|
13
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-dialectlist">
|
|
14
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
15
15
|
</a>
|
|
16
16
|
|
|
17
17
|
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
@@ -55,8 +55,8 @@ dialectlist__string_suffix_format = '你们的职业是水群吗?————M
|
|
|
55
55
|
dialectlist__get_num = 10 #获取人数数量
|
|
56
56
|
dialectlist__visualization = True #是否可视化
|
|
57
57
|
dialectlist__visualization_type = '圆环图' #可视化方案
|
|
58
|
-
dialectlist__font = 'SimHei'#字体格式
|
|
59
|
-
dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
|
|
58
|
+
dialectlist__font = 'SimHei' #字体格式
|
|
59
|
+
dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
|
|
60
60
|
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
|
61
61
|
```
|
|
62
62
|
💭也可以不进行配置,这将会使插件按照默认配置运行
|
|
@@ -167,11 +167,23 @@ __!!注意!!__
|
|
|
167
167
|
|
|
168
168
|
- [x] 适配全平台
|
|
169
169
|
|
|
170
|
-
- [
|
|
170
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
171
171
|
|
|
172
|
-
- [ ]
|
|
172
|
+
- [ ] 更好看的图片渲染
|
|
173
|
+
|
|
174
|
+
- [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
|
|
175
|
+
- [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
176
|
+
|
|
177
|
+
- [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
178
|
+
|
|
179
|
+
- [ ] 查询带某关键词的消息量
|
|
180
|
+
|
|
181
|
+
- [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
|
|
182
|
+
|
|
183
|
+
- [ ] 特殊的储存方案优化消息统计
|
|
184
|
+
|
|
185
|
+
- [ ] 添加一些全新的可配置项
|
|
173
186
|
|
|
174
|
-
- [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
|
|
175
187
|
|
|
176
188
|
待补充。.....
|
|
177
189
|
|
|
@@ -9,6 +9,7 @@ require("nonebot_plugin_cesaa")
|
|
|
9
9
|
|
|
10
10
|
import re
|
|
11
11
|
import os
|
|
12
|
+
import cn2an
|
|
12
13
|
import nonebot_plugin_saa as saa
|
|
13
14
|
|
|
14
15
|
from typing import Union, Optional, List
|
|
@@ -19,6 +20,7 @@ from arclet.alconna.arparma import Arparma
|
|
|
19
20
|
from nonebot.log import logger
|
|
20
21
|
from nonebot.params import Arg, Depends
|
|
21
22
|
from nonebot.typing import T_State
|
|
23
|
+
from nonebot.compat import model_dump
|
|
22
24
|
from nonebot.adapters import Bot, Event, Message
|
|
23
25
|
from nonebot.params import Arg, Depends
|
|
24
26
|
from nonebot.permission import SUPERUSER
|
|
@@ -29,6 +31,7 @@ from nonebot_plugin_alconna import (
|
|
|
29
31
|
AlconnaMatch,
|
|
30
32
|
AlconnaMatcher,
|
|
31
33
|
AlconnaQuery,
|
|
34
|
+
Option,
|
|
32
35
|
Args,
|
|
33
36
|
Match,
|
|
34
37
|
Option,
|
|
@@ -38,8 +41,6 @@ from nonebot_plugin_alconna import (
|
|
|
38
41
|
)
|
|
39
42
|
|
|
40
43
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
41
|
-
from nonebot_plugin_localstore import get_cache_file
|
|
42
|
-
from nonebot_plugin_htmlrender import html_to_pic
|
|
43
44
|
from nonebot_plugin_userinfo import get_user_info
|
|
44
45
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
45
46
|
|
|
@@ -47,13 +48,19 @@ from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
|
47
48
|
# from .function import *
|
|
48
49
|
from .config import Config, plugin_config
|
|
49
50
|
from .usage import __usage__
|
|
50
|
-
from .time import
|
|
51
|
+
from .time import (
|
|
52
|
+
get_datetime_fromisoformat_with_timezone,
|
|
53
|
+
get_datetime_now_with_timezone,
|
|
54
|
+
parse_datetime,
|
|
55
|
+
)
|
|
51
56
|
from .model import UserRankInfo
|
|
52
57
|
from .utils import (
|
|
53
58
|
got_rank,
|
|
54
59
|
msg_counter,
|
|
55
60
|
persist_id2user_id,
|
|
56
|
-
|
|
61
|
+
user_id2persist_id,
|
|
62
|
+
group_id2persist_id,
|
|
63
|
+
get_rank_image,
|
|
57
64
|
)
|
|
58
65
|
|
|
59
66
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -79,7 +86,7 @@ class SameTime(ArparmaBehavior):
|
|
|
79
86
|
interface.behave_fail()
|
|
80
87
|
|
|
81
88
|
|
|
82
|
-
def wrapper(slot: Union[int, str], content: Optional[str]) -> str:
|
|
89
|
+
def wrapper(slot: Union[int, str], content: Optional[str], context) -> str:
|
|
83
90
|
if slot == "type" and content:
|
|
84
91
|
return content
|
|
85
92
|
return "" # pragma: no cover
|
|
@@ -89,13 +96,15 @@ rank_cmd = on_alconna(
|
|
|
89
96
|
Alconna(
|
|
90
97
|
"B话榜",
|
|
91
98
|
Args["type?", ["今日", "昨日", "本周", "上周", "本月", "上月", "年度", "历史"]][
|
|
92
|
-
"time?",
|
|
93
|
-
|
|
99
|
+
"time?",
|
|
100
|
+
str,
|
|
94
101
|
],
|
|
102
|
+
Option("-g|--group_id", Args["group_id?", str]),
|
|
95
103
|
behaviors=[SameTime()],
|
|
96
104
|
),
|
|
97
105
|
aliases={"废话榜"},
|
|
98
106
|
use_cmd_start=True,
|
|
107
|
+
block=True,
|
|
99
108
|
)
|
|
100
109
|
|
|
101
110
|
|
|
@@ -103,7 +112,16 @@ rank_cmd.shortcut(
|
|
|
103
112
|
r"(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)B话榜",
|
|
104
113
|
{
|
|
105
114
|
"prefix": True,
|
|
106
|
-
"command": "B话榜
|
|
115
|
+
"command": "B话榜",
|
|
116
|
+
"wrapper": wrapper,
|
|
117
|
+
"args": ["{type}"],
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
rank_cmd.shortcut(
|
|
121
|
+
r"(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)废话榜",
|
|
122
|
+
{
|
|
123
|
+
"prefix": True,
|
|
124
|
+
"command": "废话榜",
|
|
107
125
|
"wrapper": wrapper,
|
|
108
126
|
"args": ["{type}"],
|
|
109
127
|
},
|
|
@@ -122,10 +140,11 @@ async def _group_message(
|
|
|
122
140
|
|
|
123
141
|
dt = get_datetime_now_with_timezone()
|
|
124
142
|
|
|
125
|
-
if group_id
|
|
143
|
+
if not group_id:
|
|
126
144
|
group_id = session.id2
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
logger.debug(f"session id2: {group_id}")
|
|
146
|
+
if group_id:
|
|
147
|
+
state["group_id"] = group_id
|
|
129
148
|
|
|
130
149
|
if not type:
|
|
131
150
|
await rank_cmd.finish(__plugin_meta__.usage)
|
|
@@ -195,17 +214,19 @@ async def _group_message(
|
|
|
195
214
|
)
|
|
196
215
|
@rank_cmd.got("group_id", prompt="请输入你要查询的群号。")
|
|
197
216
|
async def handle_rank(
|
|
217
|
+
state: T_State,
|
|
198
218
|
bot: Bot,
|
|
199
219
|
event: Event,
|
|
200
220
|
session: Session = Depends(extract_session),
|
|
201
221
|
start: datetime = Arg(),
|
|
202
222
|
stop: datetime = Arg(),
|
|
203
|
-
group_id: str = Arg(),
|
|
204
223
|
):
|
|
205
|
-
if group_id:
|
|
206
|
-
id =
|
|
224
|
+
if id := state["group_id"]:
|
|
225
|
+
id = str(id)
|
|
226
|
+
logger.debug(f"group_id: {id}")
|
|
207
227
|
else:
|
|
208
228
|
id = session.id2
|
|
229
|
+
logger.debug(f"group_id: {id}")
|
|
209
230
|
|
|
210
231
|
if not id:
|
|
211
232
|
await saa.Text("没有指定群哦").finish()
|
|
@@ -220,7 +241,12 @@ async def handle_rank(
|
|
|
220
241
|
time_stop=stop,
|
|
221
242
|
exclude_id1s=plugin_config.excluded_people,
|
|
222
243
|
)
|
|
244
|
+
|
|
245
|
+
if not messages:
|
|
246
|
+
await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish()
|
|
247
|
+
|
|
223
248
|
rank = got_rank(msg_counter(messages))
|
|
249
|
+
logger.debug(rank)
|
|
224
250
|
rank2: List[UserRankInfo] = []
|
|
225
251
|
ids = await persist_id2user_id([int(i[0]) for i in rank])
|
|
226
252
|
for i in range(len(rank)):
|
|
@@ -228,38 +254,51 @@ async def handle_rank(
|
|
|
228
254
|
logger.debug(rank[i])
|
|
229
255
|
|
|
230
256
|
total = sum([i[1] for i in rank])
|
|
231
|
-
|
|
257
|
+
index = 1
|
|
232
258
|
for i in rank:
|
|
233
259
|
if user_info := await get_user_info(bot, event, user_id=str(i[0])):
|
|
234
260
|
logger.debug(user_info)
|
|
235
|
-
user_nickname =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
261
|
+
user_nickname = (
|
|
262
|
+
user_info.user_displayname
|
|
263
|
+
if user_info.user_displayname
|
|
264
|
+
else user_info.user_name if user_info.user_name else user_info.user_id
|
|
265
|
+
)
|
|
266
|
+
user_avatar = (
|
|
267
|
+
await user_info.user_avatar.get_image()
|
|
268
|
+
if user_info.user_avatar
|
|
269
|
+
else open(
|
|
270
|
+
os.path.dirname(os.path.abspath(__file__))
|
|
271
|
+
+ "/template/avatar/default.jpg",
|
|
272
|
+
"rb",
|
|
273
|
+
).read()
|
|
274
|
+
)
|
|
275
|
+
user = UserRankInfo(
|
|
276
|
+
**model_dump(user_info),
|
|
277
|
+
user_bnum=i[1],
|
|
278
|
+
user_proportion=round(i[1] / total * 100, 2),
|
|
279
|
+
user_index=cn2an.an2cn(index),
|
|
280
|
+
user_nickname=user_nickname,
|
|
281
|
+
user_avatar_bytes=user_avatar,
|
|
282
|
+
)
|
|
283
|
+
user.user_gender = (
|
|
284
|
+
"她"
|
|
285
|
+
if user_info.user_gender == "female"
|
|
286
|
+
else "他" if user_info.user_gender == "male" else "ta"
|
|
250
287
|
)
|
|
251
|
-
user.user_gender="她" if user_info.user_gender == "female" else "他" if user_info.user_gender == "male" else "ta"
|
|
252
288
|
rank2.append(user)
|
|
253
|
-
|
|
289
|
+
index += 1
|
|
290
|
+
|
|
254
291
|
string: str = ""
|
|
255
|
-
for i in
|
|
292
|
+
for i in rank2:
|
|
293
|
+
logger.debug(i.user_name)
|
|
294
|
+
for i in range(len(rank2)):
|
|
256
295
|
str_example = plugin_config.string_format.format(
|
|
257
|
-
index=rank2[i].user_index,
|
|
258
|
-
nickname=rank2[i].user_nickname,
|
|
259
|
-
chatdatanum=rank2[i].user_bnum
|
|
296
|
+
index=rank2[i].user_index,
|
|
297
|
+
nickname=rank2[i].user_nickname,
|
|
298
|
+
chatdatanum=rank2[i].user_bnum,
|
|
260
299
|
)
|
|
261
300
|
string += str_example
|
|
262
|
-
|
|
301
|
+
|
|
263
302
|
image = await get_rank_image(rank2)
|
|
264
303
|
|
|
265
304
|
await (saa.Text(string) + saa.Image(image)).finish(reply=True)
|
|
@@ -16,7 +16,7 @@ from nonebot_plugin_orm import get_session
|
|
|
16
16
|
from nonebot_plugin_session import Session, SessionLevel, extract_session
|
|
17
17
|
from nonebot_plugin_session_orm import SessionModel
|
|
18
18
|
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
|
19
|
-
from nonebot_plugin_htmlrender import html_to_pic,template_to_pic
|
|
19
|
+
from nonebot_plugin_htmlrender import html_to_pic, template_to_pic
|
|
20
20
|
from nonebot_plugin_apscheduler import scheduler
|
|
21
21
|
from nonebot_plugin_chatrecorder import MessageRecord
|
|
22
22
|
from nonebot_plugin_localstore import get_cache_dir
|
|
@@ -46,27 +46,45 @@ async def ensure_group(matcher: Matcher, session: Session = Depends(extract_sess
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
async def persist_id2user_id(ids: List) -> List[str]:
|
|
49
|
+
user_ids = []
|
|
50
|
+
async with get_session() as db_session:
|
|
51
|
+
for i in ids:
|
|
52
|
+
user_id = (await db_session.scalar(select(SessionModel).where(or_(*[SessionModel.id == i])))).id1 # type: ignore
|
|
53
|
+
user_ids.append(user_id)
|
|
54
|
+
return user_ids
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def user_id2persist_id(ids: List[str]) -> List[int]:
|
|
49
58
|
whereclause: List[ColumnElement[bool]] = []
|
|
50
|
-
whereclause.append(or_(*[SessionModel.
|
|
59
|
+
whereclause.append(or_(*[SessionModel.id1 == id for id in ids]))
|
|
51
60
|
statement = (
|
|
52
61
|
select(SessionModel).where(*whereclause)
|
|
53
62
|
# .join(SessionModel, SessionModel.id == MessageRecord.session_persist_id)
|
|
54
63
|
)
|
|
55
64
|
async with get_session() as db_session:
|
|
56
65
|
records = (await db_session.scalars(statement)).all()
|
|
57
|
-
return [i.
|
|
66
|
+
return [i.id for i in records]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
async def group_id2persist_id(ids: List[str]) -> List[int]:
|
|
70
|
+
persist_ids = []
|
|
71
|
+
async with get_session() as db_session:
|
|
72
|
+
for i in ids:
|
|
73
|
+
persist_id = (await db_session.scalar(select(SessionModel).where(or_(*[SessionModel.id2 == i])))).id # type: ignore
|
|
74
|
+
persist_ids.append(persist_id)
|
|
75
|
+
return persist_ids
|
|
58
76
|
|
|
59
77
|
|
|
60
|
-
async def
|
|
78
|
+
async def persist_id2group_id(ids: List[str]) -> List[str]:
|
|
61
79
|
whereclause: List[ColumnElement[bool]] = []
|
|
62
|
-
whereclause.append(or_(*[SessionModel.
|
|
80
|
+
whereclause.append(or_(*[SessionModel.id == id for id in ids]))
|
|
63
81
|
statement = (
|
|
64
82
|
select(SessionModel).where(*whereclause)
|
|
65
83
|
# .join(SessionModel, SessionModel.id == MessageRecord.session_persist_id)
|
|
66
84
|
)
|
|
67
85
|
async with get_session() as db_session:
|
|
68
86
|
records = (await db_session.scalars(statement)).all()
|
|
69
|
-
return records
|
|
87
|
+
return [i.id2 for i in records]
|
|
70
88
|
|
|
71
89
|
|
|
72
90
|
def msg_counter(msg_list: List[MessageRecord]) -> Dict[str, int]:
|
|
@@ -119,6 +137,7 @@ def got_rank(msg_dict: Dict[str, int]) -> List:
|
|
|
119
137
|
|
|
120
138
|
return rank
|
|
121
139
|
|
|
140
|
+
|
|
122
141
|
def remove_control_characters(string: str) -> str:
|
|
123
142
|
"""### 将字符串中的控制符去除
|
|
124
143
|
|
|
@@ -130,27 +149,40 @@ def remove_control_characters(string: str) -> str:
|
|
|
130
149
|
"""
|
|
131
150
|
return "".join(ch for ch in string if unicodedata.category(ch)[0] != "C")
|
|
132
151
|
|
|
152
|
+
|
|
133
153
|
async def get_rank_image(rank: List[UserRankInfo]) -> bytes:
|
|
134
154
|
for i in rank:
|
|
135
155
|
if i.user_avatar:
|
|
136
156
|
try:
|
|
137
157
|
user_avatar = i.user_avatar_bytes
|
|
138
158
|
except NotImplementedError:
|
|
139
|
-
user_avatar = open(
|
|
159
|
+
user_avatar = open(
|
|
160
|
+
os.path.dirname(os.path.abspath(__file__))
|
|
161
|
+
+ "/template/avatar/default.jpg",
|
|
162
|
+
"rb",
|
|
163
|
+
).read()
|
|
140
164
|
# if not os.path.exists(cache_path / str(i.user_id)):
|
|
141
165
|
with open(cache_path / (str(i.user_id) + ".jpg"), "wb") as f:
|
|
142
166
|
f.write(user_avatar)
|
|
143
|
-
|
|
144
|
-
if plugin_config.template_path[:2] ==
|
|
145
|
-
path =
|
|
167
|
+
|
|
168
|
+
if plugin_config.template_path[:2] == "./":
|
|
169
|
+
path = (
|
|
170
|
+
os.path.dirname(os.path.abspath(__file__)) + plugin_config.template_path[1:]
|
|
171
|
+
)
|
|
146
172
|
else:
|
|
147
173
|
path = plugin_config.template_path
|
|
148
|
-
|
|
174
|
+
|
|
149
175
|
path_dir, filename = os.path.split(path)
|
|
150
|
-
logger.debug(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
176
|
+
logger.debug(
|
|
177
|
+
os.path.dirname(os.path.abspath(__file__)) + plugin_config.template_path[1:]
|
|
178
|
+
)
|
|
179
|
+
return await template_to_pic(
|
|
180
|
+
path_dir,
|
|
181
|
+
filename,
|
|
182
|
+
{
|
|
183
|
+
"users": rank,
|
|
184
|
+
"cache_path": cache_path,
|
|
185
|
+
"file_path": os.path.dirname(os.path.abspath(__file__)),
|
|
186
|
+
},
|
|
187
|
+
pages={"viewport": {"width": 1100, "height": 10}},
|
|
188
|
+
)
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
7
|
-
Requires-Python: <4.0,>=3.
|
|
7
|
+
Requires-Python: <4.0,>=3.9
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
|
-
Requires-Dist: nonebot2>=2.3.1
|
|
10
9
|
Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
|
|
11
|
-
Requires-Dist: pygal>=3.0.4
|
|
12
10
|
Requires-Dist: requests>=2.32.3
|
|
13
11
|
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
14
|
-
Requires-Dist: nonebot-plugin-alconna>=0.
|
|
12
|
+
Requires-Dist: nonebot-plugin-alconna>=0.50.2
|
|
15
13
|
Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
16
14
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.4
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: nonebot-plugin-htmlrender>=0.3.3
|
|
16
|
+
Requires-Dist: nonebot2>=2.3.2
|
|
17
|
+
Requires-Dist: cn2an>=0.5.22
|
|
19
18
|
Provides-Extra: dev
|
|
20
|
-
Requires-Dist: ruff>=0.
|
|
21
|
-
Requires-Dist: setuptools>=
|
|
19
|
+
Requires-Dist: ruff>=0.5.5; extra == "dev"
|
|
20
|
+
Requires-Dist: setuptools>=71.1.0; extra == "dev"
|
|
22
21
|
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
23
22
|
Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: nonebot-adapter-onebot>=2.4.4; extra == "test"
|
|
24
25
|
|
|
25
26
|
<div align="center">
|
|
26
27
|
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
@@ -34,8 +35,8 @@ Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
|
34
35
|
nonebot-plugin-dialectlist
|
|
35
36
|
|
|
36
37
|
<p align="center">
|
|
37
|
-
<a href="https://pypi.python.org/pypi/nonebot-plugin-
|
|
38
|
-
<img src="https://img.shields.io/pypi/v/nonebot-plugin-
|
|
38
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-dialectlist">
|
|
39
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
39
40
|
</a>
|
|
40
41
|
|
|
41
42
|
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
@@ -79,8 +80,8 @@ dialectlist__string_suffix_format = '你们的职业是水群吗?————M
|
|
|
79
80
|
dialectlist__get_num = 10 #获取人数数量
|
|
80
81
|
dialectlist__visualization = True #是否可视化
|
|
81
82
|
dialectlist__visualization_type = '圆环图' #可视化方案
|
|
82
|
-
dialectlist__font = 'SimHei'#字体格式
|
|
83
|
-
dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
|
|
83
|
+
dialectlist__font = 'SimHei' #字体格式
|
|
84
|
+
dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
|
|
84
85
|
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
|
85
86
|
```
|
|
86
87
|
💭也可以不进行配置,这将会使插件按照默认配置运行
|
|
@@ -191,11 +192,23 @@ __!!注意!!__
|
|
|
191
192
|
|
|
192
193
|
- [x] 适配全平台
|
|
193
194
|
|
|
194
|
-
- [
|
|
195
|
+
- [x] 尝试利用 jinja2 模板引擎制作可视化图片
|
|
195
196
|
|
|
196
|
-
- [ ]
|
|
197
|
+
- [ ] 更好看的图片渲染
|
|
198
|
+
|
|
199
|
+
- [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
|
|
200
|
+
- [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
|
|
201
|
+
|
|
202
|
+
- [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
|
|
203
|
+
|
|
204
|
+
- [ ] 查询带某关键词的消息量
|
|
205
|
+
|
|
206
|
+
- [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
|
|
207
|
+
|
|
208
|
+
- [ ] 特殊的储存方案优化消息统计
|
|
209
|
+
|
|
210
|
+
- [ ] 添加一些全新的可配置项
|
|
197
211
|
|
|
198
|
-
- [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
|
|
199
212
|
|
|
200
213
|
待补充。.....
|
|
201
214
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
nonebot2>=2.3.1
|
|
2
1
|
nonebot-plugin-chatrecorder>=0.6.0
|
|
3
|
-
pygal>=3.0.4
|
|
4
2
|
requests>=2.32.3
|
|
5
3
|
nonebot-plugin-apscheduler>=0.4.0
|
|
6
|
-
nonebot-plugin-alconna>=0.
|
|
4
|
+
nonebot-plugin-alconna>=0.50.2
|
|
7
5
|
nonebot-plugin-cesaa>=0.4.0
|
|
8
6
|
nonebot-plugin-userinfo>=0.2.4
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
nonebot-plugin-htmlrender>=0.3.3
|
|
8
|
+
nonebot2>=2.3.2
|
|
9
|
+
cn2an>=0.5.22
|
|
10
|
+
|
|
11
|
+
[Test]
|
|
12
|
+
nonebot-adapter-onebot>=2.4.4
|
|
11
13
|
|
|
12
14
|
[dev]
|
|
13
|
-
ruff>=0.
|
|
14
|
-
setuptools>=
|
|
15
|
+
ruff>=0.5.5
|
|
16
|
+
setuptools>=71.1.0
|
|
15
17
|
twine>=5.1.0
|
|
16
18
|
nb-cli>=0.7.6
|
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-dialectlist"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.2.0"
|
|
4
4
|
description = "看看你群群友有多能说"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
|
7
7
|
]
|
|
8
8
|
dependencies = [
|
|
9
|
-
"nonebot2>=2.3.1",
|
|
10
9
|
"nonebot-plugin-chatrecorder>=0.6.0",
|
|
11
|
-
"pygal>=3.0.4",
|
|
12
10
|
"requests>=2.32.3",
|
|
13
11
|
"nonebot-plugin-apscheduler>=0.4.0",
|
|
14
|
-
"nonebot-plugin-alconna>=0.
|
|
12
|
+
"nonebot-plugin-alconna>=0.50.2",
|
|
15
13
|
"nonebot-plugin-cesaa>=0.4.0",
|
|
16
14
|
"nonebot-plugin-userinfo>=0.2.4",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
15
|
+
"nonebot-plugin-htmlrender>=0.3.3",
|
|
16
|
+
"nonebot2>=2.3.2",
|
|
17
|
+
"cn2an>=0.5.22"
|
|
19
18
|
]
|
|
20
|
-
requires-python = ">=3.
|
|
19
|
+
requires-python = ">=3.9,<4.0"
|
|
21
20
|
readme = "README.md"
|
|
22
21
|
license = {text = "MIT"}
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
[project.optional-dependencies]
|
|
26
25
|
dev = [
|
|
27
|
-
"ruff>=0.
|
|
28
|
-
"setuptools>=
|
|
26
|
+
"ruff>=0.5.5",
|
|
27
|
+
"setuptools>=71.1.0",
|
|
29
28
|
"twine>=5.1.0",
|
|
30
29
|
"nb-cli>=0.7.6"
|
|
31
30
|
]
|
|
31
|
+
Test = [
|
|
32
|
+
"nonebot-adapter-onebot>=2.4.4",
|
|
33
|
+
]
|
|
32
34
|
|
|
33
35
|
[tool.pdm]
|
|
34
36
|
distribution = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|