nonebot-plugin-dialectlist 2.4.2__tar.gz → 2.4.4__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.4.2/nonebot_plugin_dialectlist.egg-info → nonebot_plugin_dialectlist-2.4.4}/PKG-INFO +2 -2
  2. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/__init__.py +20 -14
  3. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/config.py +2 -0
  4. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/storage.py +9 -5
  5. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/utils.py +15 -7
  6. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4/nonebot_plugin_dialectlist.egg-info}/PKG-INFO +2 -2
  7. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/pyproject.toml +2 -2
  8. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/LICENSE +0 -0
  9. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/MANIFEST.in +0 -0
  10. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/README.md +0 -0
  11. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/model.py +0 -0
  12. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
  13. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
  14. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
  15. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/time.py +0 -0
  16. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist/usage.py +0 -0
  17. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -0
  18. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
  19. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -0
  20. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
  21. {nonebot_plugin_dialectlist-2.4.2 → nonebot_plugin_dialectlist-2.4.4}/setup.cfg +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.4.2
3
+ Version: 2.4.4
4
4
  Summary: 看看你群群友有多能说
5
5
  Author-email: Chen_Xu233 <woyerpa@outlook.com>
6
6
  License: MIT
7
- Requires-Python: <4.0,>=3.9
7
+ Requires-Python: <3.13,>=3.9
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
10
  Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
