nonebot-plugin-dialectlist 2.3.0__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.3.0 → nonebot_plugin_dialectlist-2.3.1}/PKG-INFO +1 -1
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/__init__.py +3 -10
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/config.py +2 -2
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/model.py +2 -2
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/time.py +0 -1
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/utils.py +26 -16
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +1 -1
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/pyproject.toml +4 -15
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/MANIFEST.in +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/README.md +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/storage.py +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.3.0 → nonebot_plugin_dialectlist-2.3.1}/setup.cfg +0 -0
|
@@ -8,21 +8,18 @@ require("nonebot_plugin_alconna")
|
|
|
8
8
|
require("nonebot_plugin_cesaa")
|
|
9
9
|
|
|
10
10
|
import re
|
|
11
|
-
import os
|
|
12
11
|
import time as t
|
|
13
12
|
import nonebot_plugin_saa as saa
|
|
14
13
|
|
|
15
|
-
from typing import Union, Optional
|
|
14
|
+
from typing import Union, Optional
|
|
16
15
|
from datetime import datetime, timedelta
|
|
17
16
|
from arclet.alconna import ArparmaBehavior
|
|
18
17
|
from arclet.alconna.arparma import Arparma
|
|
19
18
|
|
|
20
19
|
from nonebot.log import logger
|
|
21
20
|
from nonebot.typing import T_State
|
|
22
|
-
from nonebot.compat import model_dump
|
|
23
21
|
from nonebot.params import Arg, Depends
|
|
24
22
|
from nonebot.adapters import Bot, Event
|
|
25
|
-
from nonebot.permission import SUPERUSER
|
|
26
23
|
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
|
27
24
|
from nonebot_plugin_alconna import (
|
|
28
25
|
Args,
|
|
@@ -30,9 +27,6 @@ from nonebot_plugin_alconna import (
|
|
|
30
27
|
Alconna,
|
|
31
28
|
on_alconna,
|
|
32
29
|
)
|
|
33
|
-
|
|
34
|
-
from nonebot_plugin_apscheduler import scheduler
|
|
35
|
-
from nonebot_plugin_userinfo import get_user_info
|
|
36
30
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
37
31
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
38
32
|
|
|
@@ -45,7 +39,6 @@ from .time import (
|
|
|
45
39
|
get_datetime_now_with_timezone,
|
|
46
40
|
parse_datetime,
|
|
47
41
|
)
|
|
48
|
-
from .model import UserRankInfo
|
|
49
42
|
from .utils import (
|
|
50
43
|
got_rank,
|
|
51
44
|
msg_counter,
|
|
@@ -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}")
|
|
@@ -228,7 +221,7 @@ async def handle_rank(
|
|
|
228
221
|
await saa.Text("没有指定群哦").finish()
|
|
229
222
|
|
|
230
223
|
if plugin_config.counting_cache:
|
|
231
|
-
raise Exception("我草缓存功能还没端上来呢,你怎么就先用上了")
|
|
224
|
+
raise Exception("我草缓存功能还没端上来呢,你怎么就先用上了")
|
|
232
225
|
else:
|
|
233
226
|
messages = await get_message_records(
|
|
234
227
|
id2s=[id],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
|
-
from typing import Optional, List
|
|
2
|
+
from typing import Optional, List
|
|
3
3
|
from nonebot import get_driver, get_plugin_config
|
|
4
4
|
|
|
5
5
|
|
|
@@ -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 = False
|
|
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}秒" # 消息格式后缀
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from typing import Union
|
|
3
|
-
from
|
|
4
|
-
from sqlalchemy import JSON, TEXT, String,Integer
|
|
3
|
+
from sqlalchemy import Integer
|
|
5
4
|
from nonebot_plugin_orm import Model
|
|
6
5
|
from nonebot_plugin_userinfo import UserInfo
|
|
7
6
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
@@ -19,6 +18,7 @@ class UserRankInfo(UserInfo):
|
|
|
19
18
|
# session_id: str
|
|
20
19
|
# session_bnum: int
|
|
21
20
|
|
|
21
|
+
|
|
22
22
|
class MessageCountCache(Model):
|
|
23
23
|
__table_args__ = {"extend_existing": True}
|
|
24
24
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
import asyncio
|
|
3
3
|
import unicodedata
|
|
4
4
|
|
|
5
|
-
from typing import Dict, List
|
|
5
|
+
from typing import Dict, List
|
|
6
6
|
from sqlalchemy import or_, select
|
|
7
7
|
from sqlalchemy.sql import ColumnElement
|
|
8
8
|
|
|
@@ -184,7 +184,9 @@ async def get_rank_image(rank: List[UserRankInfo]) -> bytes:
|
|
|
184
184
|
},
|
|
185
185
|
pages={"viewport": {"width": 1000, "height": 10}},
|
|
186
186
|
)
|
|
187
|
-
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _get_user_nickname(user_info: UserInfo) -> str:
|
|
188
190
|
user_nickname = (
|
|
189
191
|
user_info.user_displayname
|
|
190
192
|
if user_info.user_displayname
|
|
@@ -192,27 +194,31 @@ def _get_user_nickname(user_info:UserInfo)->str:
|
|
|
192
194
|
)
|
|
193
195
|
return user_nickname
|
|
194
196
|
|
|
195
|
-
|
|
197
|
+
|
|
198
|
+
async def _get_user_default_avatar() -> bytes:
|
|
196
199
|
img = open(
|
|
197
|
-
os.path.dirname(os.path.abspath(__file__))
|
|
198
|
-
+ "/template/avatar/default.jpg",
|
|
200
|
+
os.path.dirname(os.path.abspath(__file__)) + "/template/avatar/default.jpg",
|
|
199
201
|
"rb",
|
|
200
|
-
|
|
202
|
+
).read()
|
|
201
203
|
return img
|
|
202
204
|
|
|
203
|
-
|
|
205
|
+
|
|
206
|
+
def get_default_user_info() -> UserInfo:
|
|
204
207
|
user_info = UserInfo(
|
|
205
208
|
user_id="114514",
|
|
206
209
|
user_name="鬼知道这谁,bot获取不了",
|
|
207
210
|
)
|
|
208
211
|
return user_info
|
|
209
212
|
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
|
|
214
|
+
async def get_user_infos(
|
|
215
|
+
bot: Bot, event: Event, rank: List, use_cache: bool = True
|
|
216
|
+
) -> List[UserRankInfo]:
|
|
217
|
+
|
|
212
218
|
user_ids = [i[0] for i in rank]
|
|
213
219
|
pool = [get_user_info(bot, event, id, use_cache) for id in user_ids]
|
|
214
|
-
user_infos =
|
|
215
|
-
|
|
220
|
+
user_infos = await asyncio.gather(*pool)
|
|
221
|
+
|
|
216
222
|
pool = []
|
|
217
223
|
for i in user_infos:
|
|
218
224
|
if not i:
|
|
@@ -223,25 +229,29 @@ async def get_user_infos(bot:Bot,event:Event,rank:List,use_cache: bool = True)->
|
|
|
223
229
|
user_avatars = await asyncio.gather(*pool)
|
|
224
230
|
for i in user_avatars:
|
|
225
231
|
if not i:
|
|
226
|
-
user_avatars[user_avatars.index(i)] = await
|
|
232
|
+
user_avatars[user_avatars.index(i)] = await _get_user_default_avatar()
|
|
227
233
|
|
|
228
234
|
total = sum([i[1] for i in rank])
|
|
229
235
|
rank2 = []
|
|
230
236
|
for i in range(len(rank)):
|
|
231
|
-
|
|
237
|
+
|
|
232
238
|
user_info = user_infos[i]
|
|
233
239
|
if not user_info:
|
|
234
240
|
user_info = get_default_user_info()
|
|
235
|
-
|
|
241
|
+
|
|
236
242
|
user = UserRankInfo(
|
|
237
243
|
**model_dump(user_info),
|
|
238
244
|
user_bnum=rank[i][1],
|
|
239
245
|
user_proportion=round(rank[i][1] / total * 100, 2),
|
|
240
|
-
user_index=i+1,
|
|
246
|
+
user_index=i + 1,
|
|
241
247
|
user_nickname=_get_user_nickname(user_info),
|
|
242
248
|
user_avatar_bytes=user_avatars[i],
|
|
243
249
|
)
|
|
250
|
+
user.user_gender = (
|
|
251
|
+
"♂"
|
|
252
|
+
if user.user_gender == "male"
|
|
253
|
+
else "♀" if user.user_gender == "female" else ""
|
|
254
|
+
)
|
|
244
255
|
rank2.append(user)
|
|
245
256
|
|
|
246
257
|
return rank2
|
|
247
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-dialectlist"
|
|
3
|
-
version = "2.3.
|
|
3
|
+
version = "2.3.1"
|
|
4
4
|
description = "看看你群群友有多能说"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
|
@@ -40,21 +40,10 @@ distribution = true
|
|
|
40
40
|
|
|
41
41
|
[tool.ruff]
|
|
42
42
|
line-length = 80
|
|
43
|
+
|
|
43
44
|
[tool.ruff.format]
|
|
44
45
|
quote-style = "single"
|
|
45
46
|
indent-style = "tab"
|
|
46
47
|
|
|
47
|
-
[tool.
|
|
48
|
-
|
|
49
|
-
build = 'pdm run setup.py sdist'
|
|
50
|
-
publish = 'pdm run python -m twine upload dist/*'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# 以下为智普 AI 生成,还不知道这玩意有啥用。
|
|
54
|
-
# [tool.pdm.dev-dependencies]
|
|
55
|
-
# black = "^23.1.0"
|
|
56
|
-
# isort = "^5.10.1"
|
|
57
|
-
# pre-commit = "^2.20.0"
|
|
58
|
-
|
|
59
|
-
# [tool.pdm.global-options]
|
|
60
|
-
# --no-pip-version-check = true
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
ignore = ["E402"]
|
|
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
|