nonebot-plugin-dialectlist 3.0.1__tar.gz → 3.1.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-3.0.1/nonebot_plugin_dialectlist.egg-info → nonebot_plugin_dialectlist-3.1.0}/PKG-INFO +45 -27
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/README.md +31 -13
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/__init__.py +17 -14
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/config.py +0 -2
- nonebot_plugin_dialectlist-3.1.0/nonebot_plugin_dialectlist/schema.py +31 -0
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/template/rank_template.j2 +2 -2
- nonebot_plugin_dialectlist-3.1.0/nonebot_plugin_dialectlist/template/res/HarmonyOS_Sans_SC.woff2 +0 -0
- nonebot_plugin_dialectlist-3.1.0/nonebot_plugin_dialectlist/time.py +52 -0
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/usage.py +0 -2
- nonebot_plugin_dialectlist-3.1.0/nonebot_plugin_dialectlist/utils.py +323 -0
- nonebot_plugin_dialectlist-3.1.0/pyproject.toml +59 -0
- nonebot_plugin_dialectlist-3.1.0/tests/screenshot-chromium.png +0 -0
- nonebot_plugin_dialectlist-3.1.0/tests/screenshot-firefox.png +0 -0
- nonebot_plugin_dialectlist-3.1.0/tests/screenshot-webkit.png +0 -0
- nonebot_plugin_dialectlist-3.1.0/tests/temple_render.py +12 -0
- nonebot_plugin_dialectlist-3.0.1/MANIFEST.in +0 -3
- nonebot_plugin_dialectlist-3.0.1/PKG-INFO +0 -246
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist/schema.py +0 -11
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist/time.py +0 -77
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist/utils.py +0 -269
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +0 -18
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -1
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist.egg-info/requires.txt +0 -20
- nonebot_plugin_dialectlist-3.0.1/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -1
- nonebot_plugin_dialectlist-3.0.1/pyproject.toml +0 -44
- nonebot_plugin_dialectlist-3.0.1/setup.cfg +0 -4
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/LICENSE +0 -0
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
- {nonebot_plugin_dialectlist-3.0.1 → nonebot_plugin_dialectlist-3.1.0}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
|
-
Author-
|
|
5
|
+
Author-Email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
7
|
-
Requires-Python: <4.0,>=3.
|
|
8
|
-
|
|
9
|
-
License-File: LICENSE
|
|
7
|
+
Requires-Python: <4.0,>=3.10
|
|
8
|
+
Requires-Dist: nonebot2>=2.4.0
|
|
10
9
|
Requires-Dist: nonebot-plugin-chatrecorder>=0.7.0
|
|
11
|
-
Requires-Dist: nonebot-plugin-orm[
|
|
12
|
-
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
10
|
+
Requires-Dist: nonebot-plugin-orm[sqlite]>=0.8.0
|
|
13
11
|
Requires-Dist: nonebot-plugin-alconna>=0.50.2
|
|
14
|
-
Requires-Dist: nonebot-plugin-
|
|
12
|
+
Requires-Dist: nonebot-plugin-uninfo>=0.8.0
|
|
15
13
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.6
|
|
16
|
-
Requires-Dist: nonebot-plugin-htmlrender
|
|
17
|
-
Requires-Dist:
|
|
14
|
+
Requires-Dist: nonebot-plugin-htmlrender<0.9,>=0.6.6
|
|
15
|
+
Requires-Dist: playwright>=1.48.0
|
|
16
|
+
Requires-Dist: nonebot-plugin-send-anything-anywhere>=0.7.1
|
|
17
|
+
Requires-Dist: httpx>=0.27.0
|
|
18
|
+
Requires-Dist: jinja2>=3.0.3
|
|
19
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
18
20
|
Requires-Dist: pillow>=11.3.0
|
|
19
|
-
Requires-Dist: nonebot-plugin-uninfo>=0.1.1
|
|
20
21
|
Provides-Extra: dev
|
|
21
22
|
Requires-Dist: ruff>=0.5.5; extra == "dev"
|
|
22
|
-
Requires-Dist: setuptools>=80.9.0; extra == "dev"
|
|
23
23
|
Requires-Dist: twine>=6.2.0; extra == "dev"
|
|
24
24
|
Requires-Dist: nb-cli>=1.4.2; extra == "dev"
|
|
25
25
|
Requires-Dist: py-spy>=0.3.14; extra == "dev"
|
|
26
26
|
Provides-Extra: test
|
|
27
27
|
Requires-Dist: nonebot-adapter-onebot>=2.4.4; extra == "test"
|
|
28
|
-
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
29
|
|
|
30
30
|
<div align="center">
|
|
31
31
|
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
@@ -44,7 +44,7 @@ nonebot-plugin-dialectlist
|
|
|
44
44
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
45
45
|
</a>
|
|
46
46
|
|
|
47
|
-
<img src="https://img.shields.io/badge/python-3.
|
|
47
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="python">
|
|
48
48
|
|
|
49
49
|
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
50
50
|
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1128359833-orange?style=flat-square" alt="QQ Chat Group">
|
|
@@ -75,15 +75,30 @@ nb plugin install nonebot-plugin-dialectlist
|
|
|
75
75
|
|
|
76
76
|
### ✅ 插件依赖于
|
|
77
77
|
|
|
78
|
-
1. [nonebot-plugin-
|
|
79
|
-
2. [nonebot-plugin-
|
|
80
|
-
3. [nonebot-plugin-
|
|
81
|
-
4. [nonebot-plugin-
|
|
82
|
-
5. [nonebot-plugin-
|
|
83
|
-
6. [nonebot-plugin-
|
|
78
|
+
1. [nonebot-plugin-chatrecorder](https://github.com/noneplugin/nonebot-plugin-chatrecorder) ————实现消息储存
|
|
79
|
+
2. [nonebot-plugin-orm](https://github.com/nonebot/nonebot-plugin-orm) ————数据库
|
|
80
|
+
3. [nonebot-plugin-uninfo](https://github.com/nonebot/nonebot-plugin-uninfo) ————跨平台会话信息
|
|
81
|
+
4. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
82
|
+
5. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
83
|
+
6. [nonebot-plugin-send-anything-anywhere](https://github.com/felinae98/nonebot-plugin-send-anything-anywhere) ————实现多平台发送
|
|
84
|
+
7. [nonebot-plugin-htmlrender](https://github.com/nonebot/nonebot-plugin-htmlrender) ————渲染排行榜图片
|
|
84
85
|
|
|
85
86
|
**⚠ 注意** 若先前没有安装过`nonebot-plugin-chatrecorder`或者`nonebot-plugin-orm`,则会在启动时报错,请按报错的提示安装数据库!
|
|
86
87
|
|
|
88
|
+
> [!IMPORTANT]
|
|
89
|
+
> **关于 htmlrender 版本**:支持 `nonebot-plugin-htmlrender >= 0.6.6, < 0.9`。
|
|
90
|
+
> 0.6 开箱即用;用 0.7 / 0.8 时上游要求显式指定渲染后端,需要在 `.env` 里加一行:
|
|
91
|
+
>
|
|
92
|
+
> ```dotenv
|
|
93
|
+
> # htmlrender 0.8+
|
|
94
|
+
> RENDER__PROVIDER=playwright
|
|
95
|
+
> # htmlrender 0.7
|
|
96
|
+
> RENDER_BACKEND=playwright
|
|
97
|
+
> ```
|
|
98
|
+
>
|
|
99
|
+
> 模板的样式、字体和头像已全部内联成 data URI,所以 0.8 的本地文件访问限制不影响出图。
|
|
100
|
+
> 首次渲染会自动安装 Chromium,也可以手动执行 `playwright install chromium`。
|
|
101
|
+
|
|
87
102
|
## ⚙ 配置
|
|
88
103
|
|
|
89
104
|
需要**提前配置**本插件所**依赖的插件**!
|
|
@@ -92,9 +107,7 @@ nb plugin install nonebot-plugin-dialectlist
|
|
|
92
107
|
|
|
93
108
|
```python
|
|
94
109
|
dialectlist__get_num: int = 5 # 获取人数数量
|
|
95
|
-
dialectlist__font: str = "SimHei" # 字体格式
|
|
96
110
|
dialectlist__suffix: bool = True # 是否显示后缀
|
|
97
|
-
dialectlist__excluded_self: bool = True # 是否排除自己
|
|
98
111
|
dialectlist__visualization: bool = True # 是否可视化
|
|
99
112
|
dialectlist__show_text_rank: bool = True # 是否显示文本排名
|
|
100
113
|
dialectlist__excluded_people: List[str] = [] # 排除的人的 QQ 号
|
|
@@ -103,11 +116,15 @@ dialectlist__aggregate_transmission: bool = False # 是否聚合转发消息
|
|
|
103
116
|
dialectlist__timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
|
|
104
117
|
dialectlist__string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
|
105
118
|
dialectlist__template_path: str = "./template/rank_template.j2" # 模板路径
|
|
106
|
-
dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}
|
|
119
|
+
dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条消息\n" # 消息格式
|
|
107
120
|
```
|
|
108
121
|
|
|
109
122
|
💭 也可以不进行配置,这将会使插件按照默认配置运行
|
|
110
123
|
|
|
124
|
+
> [!NOTE]
|
|
125
|
+
> 3.1.0 起模板变量有变化:`inline_css`(内联的样式表与字体)、`i.user_avatar_data_uri`(头像 data URI)。
|
|
126
|
+
> 插件不再向缓存目录写头像文件,也不再向模板传入 `cache_path` / `file_path`;自定义模板请改用新变量。
|
|
127
|
+
|
|
111
128
|
### ⚠ 注意!!
|
|
112
129
|
|
|
113
130
|
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
|
@@ -130,8 +147,6 @@ dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条
|
|
|
130
147
|
|
|
131
148
|
-`/昨日 B 话榜` ————看看昨天的群友发了多少消息!
|
|
132
149
|
|
|
133
|
-
-`/前日 B 话榜` ————看看前天的群友发了多少消息!
|
|
134
|
-
|
|
135
150
|
-`/本周 B 话榜` ————看看本周的群友发了多少消息!
|
|
136
151
|
|
|
137
152
|
-`/上周 B 话榜` ————看看上周的群友发了多少消息!
|
|
@@ -172,7 +187,10 @@ dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条
|
|
|
172
187
|
`/kkb @man -k ♂`
|
|
173
188
|
|
|
174
189
|
> [!IMPORTANT]
|
|
175
|
-
>
|
|
190
|
+
> 关键词按“包含”匹配(不区分大小写的子串匹配),**不支持正则表达式**;输入中的 `%`、`_` 会按普通字符处理。
|
|
191
|
+
|
|
192
|
+
> [!NOTE]
|
|
193
|
+
> 3.0.2 起移除了从未生效的 `font`(字体固定使用内置字体)与 `excluded_self`(统计本就只算收到的消息)两项配置。
|
|
176
194
|
|
|
177
195
|
## 💪 目前支持的平台
|
|
178
196
|
|
|
@@ -15,7 +15,7 @@ nonebot-plugin-dialectlist
|
|
|
15
15
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
16
16
|
</a>
|
|
17
17
|
|
|
18
|
-
<img src="https://img.shields.io/badge/python-3.
|
|
18
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="python">
|
|
19
19
|
|
|
20
20
|
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
21
21
|
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1128359833-orange?style=flat-square" alt="QQ Chat Group">
|
|
@@ -46,15 +46,30 @@ nb plugin install nonebot-plugin-dialectlist
|
|
|
46
46
|
|
|
47
47
|
### ✅ 插件依赖于
|
|
48
48
|
|
|
49
|
-
1. [nonebot-plugin-
|
|
50
|
-
2. [nonebot-plugin-
|
|
51
|
-
3. [nonebot-plugin-
|
|
52
|
-
4. [nonebot-plugin-
|
|
53
|
-
5. [nonebot-plugin-
|
|
54
|
-
6. [nonebot-plugin-
|
|
49
|
+
1. [nonebot-plugin-chatrecorder](https://github.com/noneplugin/nonebot-plugin-chatrecorder) ————实现消息储存
|
|
50
|
+
2. [nonebot-plugin-orm](https://github.com/nonebot/nonebot-plugin-orm) ————数据库
|
|
51
|
+
3. [nonebot-plugin-uninfo](https://github.com/nonebot/nonebot-plugin-uninfo) ————跨平台会话信息
|
|
52
|
+
4. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
53
|
+
5. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
54
|
+
6. [nonebot-plugin-send-anything-anywhere](https://github.com/felinae98/nonebot-plugin-send-anything-anywhere) ————实现多平台发送
|
|
55
|
+
7. [nonebot-plugin-htmlrender](https://github.com/nonebot/nonebot-plugin-htmlrender) ————渲染排行榜图片
|
|
55
56
|
|
|
56
57
|
**⚠ 注意** 若先前没有安装过`nonebot-plugin-chatrecorder`或者`nonebot-plugin-orm`,则会在启动时报错,请按报错的提示安装数据库!
|
|
57
58
|
|
|
59
|
+
> [!IMPORTANT]
|
|
60
|
+
> **关于 htmlrender 版本**:支持 `nonebot-plugin-htmlrender >= 0.6.6, < 0.9`。
|
|
61
|
+
> 0.6 开箱即用;用 0.7 / 0.8 时上游要求显式指定渲染后端,需要在 `.env` 里加一行:
|
|
62
|
+
>
|
|
63
|
+
> ```dotenv
|
|
64
|
+
> # htmlrender 0.8+
|
|
65
|
+
> RENDER__PROVIDER=playwright
|
|
66
|
+
> # htmlrender 0.7
|
|
67
|
+
> RENDER_BACKEND=playwright
|
|
68
|
+
> ```
|
|
69
|
+
>
|
|
70
|
+
> 模板的样式、字体和头像已全部内联成 data URI,所以 0.8 的本地文件访问限制不影响出图。
|
|
71
|
+
> 首次渲染会自动安装 Chromium,也可以手动执行 `playwright install chromium`。
|
|
72
|
+
|
|
58
73
|
## ⚙ 配置
|
|
59
74
|
|
|
60
75
|
需要**提前配置**本插件所**依赖的插件**!
|
|
@@ -63,9 +78,7 @@ nb plugin install nonebot-plugin-dialectlist
|
|
|
63
78
|
|
|
64
79
|
```python
|
|
65
80
|
dialectlist__get_num: int = 5 # 获取人数数量
|
|
66
|
-
dialectlist__font: str = "SimHei" # 字体格式
|
|
67
81
|
dialectlist__suffix: bool = True # 是否显示后缀
|
|
68
|
-
dialectlist__excluded_self: bool = True # 是否排除自己
|
|
69
82
|
dialectlist__visualization: bool = True # 是否可视化
|
|
70
83
|
dialectlist__show_text_rank: bool = True # 是否显示文本排名
|
|
71
84
|
dialectlist__excluded_people: List[str] = [] # 排除的人的 QQ 号
|
|
@@ -74,11 +87,15 @@ dialectlist__aggregate_transmission: bool = False # 是否聚合转发消息
|
|
|
74
87
|
dialectlist__timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
|
|
75
88
|
dialectlist__string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
|
76
89
|
dialectlist__template_path: str = "./template/rank_template.j2" # 模板路径
|
|
77
|
-
dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}
|
|
90
|
+
dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条消息\n" # 消息格式
|
|
78
91
|
```
|
|
79
92
|
|
|
80
93
|
💭 也可以不进行配置,这将会使插件按照默认配置运行
|
|
81
94
|
|
|
95
|
+
> [!NOTE]
|
|
96
|
+
> 3.1.0 起模板变量有变化:`inline_css`(内联的样式表与字体)、`i.user_avatar_data_uri`(头像 data URI)。
|
|
97
|
+
> 插件不再向缓存目录写头像文件,也不再向模板传入 `cache_path` / `file_path`;自定义模板请改用新变量。
|
|
98
|
+
|
|
82
99
|
### ⚠ 注意!!
|
|
83
100
|
|
|
84
101
|
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
|
@@ -101,8 +118,6 @@ dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条
|
|
|
101
118
|
|
|
102
119
|
-`/昨日 B 话榜` ————看看昨天的群友发了多少消息!
|
|
103
120
|
|
|
104
|
-
-`/前日 B 话榜` ————看看前天的群友发了多少消息!
|
|
105
|
-
|
|
106
121
|
-`/本周 B 话榜` ————看看本周的群友发了多少消息!
|
|
107
122
|
|
|
108
123
|
-`/上周 B 话榜` ————看看上周的群友发了多少消息!
|
|
@@ -143,7 +158,10 @@ dialectlist__string_format: str = "第{index}名:\n{nickname},{chatdatanum}条
|
|
|
143
158
|
`/kkb @man -k ♂`
|
|
144
159
|
|
|
145
160
|
> [!IMPORTANT]
|
|
146
|
-
>
|
|
161
|
+
> 关键词按“包含”匹配(不区分大小写的子串匹配),**不支持正则表达式**;输入中的 `%`、`_` 会按普通字符处理。
|
|
162
|
+
|
|
163
|
+
> [!NOTE]
|
|
164
|
+
> 3.0.2 起移除了从未生效的 `font`(字体固定使用内置字体)与 `excluded_self`(统计本就只算收到的消息)两项配置。
|
|
147
165
|
|
|
148
166
|
## 💪 目前支持的平台
|
|
149
167
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
from nonebot import require
|
|
2
2
|
|
|
3
3
|
require('nonebot_plugin_chatrecorder')
|
|
4
|
-
require('nonebot_plugin_apscheduler')
|
|
5
4
|
require('nonebot_plugin_htmlrender')
|
|
6
5
|
require('nonebot_plugin_userinfo')
|
|
7
6
|
require('nonebot_plugin_alconna')
|
|
8
7
|
require('nonebot_plugin_uninfo')
|
|
9
|
-
require('
|
|
8
|
+
require('nonebot_plugin_saa')
|
|
10
9
|
|
|
11
10
|
import re
|
|
12
11
|
import time as t
|
|
@@ -33,8 +32,6 @@ from nonebot_plugin_alconna import (
|
|
|
33
32
|
from nonebot_plugin_uninfo import Session, Uninfo, get_session
|
|
34
33
|
|
|
35
34
|
from .config import Config, plugin_config
|
|
36
|
-
|
|
37
|
-
# from .storage import build_cache, get_cache
|
|
38
35
|
from .time import (
|
|
39
36
|
get_datetime_fromisoformat_with_timezone,
|
|
40
37
|
get_datetime_now_with_timezone,
|
|
@@ -110,24 +107,26 @@ async def handle_b_cmd(
|
|
|
110
107
|
if not gid:
|
|
111
108
|
await b_cmd.finish('请指定群号。')
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
# 未使用 -k 时 Match.result 为 None,不能直接拼进文案
|
|
111
|
+
keyword_text = keyword.result if keyword.available else None
|
|
112
|
+
keyword_desc = f'关于“{keyword_text}”的' if keyword_text else ''
|
|
114
113
|
|
|
115
114
|
d = await get_user_message_counts(
|
|
116
|
-
keyword=
|
|
115
|
+
keyword=keyword_text,
|
|
117
116
|
scene_ids=[gid],
|
|
118
117
|
user_ids=[id],
|
|
119
|
-
types=['message'], #
|
|
118
|
+
types=['message'], # 只统计收到的消息,机器人自己发的不计入
|
|
120
119
|
exclude_user_ids=plugin_config.excluded_people,
|
|
121
120
|
)
|
|
122
121
|
|
|
123
122
|
rank = got_rank(d)
|
|
124
123
|
if not rank:
|
|
125
124
|
await b_cmd.finish(
|
|
126
|
-
f'该用户在群“{uninfo.scene.name}
|
|
125
|
+
f'该用户在群“{uninfo.scene.name}”{keyword_desc}B话数量为0。'
|
|
127
126
|
)
|
|
128
127
|
|
|
129
128
|
await saa.Text(
|
|
130
|
-
f'该用户在群“{uninfo.scene.name}
|
|
129
|
+
f'该用户在群“{uninfo.scene.name}”{keyword_desc}B话数量为{rank[0][1]}。'
|
|
131
130
|
).send(reply=True)
|
|
132
131
|
|
|
133
132
|
|
|
@@ -183,7 +182,6 @@ async def _group_message(
|
|
|
183
182
|
):
|
|
184
183
|
t1 = t.time()
|
|
185
184
|
state['t1'] = t1
|
|
186
|
-
dt = get_datetime_now_with_timezone()
|
|
187
185
|
|
|
188
186
|
if not group_id:
|
|
189
187
|
group_id = session.scene.id
|
|
@@ -305,10 +303,15 @@ async def handle_rank(
|
|
|
305
303
|
).finish()
|
|
306
304
|
|
|
307
305
|
rank = got_rank(raw_rank)
|
|
308
|
-
|
|
309
|
-
for
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
# 必须按 user_persist_id 精确映射,不能依赖查询返回顺序
|
|
307
|
+
id_map = await persist_id2user_id([item[0] for item in rank])
|
|
308
|
+
for item in rank:
|
|
309
|
+
user_id = id_map.get(item[0])
|
|
310
|
+
if user_id is None:
|
|
311
|
+
logger.warning(f'未找到持久化 id {item[0]} 对应的平台用户')
|
|
312
|
+
user_id = str(item[0])
|
|
313
|
+
item[0] = user_id
|
|
314
|
+
logger.debug(item)
|
|
312
315
|
|
|
313
316
|
t1 = t.time()
|
|
314
317
|
rank2 = await get_user_infos(bot, event, rank)
|
|
@@ -6,9 +6,7 @@ from pydantic import BaseModel
|
|
|
6
6
|
|
|
7
7
|
class ScopedConfig(BaseModel):
|
|
8
8
|
get_num: int = 5 # 获取人数数量
|
|
9
|
-
font: str = 'SimHei' # 字体格式
|
|
10
9
|
suffix: bool = True # 是否显示后缀
|
|
11
|
-
excluded_self: bool = True # 是否排除自己
|
|
12
10
|
visualization: bool = True # 是否可视化
|
|
13
11
|
show_text_rank: bool = True # 是否显示文本排名
|
|
14
12
|
excluded_people: List[str] = [] # 排除的人的QQ号
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
from typing import Union
|
|
3
|
+
|
|
4
|
+
from nonebot_plugin_userinfo import UserInfo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _image_mime(data: bytes) -> str:
|
|
8
|
+
"""按文件头猜测头像的 MIME 类型"""
|
|
9
|
+
if data.startswith(b'\x89PNG\r\n\x1a\n'):
|
|
10
|
+
return 'image/png'
|
|
11
|
+
if data.startswith(b'GIF8'):
|
|
12
|
+
return 'image/gif'
|
|
13
|
+
if data[:4] == b'RIFF' and data[8:12] == b'WEBP':
|
|
14
|
+
return 'image/webp'
|
|
15
|
+
return 'image/jpeg'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class UserRankInfo(UserInfo):
|
|
19
|
+
user_bnum: int
|
|
20
|
+
user_proportion: float
|
|
21
|
+
user_nickname: str
|
|
22
|
+
user_index: Union[int, str]
|
|
23
|
+
user_avatar_bytes: bytes
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def user_avatar_data_uri(self) -> str:
|
|
27
|
+
"""把头像内联成 data URI,模板不再依赖任何本地文件"""
|
|
28
|
+
return (
|
|
29
|
+
f'data:{_image_mime(self.user_avatar_bytes)};base64,'
|
|
30
|
+
+ base64.b64encode(self.user_avatar_bytes).decode('ascii')
|
|
31
|
+
)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>
|
|
6
6
|
在 title 里夹一点私货应该不会被发现吧?——ddl 真是太厉害啦!
|
|
7
7
|
</title>
|
|
8
|
-
<
|
|
8
|
+
<style>{{ inline_css|safe }}</style>
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div class="container">
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<div class="rank_number rank_number_{{ i.user_index }}">{{ i.user_index }}</div>
|
|
22
22
|
</div>
|
|
23
23
|
<div class="avatar">
|
|
24
|
-
<img class="profile" src="{{
|
|
24
|
+
<img class="profile" src="{{ i.user_avatar_data_uri }}"/>
|
|
25
25
|
</div>
|
|
26
26
|
<div class="rank_card_info">
|
|
27
27
|
<h1>{{ i.user_nickname }} {{ i.user_gender }}</h1>
|
nonebot_plugin_dialectlist-3.1.0/nonebot_plugin_dialectlist/template/res/HarmonyOS_Sans_SC.woff2
ADDED
|
Binary file
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Union
|
|
3
|
+
from zoneinfo import ZoneInfo
|
|
4
|
+
|
|
5
|
+
from nonebot.adapters import Message
|
|
6
|
+
from nonebot.params import Arg
|
|
7
|
+
from nonebot.typing import T_State
|
|
8
|
+
from nonebot_plugin_alconna import AlconnaMatcher
|
|
9
|
+
|
|
10
|
+
from .config import plugin_config
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_datetime(key: str):
|
|
14
|
+
"""解析数字,并将结果存入 state 中"""
|
|
15
|
+
|
|
16
|
+
async def _key_parser(
|
|
17
|
+
matcher: AlconnaMatcher,
|
|
18
|
+
state: T_State,
|
|
19
|
+
input: Union[datetime, Message] = Arg(key),
|
|
20
|
+
):
|
|
21
|
+
if isinstance(input, datetime):
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
plaintext = input.extract_plain_text()
|
|
25
|
+
try:
|
|
26
|
+
state[key] = get_datetime_fromisoformat_with_timezone(plaintext)
|
|
27
|
+
except ValueError:
|
|
28
|
+
await matcher.reject_arg(
|
|
29
|
+
key, '请输入正确的日期,不然我没法理解呢!'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return _key_parser
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_datetime_now_with_timezone() -> datetime:
|
|
36
|
+
"""获取当前时间,并包含时区信息"""
|
|
37
|
+
if plugin_config.timezone:
|
|
38
|
+
return datetime.now(ZoneInfo(plugin_config.timezone))
|
|
39
|
+
else:
|
|
40
|
+
return datetime.now().astimezone()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_datetime_fromisoformat_with_timezone(date_string: str) -> datetime:
|
|
44
|
+
"""从 ISO-8601 格式字符串中获取时间,并包含时区信息"""
|
|
45
|
+
if not plugin_config.timezone:
|
|
46
|
+
return datetime.fromisoformat(date_string).astimezone()
|
|
47
|
+
raw = datetime.fromisoformat(date_string)
|
|
48
|
+
return (
|
|
49
|
+
raw.astimezone(ZoneInfo(plugin_config.timezone))
|
|
50
|
+
if raw.tzinfo
|
|
51
|
+
else raw.replace(tzinfo=ZoneInfo(plugin_config.timezone))
|
|
52
|
+
)
|