@@ -31,7 +31,7 @@ from nonebot_plugin_alconna import (
31
31
  from nonebot_plugin_chatrecorder import get_message_records
32
32
  from nonebot_plugin_session import Session, SessionIdType, extract_session
33
33
 
34
- from .storage import get_cache,build_cache
34
+ from .storage import get_cache, build_cache
35
35
  from .config import Config, plugin_config
36
36
  from .usage import __usage__
37
37
  from .time import (
@@ -74,14 +74,17 @@ def wrapper(slot: Union[int, str], content: Optional[str], context) -> str:
74
74
  return content
75
75
  return "" # pragma: no cover
76
76
 
77
+
77
78
  build_cache_cmd = on_command("build_cache", aliases={"重建缓存"}, block=True)
78
79
 
80
+
79
81
  @build_cache_cmd.handle()
80
82
  async def _build_cache(bot: Bot, event: Event):
81
83
  await saa.Text("正在重建缓存,请稍等。").send(reply=True)
82
84
  await build_cache()
83
85
  await saa.Text("重建缓存完成。").send(reply=True)
84
86
 
87
+
85
88
  rank_cmd = on_alconna(
86
89
  Alconna(
87
90
  "B话榜",
@@ -254,30 +257,33 @@ async def handle_rank(
254
257
  t1 = t.time()
255
258
  rank2 = await get_user_infos(bot, event, rank)
256
259
  logger.debug(f"获取用户信息花费时间:{t.time() - t1}")
257
-
260
+
258
261
  string: str = ""
259
- for i in rank2:
260
- logger.debug(i.user_name)
261
- for i in range(len(rank2)):
262
- str_example = plugin_config.string_format.format(
263
- index=rank2[i].user_index,
264
- nickname=rank2[i].user_nickname,
265
- chatdatanum=rank2[i].user_bnum,
266
- )
267
- string += str_example
262
+
263
+ if plugin_config.show_text_rank:
264
+ for i in rank2:
265
+ logger.debug(i.user_name)
266
+ for i in range(len(rank2)):
267
+ str_example = plugin_config.string_format.format(
268
+ index=rank2[i].user_index,
269
+ nickname=rank2[i].user_nickname,
270
+ chatdatanum=rank2[i].user_bnum,
271
+ )
272
+ string += str_example
268
273
 
269
274
  msg = saa.Text(string)
270
- t1 = t.time()
271
275
 
272
276
  if plugin_config.visualization:
277
+ t1 = t.time()
273
278
  image = await get_rank_image(rank2)
274
279
  msg += saa.Image(image)
280
+ logger.debug(f"群聊消息渲染图片花费时间:{t.time() - t1}")
275
281
 
276
282
  if plugin_config.suffix:
277
283
  timecost = t.time() - state["t1"]
278
284
  suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost))
279
285
  msg += suffix
280
-
281
- logger.debug(f"群聊消息渲染图片花费时间:{t.time() - t1}")
286
+ if not msg:
287
+ await saa.Text("你把可视化都关了哪来的排行榜?").finish()
282
288
 
283
289
  await msg.finish(reply=True)
@@ -9,8 +9,10 @@ class ScopedConfig(BaseModel):
9
9
  suffix: bool = True # 是否显示后缀
10
10
  excluded_self: bool = True # 是否排除自己
11
11
  visualization: bool = True # 是否可视化
12
+ show_text_rank:bool = True # 是否显示文本排名
12
13
  counting_cache: bool = False # 计数缓存(能够提高回复速度)
13
14
  excluded_people: List[str] = [] # 排除的人的QQ号
15
+ use_user_info_cache: bool = False # 是否使用用户信息缓存
14
16
  timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
15
17
  string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
16
18
  template_path: str = "./template/rank_template.j2" # 模板路径
@@ -6,7 +6,7 @@ from sqlalchemy import delete, or_, select
6
6
  from nonebot import get_driver
7
7
  from nonebot.log import logger
8
8
  from nonebot.params import Depends
9
- from nonebot.adapters import Event,Bot
9
+ from nonebot.adapters import Event, Bot
10
10
  from nonebot.message import event_postprocessor
11
11
 
12
12
  from .model import MessageCountCache
@@ -56,7 +56,9 @@ async def build_cache():
56
56
  where.append(
57
57
  or_(
58
58
  MessageCountCache.time
59
- == remove_timezone(msg.time.replace(hour=1, minute=0, second=0, microsecond=0))
59
+ == remove_timezone(
60
+ msg.time.replace(hour=1, minute=0, second=0, microsecond=0)
61
+ )
60
62
  )
61
63
  )
62
64
  statement = select(MessageCountCache).where(*where)
@@ -68,7 +70,9 @@ async def build_cache():
68
70
  else:
69
71
  user_cache = MessageCountCache(
70
72
  session_id=msg.session_persist_id,
71
- time=remove_timezone(msg.time.replace(hour=1, minute=0, second=0, microsecond=0)),
73
+ time=remove_timezone(
74
+ msg.time.replace(hour=1, minute=0, second=0, microsecond=0)
75
+ ),
72
76
  session_bnum=1,
73
77
  )
74
78
  db_session.add(user_cache)
@@ -100,7 +104,7 @@ async def _():
100
104
 
101
105
 
102
106
  @event_postprocessor
103
- async def _(bot: Bot, event: Event,session: Session = Depends(extract_session)):
107
+ async def _(bot: Bot, event: Event, session: Session = Depends(extract_session)):
104
108
  if not plugin_config.counting_cache:
105
109
  return
106
110
  if not session.id2:
@@ -112,7 +116,7 @@ async def _(bot: Bot, event: Event,session: Session = Depends(extract_session)):
112
116
 
113
117
  async with get_session() as db_session:
114
118
  session_id = await get_session_persist_id(session)
115
- logger.debug("session_id:"+str(session_id))
119
+ logger.debug("session_id:" + str(session_id))
116
120
  where = [or_(MessageCountCache.session_id == session_id)]
117
121
  where.append(or_(MessageCountCache.time == remove_timezone(now)))
118
122
  statement = select(MessageCountCache).where(*where)
@@ -194,6 +194,7 @@ async def _get_user_default_avatar() -> bytes:
194
194
  ).read()
195
195
  return img
196
196
 
197
+
197
198
  async def _get_user_avatar(user: UserInfo, client: httpx.AsyncClient) -> bytes:
198
199
  if not user.user_avatar:
199
200
  return await _get_user_default_avatar()
@@ -208,6 +209,7 @@ async def _get_user_avatar(user: UserInfo, client: httpx.AsyncClient) -> bytes:
208
209
  await asyncio.sleep(3)
209
210
  raise NetworkError(f"{url} 下载失败!")
210
211
 
212
+
211
213
  def get_default_user_info() -> UserInfo:
212
214
  user_info = UserInfo(
213
215
  user_id="114514",
@@ -215,14 +217,18 @@ def get_default_user_info() -> UserInfo:
215
217
  )
216
218
  return user_info
217
219
 
220
+
218
221
  async def get_user_infos(
219
- bot: Bot, event: Event, rank: List, use_cache: bool = True
222
+ bot: Bot,
223
+ event: Event,
224
+ rank: List,
225
+ use_cache: bool = plugin_config.use_user_info_cache,
220
226
  ) -> List[UserRankInfo]:
221
227
 
222
228
  user_ids = [i[0] for i in rank]
223
229
  pool = [get_user_info(bot, event, id, use_cache) for id in user_ids]
224
230
  user_infos = await asyncio.gather(*pool)
225
-
231
+
226
232
  async with httpx.AsyncClient() as client:
227
233
  pool = []
228
234
  for i in user_infos:
@@ -253,11 +259,13 @@ async def get_user_infos(
253
259
  user_nickname=_get_user_nickname(user_info),
254
260
  user_avatar_bytes=user_avatars[i],
255
261
  )
256
- user.user_gender = (
257
- "♂"
258
- if user.user_gender == "male"
259
- else "♀" if user.user_gender == "female" else ""
260
- )
262
+ print(user.user_gender)
263
+ if user.user_gender == "male":
264
+ user.user_gender = "♂"
265
+ elif user.user_gender == "female":
266
+ user.user_gender = "♀"
267
+ else:
268
+ user.user_gender = "🤔"
261
269
  rank2.append(user)
262
270
 
263
271
  return rank2
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.4.2
3
+ Version: 2.4.4
4
4
  Summary: 看看你群群友有多能说
5
5
  Author-email: Chen_Xu233 <woyerpa@outlook.com>
6
6
  License: MIT
7
- Requires-Python: <4.0,>=3.9
7
+ Requires-Python: <3.13,>=3.9
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
10
  Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-dialectlist"
3
- version = "2.4.2"
3
+ version = "2.4.4"
4
4
  description = "看看你群群友有多能说"
5
5
  authors = [
6
6
  {name = "Chen_Xu233", email = "woyerpa@outlook.com"},
@@ -18,7 +18,7 @@ dependencies = [
18
18
  "pillow>=10.4.0",
19
19
  "nonebot-plugin-uninfo>=0.1.1",
20
20
  ]
21
- requires-python = ">=3.9,<4.0"
21
+ requires-python = ">=3.9,<3.13"
22
22
  readme = "README.md"
23
23
  license = {text = "MIT"}
24
24