nonebot-plugin-dialectlist 2.0.2__tar.gz → 2.1.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.
- nonebot_plugin_dialectlist-2.1.4/PKG-INFO +203 -0
- nonebot_plugin_dialectlist-2.1.4/README.md +179 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist/__init__.py +63 -54
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist/config.py +2 -1
- nonebot_plugin_dialectlist-2.1.4/nonebot_plugin_dialectlist/model.py +11 -0
- nonebot_plugin_dialectlist-2.1.4/nonebot_plugin_dialectlist/storage.py +1 -0
- nonebot_plugin_dialectlist-2.1.4/nonebot_plugin_dialectlist/time.py +80 -0
- nonebot_plugin_dialectlist-2.1.4/nonebot_plugin_dialectlist/utils.py +151 -0
- nonebot_plugin_dialectlist-2.1.4/nonebot_plugin_dialectlist.egg-info/PKG-INFO +203 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +3 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist.egg-info/requires.txt +3 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/pyproject.toml +20 -2
- nonebot_plugin_dialectlist-2.0.2/PKG-INFO +0 -150
- nonebot_plugin_dialectlist-2.0.2/README.md +0 -129
- nonebot_plugin_dialectlist-2.0.2/nonebot_plugin_dialectlist/utils.py +0 -441
- nonebot_plugin_dialectlist-2.0.2/nonebot_plugin_dialectlist.egg-info/PKG-INFO +0 -150
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/setup.cfg +0 -0
- {nonebot_plugin_dialectlist-2.0.2 → nonebot_plugin_dialectlist-2.1.4}/setup.py +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: nonebot_plugin_dialectlist
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: 看看你群群友有多能说
|
|
5
|
+
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: <4.0,>=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: nonebot2>=2.3.1
|
|
10
|
+
Requires-Dist: nonebot-plugin-chatrecorder>=0.6.0
|
|
11
|
+
Requires-Dist: pygal>=3.0.4
|
|
12
|
+
Requires-Dist: requests>=2.32.3
|
|
13
|
+
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
14
|
+
Requires-Dist: nonebot-plugin-alconna>=0.46.6
|
|
15
|
+
Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
16
|
+
Requires-Dist: nonebot-plugin-userinfo>=0.2.4
|
|
17
|
+
Requires-Dist: pyecharts>=2.0.5
|
|
18
|
+
Requires-Dist: nonebot-plugin-htmlrender>=0.3.2
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: ruff>=0.4.9; extra == "dev"
|
|
21
|
+
Requires-Dist: setuptools>=70.0.0; extra == "dev"
|
|
22
|
+
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
23
|
+
Requires-Dist: nb-cli>=0.7.6; extra == "dev"
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
27
|
+
<br>
|
|
28
|
+
<p><img src="https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png" width="240" alt="NoneBotPluginText"></p>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
|
|
33
|
+
# 📃话痨排行榜
|
|
34
|
+
nonebot-plugin-dialectlist
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-wordcloud">
|
|
38
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-wordcloud.svg" alt="pypi">
|
|
39
|
+
</a>
|
|
40
|
+
|
|
41
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
42
|
+
|
|
43
|
+
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
44
|
+
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1128359833-orange?style=flat-square" alt="QQ Chat Group">
|
|
45
|
+
</a>
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
\>💬**看看群友们这些天在群里水了多少话**💬<
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
## 💿 安装
|
|
52
|
+
|
|
53
|
+
通过`pip`或`nb`安装;
|
|
54
|
+
|
|
55
|
+
>**通过 pip **安装
|
|
56
|
+
|
|
57
|
+
`pip install nonebot-plugin-dialectlist`
|
|
58
|
+
|
|
59
|
+
>**通过 nb **安装
|
|
60
|
+
|
|
61
|
+
`nb plugin install nonebot-plugin-dialectlist`
|
|
62
|
+
|
|
63
|
+
### ✅ 插件依赖于
|
|
64
|
+
|
|
65
|
+
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————储存历史的消息
|
|
66
|
+
2. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
67
|
+
3. [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) ————定时发送排行榜信息
|
|
68
|
+
4. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
69
|
+
5. [nonebot-plugin-cesaa](https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere) ————实现多平台
|
|
70
|
+
|
|
71
|
+
## ⚙ 配置
|
|
72
|
+
|
|
73
|
+
需要**提前配置**本插件所**依赖的插件**!
|
|
74
|
+
|
|
75
|
+
在 .env 中,可以添加以下配置项
|
|
76
|
+
```python
|
|
77
|
+
dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
|
|
78
|
+
dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
|
|
79
|
+
dialectlist__get_num = 10 #获取人数数量
|
|
80
|
+
dialectlist__visualization = True #是否可视化
|
|
81
|
+
dialectlist__visualization_type = '圆环图' #可视化方案
|
|
82
|
+
dialectlist__font = 'SimHei'#字体格式
|
|
83
|
+
dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
|
|
84
|
+
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
|
85
|
+
```
|
|
86
|
+
💭也可以不进行配置,这将会使插件按照默认配置运行
|
|
87
|
+
|
|
88
|
+
### ⚠ 注意!!
|
|
89
|
+
|
|
90
|
+
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
|
91
|
+
|
|
92
|
+
## 🗨命令
|
|
93
|
+
__!!注意!!__
|
|
94
|
+
新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
|
|
95
|
+
同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给[盘古之白](https://github.com/vinta/pangu.js)风格爱好者的福利吧?)
|
|
96
|
+
|
|
97
|
+
### 🎨一般用法
|
|
98
|
+
|
|
99
|
+
-`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
|
|
100
|
+
|
|
101
|
+
-`/今日B话榜` ————看看今天的群友发了多少消息!
|
|
102
|
+
|
|
103
|
+
-`/昨日B话榜` ————看看昨天的群友发了多少消息!
|
|
104
|
+
|
|
105
|
+
-`/前日B话榜` ————看看前天的群友发了多少消息!
|
|
106
|
+
|
|
107
|
+
-`/本周B话榜` ————看看本周的群友发了多少消息!
|
|
108
|
+
|
|
109
|
+
-`/上周B话榜` ————看看上周的群友发了多少消息!
|
|
110
|
+
|
|
111
|
+
-`/本月B话榜` ————看看这个月的群友发了多少消息!
|
|
112
|
+
|
|
113
|
+
-`/年度B话榜` ————看看今年的群友发了多少消息!
|
|
114
|
+
|
|
115
|
+
-`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
|
|
116
|
+
|
|
117
|
+
### 🚀进阶用法
|
|
118
|
+
|
|
119
|
+
`/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601格式时间} {群号}`
|
|
120
|
+
|
|
121
|
+
如:`/B话榜 历史 2024-01-01~2024-01-02 12345678`
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## 📖版本
|
|
125
|
+
|
|
126
|
+
### V1.0
|
|
127
|
+
|
|
128
|
+
- 看看群里群友能有多话痨
|
|
129
|
+
|
|
130
|
+
### V1.1
|
|
131
|
+
|
|
132
|
+
- 支持频道咯!(*^_^*)
|
|
133
|
+
|
|
134
|
+
### V1.2
|
|
135
|
+
|
|
136
|
+
- 排行榜可视化
|
|
137
|
+
|
|
138
|
+
### V1.3
|
|
139
|
+
|
|
140
|
+
- 添加了一些可配置项
|
|
141
|
+
|
|
142
|
+
### V1.4
|
|
143
|
+
|
|
144
|
+
- 适配新版本的 chatrecorder, 暂时停止频道支持
|
|
145
|
+
|
|
146
|
+
### V2.0
|
|
147
|
+
|
|
148
|
+
- 理论支持全平台!暂停图片支持。
|
|
149
|
+
|
|
150
|
+
## 💪 目前支持的平台
|
|
151
|
+
|
|
152
|
+
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |
|
|
153
|
+
|:-----:|:----:|:----:| :----: |
|
|
154
|
+
| Onebot | ✅ | ✅ | NapCat + Window11|
|
|
155
|
+
| 飞书 | ❌ | ❓ | 🤔 |
|
|
156
|
+
| Red | ❌ | ❓ | 🤔 |
|
|
157
|
+
| DoDo | ❌ | ❓ | 🤔 |
|
|
158
|
+
| Mirai | ❌ | ❓ | 🤔 |
|
|
159
|
+
| 开黑啦 | ❌ | ❓ | 🤔 |
|
|
160
|
+
| Kritor | ❌ | ❓ | 🤔 |
|
|
161
|
+
| Ntchat | ❌ | ❓ | 🤔 |
|
|
162
|
+
| Satori | ❌ | ❓ | 🤔 |
|
|
163
|
+
| Telegram | ❌ | ❓ | 🤔 |
|
|
164
|
+
| Discord | ❌ | ❓ | 🤔 |
|
|
165
|
+
| Tailchat | ❌ | ❓ | 🤔 |
|
|
166
|
+
| QQ 官方接口 | ❌ | ❓ | 🤔 |
|
|
167
|
+
| Rocket.Chat | ❌ | ❓ | 🤔 |
|
|
168
|
+
|
|
169
|
+
- 如果你测试过能够使用,请在 Issue 中指出
|
|
170
|
+
|
|
171
|
+
## 📦另外
|
|
172
|
+
|
|
173
|
+
### 😳加入作者的 BUG 反馈群 ~~(🥵女装粉丝群)~~
|
|
174
|
+
|
|
175
|
+
[群连接](https://qm.qq.com/q/Yty2yc9Bee)
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary>群二维码 点我展开</summary>
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
</details>
|
|
183
|
+
|
|
184
|
+
### 💕感谢
|
|
185
|
+
|
|
186
|
+
本插件的__init__.py 中的处理函数参考了词云中的方法 ~~(其实大部分都是 Ctrl+C Ctr+V)~~
|
|
187
|
+
|
|
188
|
+
[nonebot-plugin-wordcloud](https://github.com/he0119/nonebot-plugin-wordcloud)
|
|
189
|
+
|
|
190
|
+
### 🎀TODO
|
|
191
|
+
|
|
192
|
+
- [x] 适配全平台
|
|
193
|
+
|
|
194
|
+
- [ ] 私聊的查询(超级用户可以任意查询群聊的信息)
|
|
195
|
+
|
|
196
|
+
- [ ] 关键词查询
|
|
197
|
+
|
|
198
|
+
- [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
|
|
199
|
+
|
|
200
|
+
待补充。.....
|
|
201
|
+
|
|
202
|
+
### 👾题外话
|
|
203
|
+
~~整个项目快被我写成屎山了~~
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
3
|
+
<br>
|
|
4
|
+
<p><img src="https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png" width="240" alt="NoneBotPluginText"></p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
|
|
9
|
+
# 📃话痨排行榜
|
|
10
|
+
nonebot-plugin-dialectlist
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-wordcloud">
|
|
14
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-wordcloud.svg" alt="pypi">
|
|
15
|
+
</a>
|
|
16
|
+
|
|
17
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
18
|
+
|
|
19
|
+
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
20
|
+
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1128359833-orange?style=flat-square" alt="QQ Chat Group">
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
\>💬**看看群友们这些天在群里水了多少话**💬<
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
## 💿 安装
|
|
28
|
+
|
|
29
|
+
通过`pip`或`nb`安装;
|
|
30
|
+
|
|
31
|
+
>**通过 pip **安装
|
|
32
|
+
|
|
33
|
+
`pip install nonebot-plugin-dialectlist`
|
|
34
|
+
|
|
35
|
+
>**通过 nb **安装
|
|
36
|
+
|
|
37
|
+
`nb plugin install nonebot-plugin-dialectlist`
|
|
38
|
+
|
|
39
|
+
### ✅ 插件依赖于
|
|
40
|
+
|
|
41
|
+
1. [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) ————储存历史的消息
|
|
42
|
+
2. [nonebot-plugin-userinfo](https://github.com/noneplugin/nonebot-plugin-userinfo) ————获取用户信息
|
|
43
|
+
3. [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) ————定时发送排行榜信息
|
|
44
|
+
4. [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) ————实现命令解析
|
|
45
|
+
5. [nonebot-plugin-cesaa](https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere) ————实现多平台
|
|
46
|
+
|
|
47
|
+
## ⚙ 配置
|
|
48
|
+
|
|
49
|
+
需要**提前配置**本插件所**依赖的插件**!
|
|
50
|
+
|
|
51
|
+
在 .env 中,可以添加以下配置项
|
|
52
|
+
```python
|
|
53
|
+
dialectlist__string_format = '第{index}名:\n{nickname},{chatdatanum}条消息、n' #消息格式
|
|
54
|
+
dialectlist__string_suffix_format = '你们的职业是水群吗?————MYX\n 计算花费时间:{timecost}秒' #消息后缀格式
|
|
55
|
+
dialectlist__get_num = 10 #获取人数数量
|
|
56
|
+
dialectlist__visualization = True #是否可视化
|
|
57
|
+
dialectlist__visualization_type = '圆环图' #可视化方案
|
|
58
|
+
dialectlist__font = 'SimHei'#字体格式
|
|
59
|
+
dialectlist__excluded_people = []#排除的人的 QQ 号(或频道号?(未经测试))
|
|
60
|
+
dialectlist__excluded_self = True #是否排除机器人自己 QQ
|
|
61
|
+
```
|
|
62
|
+
💭也可以不进行配置,这将会使插件按照默认配置运行
|
|
63
|
+
|
|
64
|
+
### ⚠ 注意!!
|
|
65
|
+
|
|
66
|
+
> 在旧版插件(2.0.0 以下)中,dialectlist 与后面的配置项只隔了一个下划线,若更新到新版本以后需要俩个下划线。
|
|
67
|
+
|
|
68
|
+
## 🗨命令
|
|
69
|
+
__!!注意!!__
|
|
70
|
+
新版本指令调用方式改变,改为更易理解也更好打的 B 话榜。
|
|
71
|
+
同时也可以用类似 `/今日废话榜` 的方式(只要改前面的就好了)(算是给[盘古之白](https://github.com/vinta/pangu.js)风格爱好者的福利吧?)
|
|
72
|
+
|
|
73
|
+
### 🎨一般用法
|
|
74
|
+
|
|
75
|
+
-`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
|
|
76
|
+
|
|
77
|
+
-`/今日B话榜` ————看看今天的群友发了多少消息!
|
|
78
|
+
|
|
79
|
+
-`/昨日B话榜` ————看看昨天的群友发了多少消息!
|
|
80
|
+
|
|
81
|
+
-`/前日B话榜` ————看看前天的群友发了多少消息!
|
|
82
|
+
|
|
83
|
+
-`/本周B话榜` ————看看本周的群友发了多少消息!
|
|
84
|
+
|
|
85
|
+
-`/上周B话榜` ————看看上周的群友发了多少消息!
|
|
86
|
+
|
|
87
|
+
-`/本月B话榜` ————看看这个月的群友发了多少消息!
|
|
88
|
+
|
|
89
|
+
-`/年度B话榜` ————看看今年的群友发了多少消息!
|
|
90
|
+
|
|
91
|
+
-`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
|
|
92
|
+
|
|
93
|
+
### 🚀进阶用法
|
|
94
|
+
|
|
95
|
+
`/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601格式时间} {群号}`
|
|
96
|
+
|
|
97
|
+
如:`/B话榜 历史 2024-01-01~2024-01-02 12345678`
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## 📖版本
|
|
101
|
+
|
|
102
|
+
### V1.0
|
|
103
|
+
|
|
104
|
+
- 看看群里群友能有多话痨
|
|
105
|
+
|
|
106
|
+
### V1.1
|
|
107
|
+
|
|
108
|
+
- 支持频道咯!(*^_^*)
|
|
109
|
+
|
|
110
|
+
### V1.2
|
|
111
|
+
|
|
112
|
+
- 排行榜可视化
|
|
113
|
+
|
|
114
|
+
### V1.3
|
|
115
|
+
|
|
116
|
+
- 添加了一些可配置项
|
|
117
|
+
|
|
118
|
+
### V1.4
|
|
119
|
+
|
|
120
|
+
- 适配新版本的 chatrecorder, 暂时停止频道支持
|
|
121
|
+
|
|
122
|
+
### V2.0
|
|
123
|
+
|
|
124
|
+
- 理论支持全平台!暂停图片支持。
|
|
125
|
+
|
|
126
|
+
## 💪 目前支持的平台
|
|
127
|
+
|
|
128
|
+
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |
|
|
129
|
+
|:-----:|:----:|:----:| :----: |
|
|
130
|
+
| Onebot | ✅ | ✅ | NapCat + Window11|
|
|
131
|
+
| 飞书 | ❌ | ❓ | 🤔 |
|
|
132
|
+
| Red | ❌ | ❓ | 🤔 |
|
|
133
|
+
| DoDo | ❌ | ❓ | 🤔 |
|
|
134
|
+
| Mirai | ❌ | ❓ | 🤔 |
|
|
135
|
+
| 开黑啦 | ❌ | ❓ | 🤔 |
|
|
136
|
+
| Kritor | ❌ | ❓ | 🤔 |
|
|
137
|
+
| Ntchat | ❌ | ❓ | 🤔 |
|
|
138
|
+
| Satori | ❌ | ❓ | 🤔 |
|
|
139
|
+
| Telegram | ❌ | ❓ | 🤔 |
|
|
140
|
+
| Discord | ❌ | ❓ | 🤔 |
|
|
141
|
+
| Tailchat | ❌ | ❓ | 🤔 |
|
|
142
|
+
| QQ 官方接口 | ❌ | ❓ | 🤔 |
|
|
143
|
+
| Rocket.Chat | ❌ | ❓ | 🤔 |
|
|
144
|
+
|
|
145
|
+
- 如果你测试过能够使用,请在 Issue 中指出
|
|
146
|
+
|
|
147
|
+
## 📦另外
|
|
148
|
+
|
|
149
|
+
### 😳加入作者的 BUG 反馈群 ~~(🥵女装粉丝群)~~
|
|
150
|
+
|
|
151
|
+
[群连接](https://qm.qq.com/q/Yty2yc9Bee)
|
|
152
|
+
|
|
153
|
+
<details>
|
|
154
|
+
<summary>群二维码 点我展开</summary>
|
|
155
|
+
|
|
156
|
+

|
|
157
|
+
|
|
158
|
+
</details>
|
|
159
|
+
|
|
160
|
+
### 💕感谢
|
|
161
|
+
|
|
162
|
+
本插件的__init__.py 中的处理函数参考了词云中的方法 ~~(其实大部分都是 Ctrl+C Ctr+V)~~
|
|
163
|
+
|
|
164
|
+
[nonebot-plugin-wordcloud](https://github.com/he0119/nonebot-plugin-wordcloud)
|
|
165
|
+
|
|
166
|
+
### 🎀TODO
|
|
167
|
+
|
|
168
|
+
- [x] 适配全平台
|
|
169
|
+
|
|
170
|
+
- [ ] 私聊的查询(超级用户可以任意查询群聊的信息)
|
|
171
|
+
|
|
172
|
+
- [ ] 关键词查询
|
|
173
|
+
|
|
174
|
+
- [ ] 尝试利用 jinja2 模板引擎制作可视化图片 (((真的可以吗?))
|
|
175
|
+
|
|
176
|
+
待补充。.....
|
|
177
|
+
|
|
178
|
+
### 👾题外话
|
|
179
|
+
~~整个项目快被我写成屎山了~~
|
|
@@ -2,12 +2,13 @@ from nonebot import require
|
|
|
2
2
|
|
|
3
3
|
require("nonebot_plugin_chatrecorder")
|
|
4
4
|
require("nonebot_plugin_apscheduler")
|
|
5
|
+
require("nonebot_plugin_htmlrender")
|
|
5
6
|
require("nonebot_plugin_userinfo")
|
|
6
7
|
require("nonebot_plugin_alconna")
|
|
7
8
|
require("nonebot_plugin_cesaa")
|
|
8
9
|
|
|
9
10
|
import re
|
|
10
|
-
|
|
11
|
+
import os
|
|
11
12
|
import nonebot_plugin_saa as saa
|
|
12
13
|
|
|
13
14
|
from typing import Union, Optional, List
|
|
@@ -37,6 +38,8 @@ from nonebot_plugin_alconna import (
|
|
|
37
38
|
)
|
|
38
39
|
|
|
39
40
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
41
|
+
from nonebot_plugin_localstore import get_cache_file
|
|
42
|
+
from nonebot_plugin_htmlrender import html_to_pic
|
|
40
43
|
from nonebot_plugin_userinfo import get_user_info
|
|
41
44
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
42
45
|
|
|
@@ -44,12 +47,13 @@ from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
|
44
47
|
# from .function import *
|
|
45
48
|
from .config import Config, plugin_config
|
|
46
49
|
from .usage import __usage__
|
|
50
|
+
from .time import get_datetime_fromisoformat_with_timezone, get_datetime_now_with_timezone,parse_datetime
|
|
51
|
+
from .model import UserRankInfo
|
|
47
52
|
from .utils import (
|
|
48
|
-
get_datetime_fromisoformat_with_timezone,
|
|
49
|
-
get_datetime_now_with_timezone,
|
|
50
53
|
got_rank,
|
|
51
54
|
msg_counter,
|
|
52
55
|
persist_id2user_id,
|
|
56
|
+
get_rank_image
|
|
53
57
|
)
|
|
54
58
|
|
|
55
59
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -75,24 +79,26 @@ class SameTime(ArparmaBehavior):
|
|
|
75
79
|
interface.behave_fail()
|
|
76
80
|
|
|
77
81
|
|
|
82
|
+
def wrapper(slot: Union[int, str], content: Optional[str]) -> str:
|
|
83
|
+
if slot == "type" and content:
|
|
84
|
+
return content
|
|
85
|
+
return "" # pragma: no cover
|
|
86
|
+
|
|
87
|
+
|
|
78
88
|
rank_cmd = on_alconna(
|
|
79
89
|
Alconna(
|
|
80
90
|
"B话榜",
|
|
81
91
|
Args["type?", ["今日", "昨日", "本周", "上周", "本月", "上月", "年度", "历史"]][
|
|
82
|
-
"time?",
|
|
92
|
+
"time?",str,][
|
|
93
|
+
"group_id?", str
|
|
83
94
|
],
|
|
84
95
|
behaviors=[SameTime()],
|
|
85
96
|
),
|
|
97
|
+
aliases={"废话榜"},
|
|
86
98
|
use_cmd_start=True,
|
|
87
99
|
)
|
|
88
100
|
|
|
89
101
|
|
|
90
|
-
def wrapper(slot: Union[int, str], content: Optional[str]) -> str:
|
|
91
|
-
if slot == "type" and content:
|
|
92
|
-
return content
|
|
93
|
-
return "" # pragma: no cover
|
|
94
|
-
|
|
95
|
-
|
|
96
102
|
rank_cmd.shortcut(
|
|
97
103
|
r"(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)B话榜",
|
|
98
104
|
{
|
|
@@ -104,40 +110,23 @@ rank_cmd.shortcut(
|
|
|
104
110
|
)
|
|
105
111
|
|
|
106
112
|
|
|
107
|
-
def parse_datetime(key: str):
|
|
108
|
-
"""解析数字,并将结果存入 state 中"""
|
|
109
|
-
|
|
110
|
-
async def _key_parser(
|
|
111
|
-
matcher: AlconnaMatcher,
|
|
112
|
-
state: T_State,
|
|
113
|
-
input: Union[datetime, Message] = Arg(key),
|
|
114
|
-
):
|
|
115
|
-
if isinstance(input, datetime):
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
plaintext = input.extract_plain_text()
|
|
119
|
-
try:
|
|
120
|
-
state[key] = get_datetime_fromisoformat_with_timezone(plaintext)
|
|
121
|
-
except ValueError:
|
|
122
|
-
await matcher.reject_arg(key, "请输入正确的日期,不然我没法理解呢!")
|
|
123
|
-
|
|
124
|
-
return _key_parser
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
# TODO 处理函数更新
|
|
128
|
-
# 参考词云
|
|
129
|
-
|
|
130
|
-
|
|
131
113
|
# 这段函数完全抄的词云
|
|
132
114
|
@rank_cmd.handle()
|
|
133
115
|
async def _group_message(
|
|
134
116
|
state: T_State,
|
|
117
|
+
session: Session = Depends(extract_session),
|
|
135
118
|
type: Optional[str] = None,
|
|
136
119
|
time: Optional[str] = None,
|
|
120
|
+
group_id: Optional[str] = None,
|
|
137
121
|
):
|
|
138
122
|
|
|
139
123
|
dt = get_datetime_now_with_timezone()
|
|
140
124
|
|
|
125
|
+
if group_id is None:
|
|
126
|
+
group_id = session.id2
|
|
127
|
+
|
|
128
|
+
state["group_id"] = group_id
|
|
129
|
+
|
|
141
130
|
if not type:
|
|
142
131
|
await rank_cmd.finish(__plugin_meta__.usage)
|
|
143
132
|
|
|
@@ -204,16 +193,25 @@ async def _group_message(
|
|
|
204
193
|
prompt="请输入你要查询的结束日期(如 2022-02-22)",
|
|
205
194
|
parameterless=[Depends(parse_datetime("stop"))],
|
|
206
195
|
)
|
|
196
|
+
@rank_cmd.got("group_id", prompt="请输入你要查询的群号。")
|
|
207
197
|
async def handle_rank(
|
|
208
198
|
bot: Bot,
|
|
209
199
|
event: Event,
|
|
210
200
|
session: Session = Depends(extract_session),
|
|
211
201
|
start: datetime = Arg(),
|
|
212
202
|
stop: datetime = Arg(),
|
|
203
|
+
group_id: str = Arg(),
|
|
213
204
|
):
|
|
214
|
-
|
|
205
|
+
if group_id:
|
|
206
|
+
id = group_id
|
|
207
|
+
else:
|
|
208
|
+
id = session.id2
|
|
209
|
+
|
|
210
|
+
if not id:
|
|
211
|
+
await saa.Text("没有指定群哦").finish()
|
|
212
|
+
|
|
215
213
|
messages = await get_message_records(
|
|
216
|
-
|
|
214
|
+
id2s=[id],
|
|
217
215
|
id_type=SessionIdType.GROUP,
|
|
218
216
|
include_bot_id=False,
|
|
219
217
|
include_bot_type=False,
|
|
@@ -222,34 +220,45 @@ async def handle_rank(
|
|
|
222
220
|
time_stop=stop,
|
|
223
221
|
exclude_id1s=plugin_config.excluded_people,
|
|
224
222
|
)
|
|
225
|
-
|
|
226
223
|
rank = got_rank(msg_counter(messages))
|
|
224
|
+
rank2: List[UserRankInfo] = []
|
|
227
225
|
ids = await persist_id2user_id([int(i[0]) for i in rank])
|
|
228
226
|
for i in range(len(rank)):
|
|
229
227
|
rank[i][0] = str(ids[i])
|
|
228
|
+
logger.debug(rank[i])
|
|
229
|
+
|
|
230
|
+
total = sum([i[1] for i in rank])
|
|
230
231
|
|
|
231
|
-
string: str = ""
|
|
232
|
-
nicknames: List = []
|
|
233
232
|
for i in rank:
|
|
234
233
|
if user_info := await get_user_info(bot, event, user_id=str(i[0])):
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
234
|
+
user_nickname = user_info.user_displayname\
|
|
235
|
+
if user_info.user_displayname\
|
|
236
|
+
else user_info.user_name\
|
|
237
|
+
if user_info.user_name\
|
|
238
|
+
else\
|
|
239
|
+
user_info.user_id
|
|
240
|
+
user_avatar = await user_info.user_avatar.get_image()\
|
|
241
|
+
if user_info.user_avatar\
|
|
242
|
+
else open(os.path.dirname(os.path.abspath(__file__))+"/template/avatar/default.jpg", "rb").read()
|
|
243
|
+
user = UserRankInfo(**user_info.model_dump(),
|
|
244
|
+
user_bnum=i[1],
|
|
245
|
+
user_proportion= round(i[1] / total * 100, 2),
|
|
246
|
+
user_index= rank.index(i) + 1,
|
|
247
|
+
user_nickname=user_nickname,
|
|
248
|
+
user_avatar_bytes= user_avatar,
|
|
243
249
|
)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
user.user_gender="她" if user_info.user_gender == "female" else "他" if user_info.user_gender == "male" else "ta"
|
|
251
|
+
rank2.append(user)
|
|
252
|
+
|
|
253
|
+
string: str = ""
|
|
247
254
|
for i in range(len(rank)):
|
|
248
|
-
index = i + 1
|
|
249
|
-
nickname, chatdatanum = nicknames[i], rank[i][1]
|
|
250
255
|
str_example = plugin_config.string_format.format(
|
|
251
|
-
index=
|
|
256
|
+
index=rank2[i].user_index,
|
|
257
|
+
nickname=rank2[i].user_nickname,
|
|
258
|
+
chatdatanum=rank2[i].user_bnum
|
|
252
259
|
)
|
|
253
260
|
string += str_example
|
|
261
|
+
|
|
262
|
+
image = await get_rank_image(rank2)
|
|
254
263
|
|
|
255
|
-
await saa.Text(string).finish(reply=True)
|
|
264
|
+
await (saa.Text(string) + saa.Image(image)).finish(reply=True)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Optional, Literal, List
|
|
2
2
|
from nonebot import get_driver, get_plugin_config
|
|
3
|
-
from pydantic import BaseModel
|
|
3
|
+
from pydantic import BaseModel
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class ScopedConfig(BaseModel):
|
|
@@ -9,6 +9,7 @@ class ScopedConfig(BaseModel):
|
|
|
9
9
|
timezone: Optional[str] = "Asia/Shanghai"
|
|
10
10
|
excluded_self: bool = True
|
|
11
11
|
string_format: str = "第{index}名:\n{nickname},{chatdatanum}条消息\n" # 消息格式
|
|
12
|
+
template_path: str = "./template/rank_template.j2" # 模板路径
|
|
12
13
|
visualization: bool = True # 是否可视化
|
|
13
14
|
excluded_people: List[str] = [] # 排除的人的QQ号
|
|
14
15
|
visualization_type: Literal["饼图", "圆环图", "柱状图"] = "圆环图" # 可视化方案
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import Optional, Literal, List, Union
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
from nonebot_plugin_userinfo import get_user_info, UserInfo
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UserRankInfo(UserInfo):
|
|
7
|
+
user_bnum: int
|
|
8
|
+
user_proportion: float
|
|
9
|
+
user_nickname: str
|
|
10
|
+
user_index: Union[int,str]
|
|
11
|
+
user_avatar_bytes: bytes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO 使用计数缓存进行数据库查询优化,避免一次性查询过多消息导致内存爆炸。
|