nonebot-plugin-dialectlist 2.1.9__tar.gz → 2.2.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 (21) hide show
  1. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/PKG-INFO +19 -19
  2. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/README.md +18 -18
  3. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/__init__.py +62 -39
  4. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/config.py +2 -1
  5. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/model.py +2 -2
  6. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/utils.py +36 -22
  7. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +19 -19
  8. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/pyproject.toml +1 -1
  9. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/MANIFEST.in +0 -0
  10. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/storage.py +0 -0
  11. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
  12. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/template/avatar/master.jpg +0 -0
  13. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
  14. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
  15. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/time.py +0 -0
  16. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist/usage.py +0 -0
  17. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -0
  18. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
  19. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -0
  20. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
  21. {nonebot_plugin_dialectlist-2.1.9 → nonebot_plugin_dialectlist-2.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.1.9
3
+ Version: 2.2.1
4
4
  Summary: 看看你群群友有多能说
5
5
  Author-email: Chen_Xu233 <woyerpa@outlook.com>
6
6
  License: MIT
@@ -76,13 +76,14 @@ nonebot-plugin-dialectlist
76
76
  在 .env 中,可以添加以下配置项
77
77
  ```python
78
78
  dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
79
- dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
80
79
  dialectlist__get_num = 10 #获取人数数量
81
80
  dialectlist__visualization = True #是否可视化
82
- dialectlist__visualization_type = '圆环图' #可视化方案
81
+ # dialectlist__visualization_type = '圆环图' #可视化方案 (不再支持)
83
82
  dialectlist__font = 'SimHei' #字体格式
84
83
  dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
85
84
  dialectlist__excluded_self = True #是否排除机器人自己 QQ
85
+ dialectlist__suffix: bool = False # 是否显示后缀
86
+ dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式后缀
86
87
  ```
87
88
  💭也可以不进行配置,这将会使插件按照默认配置运行
88
89
 
@@ -93,34 +94,33 @@ dialectlist__excluded_self = True #是否排除机器人自己 QQ
93
94
  ## 🗨命令
94
95
  __!!注意!!__
95
96
  新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
96
- 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给[盘古之白](https://github.com/vinta/pangu.js)风格爱好者的福利吧?)
97
+ 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给 [盘古之白](https://github.com/vinta/pangu.js) 风格爱好者的福利吧?)
97
98
 
98
99
  ### 🎨一般用法
99
100
 
100
- -`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
101
+ -`/B 话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
101
102
 
102
- -`/今日B话榜` ————看看今天的群友发了多少消息!
103
+ -`/今日 B 话榜` ————看看今天的群友发了多少消息!
103
104
 
104
- -`/昨日B话榜` ————看看昨天的群友发了多少消息!
105
+ -`/昨日 B 话榜` ————看看昨天的群友发了多少消息!
105
106
 
106
- -`/前日B话榜` ————看看前天的群友发了多少消息!
107
+ -`/前日 B 话榜` ————看看前天的群友发了多少消息!
107
108
 
108
- -`/本周B话榜` ————看看本周的群友发了多少消息!
109
+ -`/本周 B 话榜` ————看看本周的群友发了多少消息!
109
110
 
110
- -`/上周B话榜` ————看看上周的群友发了多少消息!
111
+ -`/上周 B 话榜` ————看看上周的群友发了多少消息!
111
112
 
112
- -`/本月B话榜` ————看看这个月的群友发了多少消息!
113
+ -`/本月 B 话榜` ————看看这个月的群友发了多少消息!
113
114
 
114
- -`/年度B话榜` ————看看今年的群友发了多少消息!
115
+ -`/年度 B 话榜` ————看看今年的群友发了多少消息!
115
116
 
116
- -`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
117
+ -`/历史 B 话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
117
118
 
118
119
  ### 🚀进阶用法
119
120
 
120
- `/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601格式时间} {群号}`
121
-
122
- 如:`/B话榜 历史 2024-01-01~2024-01-02 12345678`
121
+ `/{时间类型(今日|年度)?}{B 话榜|废话榜} {时间类型?} {ISO8601 格式时间} {群号}`
123
122
 
123
+ 如:`/B 话榜 历史 2024-01-01~2024-01-02 12345678`
124
124
 
125
125
  ## 📖版本
126
126
 
@@ -196,14 +196,14 @@ __!!注意!!__
196
196
 
197
197
  - [ ] 更好看的图片渲染
198
198
 
199
- - [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
200
- - [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
199
+ - [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
200
+ - [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
201
201
 
202
202
  - [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
203
203
 
204
204
  - [ ] 查询带某关键词的消息量
205
205
 
206
- - [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
206
+ - [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
207
207
 
208
208
  - [ ] 特殊的储存方案优化消息统计
209
209
 
@@ -51,13 +51,14 @@ nonebot-plugin-dialectlist
51
51
  在 .env 中,可以添加以下配置项
52
52
  ```python
53
53
  dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
54
- dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
55
54
  dialectlist__get_num = 10 #获取人数数量
56
55
  dialectlist__visualization = True #是否可视化
57
- dialectlist__visualization_type = '圆环图' #可视化方案
56
+ # dialectlist__visualization_type = '圆环图' #可视化方案 (不再支持)
58
57
  dialectlist__font = 'SimHei' #字体格式
59
58
  dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
60
59
  dialectlist__excluded_self = True #是否排除机器人自己 QQ
60
+ dialectlist__suffix: bool = False # 是否显示后缀
61
+ dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式后缀
61
62
  ```
62
63
  💭也可以不进行配置,这将会使插件按照默认配置运行
63
64
 
@@ -68,34 +69,33 @@ dialectlist__excluded_self = True #是否排除机器人自己 QQ
68
69
  ## 🗨命令
69
70
  __!!注意!!__
70
71
  新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
71
- 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给[盘古之白](https://github.com/vinta/pangu.js)风格爱好者的福利吧?)
72
+ 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给 [盘古之白](https://github.com/vinta/pangu.js) 风格爱好者的福利吧?)
72
73
 
73
74
  ### 🎨一般用法
74
75
 
75
- -`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
76
+ -`/B 话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
76
77
 
77
- -`/今日B话榜` ————看看今天的群友发了多少消息!
78
+ -`/今日 B 话榜` ————看看今天的群友发了多少消息!
78
79
 
79
- -`/昨日B话榜` ————看看昨天的群友发了多少消息!
80
+ -`/昨日 B 话榜` ————看看昨天的群友发了多少消息!
80
81
 
81
- -`/前日B话榜` ————看看前天的群友发了多少消息!
82
+ -`/前日 B 话榜` ————看看前天的群友发了多少消息!
82
83
 
83
- -`/本周B话榜` ————看看本周的群友发了多少消息!
84
+ -`/本周 B 话榜` ————看看本周的群友发了多少消息!
84
85
 
85
- -`/上周B话榜` ————看看上周的群友发了多少消息!
86
+ -`/上周 B 话榜` ————看看上周的群友发了多少消息!
86
87
 
87
- -`/本月B话榜` ————看看这个月的群友发了多少消息!
88
+ -`/本月 B 话榜` ————看看这个月的群友发了多少消息!
88
89
 
89
- -`/年度B话榜` ————看看今年的群友发了多少消息!
90
+ -`/年度 B 话榜` ————看看今年的群友发了多少消息!
90
91
 
91
- -`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
92
+ -`/历史 B 话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
92
93
 
93
94
  ### 🚀进阶用法
94
95
 
95
- `/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601格式时间} {群号}`
96
-
97
- 如:`/B话榜 历史 2024-01-01~2024-01-02 12345678`
96
+ `/{时间类型(今日|年度)?}{B 话榜|废话榜} {时间类型?} {ISO8601 格式时间} {群号}`
98
97
 
98
+ 如:`/B 话榜 历史 2024-01-01~2024-01-02 12345678`
99
99
 
100
100
  ## 📖版本
101
101
 
@@ -171,14 +171,14 @@ __!!注意!!__
171
171
 
172
172
  - [ ] 更好看的图片渲染
173
173
 
174
- - [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
175
- - [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
174
+ - [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
175
+ - [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
176
176
 
177
177
  - [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
178
178
 
179
179
  - [ ] 查询带某关键词的消息量
180
180
 
181
- - [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
181
+ - [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
182
182
 
183
183
  - [ ] 特殊的储存方案优化消息统计
184
184
 
@@ -10,6 +10,7 @@ require("nonebot_plugin_cesaa")
10
10
  import re
11
11
  import os
12
12
  import cn2an
13
+ import time as t
13
14
  import nonebot_plugin_saa as saa
14
15
 
15
16
  from typing import Union, Optional, List
@@ -41,8 +42,6 @@ from nonebot_plugin_alconna import (
41
42
  )
42
43
 
43
44
  from nonebot_plugin_chatrecorder import get_message_records
44
- from nonebot_plugin_localstore import get_cache_file
45
- from nonebot_plugin_htmlrender import html_to_pic
46
45
  from nonebot_plugin_userinfo import get_user_info
47
46
  from nonebot_plugin_session import Session, SessionIdType, extract_session
48
47
 
@@ -50,14 +49,19 @@ from nonebot_plugin_session import Session, SessionIdType, extract_session
50
49
  # from .function import *
51
50
  from .config import Config, plugin_config
52
51
  from .usage import __usage__
53
- from .time import get_datetime_fromisoformat_with_timezone, get_datetime_now_with_timezone,parse_datetime
52
+ from .time import (
53
+ get_datetime_fromisoformat_with_timezone,
54
+ get_datetime_now_with_timezone,
55
+ parse_datetime,
56
+ )
54
57
  from .model import UserRankInfo
55
58
  from .utils import (
56
59
  got_rank,
57
60
  msg_counter,
58
61
  persist_id2user_id,
59
62
  user_id2persist_id,
60
- get_rank_image
63
+ group_id2persist_id,
64
+ get_rank_image,
61
65
  )
62
66
 
63
67
  __plugin_meta__ = PluginMetadata(
@@ -83,17 +87,20 @@ class SameTime(ArparmaBehavior):
83
87
  interface.behave_fail()
84
88
 
85
89
 
86
- def wrapper(slot: Union[int, str], content: Optional[str],context) -> str:
90
+ def wrapper(slot: Union[int, str], content: Optional[str], context) -> str:
87
91
  if slot == "type" and content:
88
92
  return content
89
93
  return "" # pragma: no cover
90
94
 
95
+
91
96
  rank_cmd = on_alconna(
92
97
  Alconna(
93
98
  "B话榜",
94
99
  Args["type?", ["今日", "昨日", "本周", "上周", "本月", "上月", "年度", "历史"]][
95
- "time?",str,],
96
- Option("-g|--group_id",Args["group_id?", str]),
100
+ "time?",
101
+ str,
102
+ ],
103
+ Option("-g|--group_id", Args["group_id?", str]),
97
104
  behaviors=[SameTime()],
98
105
  ),
99
106
  aliases={"废话榜"},
@@ -131,7 +138,8 @@ async def _group_message(
131
138
  time: Optional[str] = None,
132
139
  group_id: Optional[str] = None,
133
140
  ):
134
-
141
+ t1 = t.time()
142
+ state["t1"] = t1
135
143
  dt = get_datetime_now_with_timezone()
136
144
 
137
145
  if not group_id:
@@ -206,10 +214,7 @@ async def _group_message(
206
214
  prompt="请输入你要查询的结束日期(如 2022-02-22)",
207
215
  parameterless=[Depends(parse_datetime("stop"))],
208
216
  )
209
- @rank_cmd.got(
210
- "group_id",
211
- prompt="请输入你要查询的群号。"
212
- )
217
+ @rank_cmd.got("group_id", prompt="请输入你要查询的群号。")
213
218
  async def handle_rank(
214
219
  state: T_State,
215
220
  bot: Bot,
@@ -217,10 +222,9 @@ async def handle_rank(
217
222
  session: Session = Depends(extract_session),
218
223
  start: datetime = Arg(),
219
224
  stop: datetime = Arg(),
220
- # group_id: str = Arg(),
221
225
  ):
222
226
  if id := state["group_id"]:
223
- # id = await user_id2persist_id(id)
227
+ id = str(id)
224
228
  logger.debug(f"group_id: {id}")
225
229
  else:
226
230
  id = session.id2
@@ -239,10 +243,10 @@ async def handle_rank(
239
243
  time_stop=stop,
240
244
  exclude_id1s=plugin_config.excluded_people,
241
245
  )
242
-
246
+
243
247
  if not messages:
244
248
  await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish()
245
-
249
+
246
250
  rank = got_rank(msg_counter(messages))
247
251
  logger.debug(rank)
248
252
  rank2: List[UserRankInfo] = []
@@ -256,37 +260,56 @@ async def handle_rank(
256
260
  for i in rank:
257
261
  if user_info := await get_user_info(bot, event, user_id=str(i[0])):
258
262
  logger.debug(user_info)
259
- user_nickname = user_info.user_displayname\
260
- if user_info.user_displayname\
261
- else user_info.user_name\
262
- if user_info.user_name\
263
- else\
264
- user_info.user_id
265
- user_avatar = await user_info.user_avatar.get_image()\
266
- if user_info.user_avatar\
267
- else open(os.path.dirname(os.path.abspath(__file__))+"/template/avatar/default.jpg", "rb").read()
268
- user = UserRankInfo(**model_dump(user_info),
269
- user_bnum=i[1],
270
- user_proportion= round(i[1] / total * 100, 2),
271
- user_index= cn2an.an2cn(index),
272
- user_nickname= user_nickname,
273
- user_avatar_bytes= user_avatar,
263
+ user_nickname = (
264
+ user_info.user_displayname
265
+ if user_info.user_displayname
266
+ else user_info.user_name if user_info.user_name else user_info.user_id
267
+ )
268
+ user_avatar = (
269
+ await user_info.user_avatar.get_image()
270
+ if user_info.user_avatar
271
+ else open(
272
+ os.path.dirname(os.path.abspath(__file__))
273
+ + "/template/avatar/default.jpg",
274
+ "rb",
275
+ ).read()
276
+ )
277
+ user = UserRankInfo(
278
+ **model_dump(user_info),
279
+ user_bnum=i[1],
280
+ user_proportion=round(i[1] / total * 100, 2),
281
+ user_index=cn2an.an2cn(index),
282
+ user_nickname=user_nickname,
283
+ user_avatar_bytes=user_avatar,
284
+ )
285
+ user.user_gender = (
286
+ "她"
287
+ if user_info.user_gender == "female"
288
+ else "他" if user_info.user_gender == "male" else "ta"
274
289
  )
275
- user.user_gender="她" if user_info.user_gender == "female" else "他" if user_info.user_gender == "male" else "ta"
276
290
  rank2.append(user)
277
291
  index += 1
278
-
292
+
279
293
  string: str = ""
280
294
  for i in rank2:
281
295
  logger.debug(i.user_name)
282
296
  for i in range(len(rank2)):
283
297
  str_example = plugin_config.string_format.format(
284
- index=rank2[i].user_index,
285
- nickname=rank2[i].user_nickname,
286
- chatdatanum=rank2[i].user_bnum
298
+ index=rank2[i].user_index,
299
+ nickname=rank2[i].user_nickname,
300
+ chatdatanum=rank2[i].user_bnum,
287
301
  )
288
302
  string += str_example
289
303
 
290
- image = await get_rank_image(rank2)
291
-
292
- await (saa.Text(string) + saa.Image(image)).finish(reply=True)
304
+ msg = saa.Text(string)
305
+
306
+ if plugin_config.visualization:
307
+ image = await get_rank_image(rank2)
308
+ msg += saa.Image(image)
309
+
310
+ if plugin_config.suffix:
311
+ timecost = t.time() - state["t1"]
312
+ suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost))
313
+ msg += suffix
314
+
315
+ await msg.finish(reply=True)
@@ -12,7 +12,8 @@ class ScopedConfig(BaseModel):
12
12
  template_path: str = "./template/rank_template.j2" # 模板路径
13
13
  visualization: bool = True # 是否可视化
14
14
  excluded_people: List[str] = [] # 排除的人的QQ号
15
- visualization_type: Literal["饼图", "圆环图", "柱状图"] = "圆环图" # 可视化方案
15
+ suffix: bool = False # 是否显示后缀
16
+ string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
16
17
 
17
18
 
18
19
  class Config(BaseModel):
@@ -7,5 +7,5 @@ class UserRankInfo(UserInfo):
7
7
  user_bnum: int
8
8
  user_proportion: float
9
9
  user_nickname: str
10
- user_index: Union[int,str]
11
- user_avatar_bytes: bytes
10
+ user_index: Union[int, str]
11
+ user_avatar_bytes: bytes
@@ -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
@@ -49,7 +49,7 @@ async def persist_id2user_id(ids: List) -> List[str]:
49
49
  user_ids = []
50
50
  async with get_session() as db_session:
51
51
  for i in ids:
52
- user_id = (await db_session.scalar(select(SessionModel).where(or_(*[SessionModel.id == i])))).id1 # type: ignore
52
+ user_id = (await db_session.scalar(select(SessionModel).where(or_(*[SessionModel.id == i])))).id1 # type: ignore
53
53
  user_ids.append(user_id)
54
54
  return user_ids
55
55
 
@@ -65,16 +65,15 @@ async def user_id2persist_id(ids: List[str]) -> List[int]:
65
65
  records = (await db_session.scalars(statement)).all()
66
66
  return [i.id for i in records]
67
67
 
68
+
68
69
  async def group_id2persist_id(ids: List[str]) -> List[int]:
69
- whereclause: List[ColumnElement[bool]] = []
70
- whereclause.append(or_(*[SessionModel.id2 == id for id in ids]))
71
- statement = (
72
- select(SessionModel).where(*whereclause)
73
- # .join(SessionModel, SessionModel.id == MessageRecord.session_persist_id)
74
- )
70
+ persist_ids = []
75
71
  async with get_session() as db_session:
76
- records = (await db_session.scalars(statement)).all()
77
- return [i.id for i in records]
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
76
+
78
77
 
79
78
  async def persist_id2group_id(ids: List[str]) -> List[str]:
80
79
  whereclause: List[ColumnElement[bool]] = []
@@ -87,6 +86,7 @@ async def persist_id2group_id(ids: List[str]) -> List[str]:
87
86
  records = (await db_session.scalars(statement)).all()
88
87
  return [i.id2 for i in records]
89
88
 
89
+
90
90
  def msg_counter(msg_list: List[MessageRecord]) -> Dict[str, int]:
91
91
  """### 计算每个人的消息量
92
92
 
@@ -137,6 +137,7 @@ def got_rank(msg_dict: Dict[str, int]) -> List:
137
137
 
138
138
  return rank
139
139
 
140
+
140
141
  def remove_control_characters(string: str) -> str:
141
142
  """### 将字符串中的控制符去除
142
143
 
@@ -148,27 +149,40 @@ def remove_control_characters(string: str) -> str:
148
149
  """
149
150
  return "".join(ch for ch in string if unicodedata.category(ch)[0] != "C")
150
151
 
152
+
151
153
  async def get_rank_image(rank: List[UserRankInfo]) -> bytes:
152
154
  for i in rank:
153
155
  if i.user_avatar:
154
156
  try:
155
157
  user_avatar = i.user_avatar_bytes
156
158
  except NotImplementedError:
157
- user_avatar = open(os.path.dirname(os.path.abspath(__file__))+"/template/avatar/default.jpg", "rb").read()
159
+ user_avatar = open(
160
+ os.path.dirname(os.path.abspath(__file__))
161
+ + "/template/avatar/default.jpg",
162
+ "rb",
163
+ ).read()
158
164
  # if not os.path.exists(cache_path / str(i.user_id)):
159
165
  with open(cache_path / (str(i.user_id) + ".jpg"), "wb") as f:
160
166
  f.write(user_avatar)
161
-
162
- if plugin_config.template_path[:2] == './':
163
- path = os.path.dirname(os.path.abspath(__file__)) + plugin_config.template_path[1:]
167
+
168
+ if plugin_config.template_path[:2] == "./":
169
+ path = (
170
+ os.path.dirname(os.path.abspath(__file__)) + plugin_config.template_path[1:]
171
+ )
164
172
  else:
165
173
  path = plugin_config.template_path
166
-
174
+
167
175
  path_dir, filename = os.path.split(path)
168
- logger.debug(os.path.dirname(os.path.abspath(__file__)) + plugin_config.template_path[1:])
169
- return await template_to_pic(path_dir,
170
- filename,
171
- {'users': rank,
172
- 'cache_path': cache_path,
173
- 'file_path': os.path.dirname(os.path.abspath(__file__))},
174
- pages={"viewport": {"width": 1366, "height": 10}})
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.1.9
3
+ Version: 2.2.1
4
4
  Summary: 看看你群群友有多能说
5
5
  Author-email: Chen_Xu233 <woyerpa@outlook.com>
6
6
  License: MIT
@@ -76,13 +76,14 @@ nonebot-plugin-dialectlist
76
76
  在 .env 中,可以添加以下配置项
77
77
  ```python
78
78
  dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
79
- dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
80
79
  dialectlist__get_num = 10 #获取人数数量
81
80
  dialectlist__visualization = True #是否可视化
82
- dialectlist__visualization_type = '圆环图' #可视化方案
81
+ # dialectlist__visualization_type = '圆环图' #可视化方案 (不再支持)
83
82
  dialectlist__font = 'SimHei' #字体格式
84
83
  dialectlist__excluded_people = [] #排除的人的 QQ 号(或频道号?(未经测试))
85
84
  dialectlist__excluded_self = True #是否排除机器人自己 QQ
85
+ dialectlist__suffix: bool = False # 是否显示后缀
86
+ dialectlist__string_suffix: str = "统计花费时间{timecost}" # 消息格式后缀
86
87
  ```
87
88
  💭也可以不进行配置,这将会使插件按照默认配置运行
88
89
 
@@ -93,34 +94,33 @@ dialectlist__excluded_self = True #是否排除机器人自己 QQ
93
94
  ## 🗨命令
94
95
  __!!注意!!__
95
96
  新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
96
- 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给[盘古之白](https://github.com/vinta/pangu.js)风格爱好者的福利吧?)
97
+ 同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给 [盘古之白](https://github.com/vinta/pangu.js) 风格爱好者的福利吧?)
97
98
 
98
99
  ### 🎨一般用法
99
100
 
100
- -`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
101
+ -`/B 话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
101
102
 
102
- -`/今日B话榜` ————看看今天的群友发了多少消息!
103
+ -`/今日 B 话榜` ————看看今天的群友发了多少消息!
103
104
 
104
- -`/昨日B话榜` ————看看昨天的群友发了多少消息!
105
+ -`/昨日 B 话榜` ————看看昨天的群友发了多少消息!
105
106
 
106
- -`/前日B话榜` ————看看前天的群友发了多少消息!
107
+ -`/前日 B 话榜` ————看看前天的群友发了多少消息!
107
108
 
108
- -`/本周B话榜` ————看看本周的群友发了多少消息!
109
+ -`/本周 B 话榜` ————看看本周的群友发了多少消息!
109
110
 
110
- -`/上周B话榜` ————看看上周的群友发了多少消息!
111
+ -`/上周 B 话榜` ————看看上周的群友发了多少消息!
111
112
 
112
- -`/本月B话榜` ————看看这个月的群友发了多少消息!
113
+ -`/本月 B 话榜` ————看看这个月的群友发了多少消息!
113
114
 
114
- -`/年度B话榜` ————看看今年的群友发了多少消息!
115
+ -`/年度 B 话榜` ————看看今年的群友发了多少消息!
115
116
 
116
- -`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
117
+ -`/历史 B 话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
117
118
 
118
119
  ### 🚀进阶用法
119
120
 
120
- `/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601格式时间} {群号}`
121
-
122
- 如:`/B话榜 历史 2024-01-01~2024-01-02 12345678`
121
+ `/{时间类型(今日|年度)?}{B 话榜|废话榜} {时间类型?} {ISO8601 格式时间} {群号}`
123
122
 
123
+ 如:`/B 话榜 历史 2024-01-01~2024-01-02 12345678`
124
124
 
125
125
  ## 📖版本
126
126
 
@@ -196,14 +196,14 @@ __!!注意!!__
196
196
 
197
197
  - [ ] 更好看的图片渲染
198
198
 
199
- - [ ] 提供多样化的渲染器配置(html渲染,pillow渲染,统计绘图软件渲染)
200
- - [ ] 为pillow渲染方式提供插件的加载方式(什么?插件里的插件???)
199
+ - [ ] 提供多样化的渲染器配置(html 渲染,pillow 渲染,统计绘图软件渲染)
200
+ - [ ] 为 pillow 渲染方式提供插件的加载方式(什么?插件里的插件???)
201
201
 
202
202
  - [ ] 私聊的查询(超级用户可以任意查询群聊的信息)一半完成
203
203
 
204
204
  - [ ] 查询带某关键词的消息量
205
205
 
206
- - [ ] 使用管理员权限直接获取QQ官方统计的今日消息量以优化代码运行速度
206
+ - [ ] 使用管理员权限直接获取 QQ 官方统计的今日消息量以优化代码运行速度
207
207
 
208
208
  - [ ] 特殊的储存方案优化消息统计
209
209
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-dialectlist"
3
- version = "2.1.9"
3
+ version = "2.2.1"
4
4
  description = "看看你群群友有多能说"
5
5
  authors = [
6
6
  {name = "Chen_Xu233", email = "woyerpa@outlook.com"},