nonebot-plugin-dialectlist 2.4.1__tar.gz → 2.4.3__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.3/LICENSE +21 -0
  2. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/PKG-INFO +3 -2
  3. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/__init__.py +4 -1
  4. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/config.py +1 -0
  5. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/storage.py +9 -5
  6. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/utils.py +15 -7
  7. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +3 -2
  8. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +1 -0
  9. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/pyproject.toml +2 -2
  10. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/MANIFEST.in +0 -0
  11. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/README.md +0 -0
  12. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/model.py +0 -0
  13. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
  14. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
  15. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
  16. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/time.py +0 -0
  17. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist/usage.py +0 -0
  18. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
  19. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -0
  20. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
  21. {nonebot_plugin_dialectlist-2.4.1 → nonebot_plugin_dialectlist-2.4.3}/setup.cfg +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ChenXu233
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.4.1
3
+ Version: 2.4.3
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
+ License-File: LICENSE
9
10
  Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
10
11
  Requires-Dist: requests>=2.32.3
11
12
  Requires-Dist: nonebot-plugin-orm[default]
@@ -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话榜",
@@ -11,6 +11,7 @@ class ScopedConfig(BaseModel):
11
11
  visualization: bool = True # 是否可视化
12
12
  counting_cache: bool = False # 计数缓存(能够提高回复速度)
13
13
  excluded_people: List[str] = [] # 排除的人的QQ号
14
+ use_user_info_cache: bool = False # 是否使用用户信息缓存
14
15
  timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
15
16
  string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
16
17
  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,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-dialectlist
3
- Version: 2.4.1
3
+ Version: 2.4.3
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
+ License-File: LICENSE
9
10
  Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
10
11
  Requires-Dist: requests>=2.32.3
11
12
  Requires-Dist: nonebot-plugin-orm[default]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-dialectlist"
3
- version = "2.4.1"
3
+ version = "2.4.3"
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