nonebot-plugin-dialectlist 2.6.2__tar.gz → 2.7.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.6.2/nonebot_plugin_dialectlist.egg-info → nonebot_plugin_dialectlist-2.7.1}/PKG-INFO +7 -4
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/README.md +3 -1
- nonebot_plugin_dialectlist-2.7.1/nonebot_plugin_dialectlist/__init__.py +374 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/config.py +3 -2
- nonebot_plugin_dialectlist-2.7.1/nonebot_plugin_dialectlist/migrations/fb88e4d27eb8_update_dialectlist.py +47 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/model.py +2 -1
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/storage.py +13 -11
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/time.py +4 -5
- nonebot_plugin_dialectlist-2.7.1/nonebot_plugin_dialectlist/utils.py +263 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1/nonebot_plugin_dialectlist.egg-info}/PKG-INFO +7 -4
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +1 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist.egg-info/requires.txt +1 -1
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/pyproject.toml +5 -9
- nonebot_plugin_dialectlist-2.6.2/nonebot_plugin_dialectlist/__init__.py +0 -369
- nonebot_plugin_dialectlist-2.6.2/nonebot_plugin_dialectlist/utils.py +0 -279
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/LICENSE +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/MANIFEST.in +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/template/avatar/default.jpg +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/template/css/style.css +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/template/rank_template.j2 +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.6.2 → nonebot_plugin_dialectlist-2.7.1}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-dialectlist
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.1
|
|
4
4
|
Summary: 看看你群群友有多能说
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
7
7
|
Requires-Python: <4.0,>=3.9
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: nonebot-plugin-chatrecorder
|
|
10
|
+
Requires-Dist: nonebot-plugin-chatrecorder>=0.7.0
|
|
11
11
|
Requires-Dist: nonebot-plugin-orm[default]
|
|
12
12
|
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
13
13
|
Requires-Dist: nonebot-plugin-alconna>=0.50.2
|
|
@@ -25,6 +25,7 @@ Requires-Dist: nb-cli>=0.7.6; 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
|
+
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
<div align="center">
|
|
30
31
|
<a href="https://v2.nonebot.dev/store"><img src="./docs/NoneBotPlugin.svg" width="400" alt="NoneBotPluginLogo"></a>
|
|
@@ -41,7 +42,7 @@ nonebot-plugin-dialectlist
|
|
|
41
42
|
<a href="https://pypi.python.org/pypi/nonebot-plugin-dialectlist">
|
|
42
43
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
43
44
|
</a>
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
46
47
|
|
|
47
48
|
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
@@ -49,6 +50,8 @@ nonebot-plugin-dialectlist
|
|
|
49
50
|
</a>
|
|
50
51
|
</p>
|
|
51
52
|
|
|
53
|
+
[](https://wakatime.com/badge/user/114aee90-a5f9-49aa-b441-9eca7eebfda3/project/68aaa2a1-fb8a-4b00-bb66-ee67e8a3f3b0)
|
|
54
|
+
|
|
52
55
|
\>💬**看看群友们这些天在群里水了多少话**💬<
|
|
53
56
|
</div>
|
|
54
57
|
|
|
@@ -13,7 +13,7 @@ nonebot-plugin-dialectlist
|
|
|
13
13
|
<a href="https://pypi.python.org/pypi/nonebot-plugin-dialectlist">
|
|
14
14
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-dialectlist.svg" alt="pypi">
|
|
15
15
|
</a>
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
|
18
18
|
|
|
19
19
|
<a href="https://qm.qq.com/q/Yty2yc9Bee">
|
|
@@ -21,6 +21,8 @@ nonebot-plugin-dialectlist
|
|
|
21
21
|
</a>
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
|
+
[](https://wakatime.com/badge/user/114aee90-a5f9-49aa-b441-9eca7eebfda3/project/68aaa2a1-fb8a-4b00-bb66-ee67e8a3f3b0)
|
|
25
|
+
|
|
24
26
|
\>💬**看看群友们这些天在群里水了多少话**💬<
|
|
25
27
|
</div>
|
|
26
28
|
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
from nonebot import require
|
|
2
|
+
|
|
3
|
+
require('nonebot_plugin_chatrecorder')
|
|
4
|
+
require('nonebot_plugin_apscheduler')
|
|
5
|
+
require('nonebot_plugin_htmlrender')
|
|
6
|
+
require('nonebot_plugin_userinfo')
|
|
7
|
+
require('nonebot_plugin_alconna')
|
|
8
|
+
require('nonebot_plugin_uninfo')
|
|
9
|
+
require('nonebot_plugin_cesaa')
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
import time as t
|
|
13
|
+
from datetime import datetime, timedelta
|
|
14
|
+
from typing import Optional, Union
|
|
15
|
+
|
|
16
|
+
import nonebot_plugin_saa as saa
|
|
17
|
+
from arclet.alconna import ArparmaBehavior
|
|
18
|
+
from arclet.alconna.arparma import Arparma
|
|
19
|
+
from nonebot import on_command
|
|
20
|
+
from nonebot.adapters import Bot, Event
|
|
21
|
+
from nonebot.log import logger
|
|
22
|
+
from nonebot.params import Arg, Depends
|
|
23
|
+
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
|
24
|
+
from nonebot.typing import T_State
|
|
25
|
+
from nonebot_plugin_alconna import (
|
|
26
|
+
Alconna,
|
|
27
|
+
Args,
|
|
28
|
+
At,
|
|
29
|
+
Field,
|
|
30
|
+
Match,
|
|
31
|
+
Option,
|
|
32
|
+
on_alconna,
|
|
33
|
+
)
|
|
34
|
+
from nonebot_plugin_chatrecorder import get_message_records
|
|
35
|
+
from nonebot_plugin_uninfo import Session, Uninfo, get_session
|
|
36
|
+
|
|
37
|
+
from .config import Config, plugin_config
|
|
38
|
+
# from .storage import build_cache, get_cache
|
|
39
|
+
from .time import (
|
|
40
|
+
get_datetime_fromisoformat_with_timezone,
|
|
41
|
+
get_datetime_now_with_timezone,
|
|
42
|
+
parse_datetime,
|
|
43
|
+
)
|
|
44
|
+
from .usage import __usage__
|
|
45
|
+
from .utils import (
|
|
46
|
+
get_rank_image,
|
|
47
|
+
get_user_infos,
|
|
48
|
+
got_rank,
|
|
49
|
+
msg_counter,
|
|
50
|
+
persist_id2user_id,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
__plugin_meta__ = PluginMetadata(
|
|
54
|
+
name='B话排行榜',
|
|
55
|
+
description='调查群U的B话数量,以一定的顺序排序后排序出来。',
|
|
56
|
+
usage=__usage__,
|
|
57
|
+
homepage='https://github.com/ChenXu233/nonebot_plugin_dialectlist',
|
|
58
|
+
type='application',
|
|
59
|
+
supported_adapters=inherit_supported_adapters(
|
|
60
|
+
'nonebot_plugin_chatrecorder',
|
|
61
|
+
'nonebot_plugin_saa',
|
|
62
|
+
'nonebot_plugin_alconna',
|
|
63
|
+
),
|
|
64
|
+
config=Config,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# 抄的词云,不过真的很适合B话榜。
|
|
69
|
+
class SameTime(ArparmaBehavior):
|
|
70
|
+
def operate(self, interface: Arparma):
|
|
71
|
+
type = interface.query('type')
|
|
72
|
+
time = interface.query('time')
|
|
73
|
+
if type is None and time:
|
|
74
|
+
interface.behave_fail()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def wrapper(slot: Union[int, str], content: Optional[str], context) -> str:
|
|
78
|
+
if slot == 'type' and content:
|
|
79
|
+
return content
|
|
80
|
+
return '' # pragma: no cover
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
build_cache_cmd = on_command('build_cache', aliases={'重建缓存'}, block=True)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@build_cache_cmd.handle()
|
|
87
|
+
async def _build_cache(bot: Bot, event: Event):
|
|
88
|
+
return
|
|
89
|
+
await saa.Text('正在重建缓存,请稍等。').send(reply=True) # type: ignore
|
|
90
|
+
await build_cache()
|
|
91
|
+
await saa.Text('重建缓存完成。').send(reply=True)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
b_cmd = on_alconna(
|
|
95
|
+
Alconna(
|
|
96
|
+
'看看B话',
|
|
97
|
+
Args['at', [str, At], Field(completion=lambda: '请想要查询的人的QQ号')],
|
|
98
|
+
Option('-g|--group_id', Args['group_id?', str]),
|
|
99
|
+
Option('-k|--keyword', Args['keyword?', str]),
|
|
100
|
+
),
|
|
101
|
+
aliases={'kkb'},
|
|
102
|
+
use_cmd_start=True,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@b_cmd.handle()
|
|
107
|
+
async def handle_b_cmd(
|
|
108
|
+
at: Match[str | At],
|
|
109
|
+
group_id: Match[str],
|
|
110
|
+
keyword: Match[str],
|
|
111
|
+
uninfo: Uninfo,
|
|
112
|
+
session: Session = Depends(get_session),
|
|
113
|
+
):
|
|
114
|
+
id = at.result
|
|
115
|
+
if isinstance(id, At):
|
|
116
|
+
id = id.target
|
|
117
|
+
if group_id.available:
|
|
118
|
+
gid = group_id.result
|
|
119
|
+
else:
|
|
120
|
+
gid = session.scene.id
|
|
121
|
+
|
|
122
|
+
if not gid:
|
|
123
|
+
await b_cmd.finish('请指定群号。')
|
|
124
|
+
|
|
125
|
+
if keyword.available:
|
|
126
|
+
keywords = keyword.result
|
|
127
|
+
else:
|
|
128
|
+
keywords = None
|
|
129
|
+
|
|
130
|
+
messages = await get_message_records(
|
|
131
|
+
scene_ids=[gid],
|
|
132
|
+
user_ids=[id],
|
|
133
|
+
types=['message'], # 排除机器人自己发的消息
|
|
134
|
+
exclude_user_ids=plugin_config.excluded_people,
|
|
135
|
+
)
|
|
136
|
+
d = msg_counter(messages, keywords)
|
|
137
|
+
rank = got_rank(d)
|
|
138
|
+
if not rank:
|
|
139
|
+
await b_cmd.finish(
|
|
140
|
+
f'该用户在群“{uninfo.scene.name}”关于“{keyword.result}”的B话数量为0。'
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
await saa.Text(
|
|
144
|
+
f'该用户在群“{uninfo.scene.name}”关于“{keyword.result}”的B话数量为{rank[0][1]}。'
|
|
145
|
+
).send(reply=True)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
rank_cmd = on_alconna(
|
|
149
|
+
Alconna(
|
|
150
|
+
'B话榜',
|
|
151
|
+
Args[
|
|
152
|
+
'type?',
|
|
153
|
+
['今日', '昨日', '本周', '上周', '本月', '上月', '年度', '历史'],
|
|
154
|
+
][
|
|
155
|
+
'time?',
|
|
156
|
+
str,
|
|
157
|
+
],
|
|
158
|
+
Option('-g|--group_id', Args['group_id?', str]),
|
|
159
|
+
Option('-k|--keyword', Args['keyword?', str]),
|
|
160
|
+
behaviors=[SameTime()],
|
|
161
|
+
),
|
|
162
|
+
aliases={'废话榜'},
|
|
163
|
+
use_cmd_start=True,
|
|
164
|
+
block=True,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
rank_cmd.shortcut(
|
|
169
|
+
r'(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)B话榜',
|
|
170
|
+
{
|
|
171
|
+
'prefix': True,
|
|
172
|
+
'command': 'B话榜',
|
|
173
|
+
'wrapper': wrapper,
|
|
174
|
+
'args': ['{type}'],
|
|
175
|
+
},
|
|
176
|
+
)
|
|
177
|
+
rank_cmd.shortcut(
|
|
178
|
+
r'(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)废话榜',
|
|
179
|
+
{
|
|
180
|
+
'prefix': True,
|
|
181
|
+
'command': '废话榜',
|
|
182
|
+
'wrapper': wrapper,
|
|
183
|
+
'args': ['{type}'],
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# 这段函数完全抄的词云
|
|
189
|
+
@rank_cmd.handle()
|
|
190
|
+
async def _group_message(
|
|
191
|
+
state: T_State,
|
|
192
|
+
session: Session = Depends(get_session),
|
|
193
|
+
type: Optional[str] = None,
|
|
194
|
+
time: Optional[str] = None,
|
|
195
|
+
group_id: Optional[str] = None,
|
|
196
|
+
keyword: Optional[str] = None,
|
|
197
|
+
):
|
|
198
|
+
t1 = t.time()
|
|
199
|
+
state['t1'] = t1
|
|
200
|
+
dt = get_datetime_now_with_timezone()
|
|
201
|
+
|
|
202
|
+
if not group_id:
|
|
203
|
+
group_id = session.scene.id
|
|
204
|
+
logger.debug(f'session id2: {group_id}')
|
|
205
|
+
if group_id:
|
|
206
|
+
state['group_id'] = group_id
|
|
207
|
+
|
|
208
|
+
state['keyword'] = keyword
|
|
209
|
+
|
|
210
|
+
if not type:
|
|
211
|
+
await rank_cmd.finish(__plugin_meta__.usage)
|
|
212
|
+
|
|
213
|
+
dt = get_datetime_now_with_timezone()
|
|
214
|
+
|
|
215
|
+
if type == '今日':
|
|
216
|
+
state['start'] = dt.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
217
|
+
state['stop'] = dt
|
|
218
|
+
elif type == '昨日':
|
|
219
|
+
state['stop'] = dt.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
220
|
+
state['start'] = state['stop'] - timedelta(days=1)
|
|
221
|
+
elif type == '本周':
|
|
222
|
+
state['start'] = dt.replace(
|
|
223
|
+
hour=0, minute=0, second=0, microsecond=0
|
|
224
|
+
) - timedelta(days=dt.weekday())
|
|
225
|
+
state['stop'] = dt
|
|
226
|
+
elif type == '上周':
|
|
227
|
+
state['stop'] = dt.replace(
|
|
228
|
+
hour=0, minute=0, second=0, microsecond=0
|
|
229
|
+
) - timedelta(days=dt.weekday())
|
|
230
|
+
state['start'] = state['stop'] - timedelta(days=7)
|
|
231
|
+
elif type == '本月':
|
|
232
|
+
state['start'] = dt.replace(
|
|
233
|
+
day=1, hour=0, minute=0, second=0, microsecond=0
|
|
234
|
+
)
|
|
235
|
+
state['stop'] = dt
|
|
236
|
+
elif type == '上月':
|
|
237
|
+
state['stop'] = dt.replace(
|
|
238
|
+
day=1, hour=0, minute=0, second=0, microsecond=0
|
|
239
|
+
) - timedelta(microseconds=1)
|
|
240
|
+
state['start'] = state['stop'].replace(
|
|
241
|
+
day=1, hour=0, minute=0, second=0, microsecond=0
|
|
242
|
+
)
|
|
243
|
+
elif type == '年度':
|
|
244
|
+
state['start'] = dt.replace(
|
|
245
|
+
month=1, day=1, hour=0, minute=0, second=0, microsecond=0
|
|
246
|
+
)
|
|
247
|
+
state['stop'] = dt
|
|
248
|
+
elif type == '历史':
|
|
249
|
+
if time:
|
|
250
|
+
plaintext = time
|
|
251
|
+
if match := re.match(r'^(.+?)(?:~(.+))?$', plaintext):
|
|
252
|
+
start = match[1]
|
|
253
|
+
stop = match[2]
|
|
254
|
+
try:
|
|
255
|
+
state['start'] = get_datetime_fromisoformat_with_timezone(
|
|
256
|
+
start
|
|
257
|
+
)
|
|
258
|
+
if stop:
|
|
259
|
+
state['stop'] = (
|
|
260
|
+
get_datetime_fromisoformat_with_timezone(stop)
|
|
261
|
+
)
|
|
262
|
+
else:
|
|
263
|
+
# 如果没有指定结束日期,则认为是所给日期的当天的词云
|
|
264
|
+
state['start'] = state['start'].replace(
|
|
265
|
+
hour=0, minute=0, second=0, microsecond=0
|
|
266
|
+
)
|
|
267
|
+
state['stop'] = state['start'] + timedelta(days=1)
|
|
268
|
+
except ValueError:
|
|
269
|
+
await rank_cmd.finish(
|
|
270
|
+
'请输入正确的日期,不然我没法理解呢!'
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
@rank_cmd.got(
|
|
275
|
+
'start',
|
|
276
|
+
prompt='请输入你要查询的起始日期(如 2022-01-01)',
|
|
277
|
+
parameterless=[Depends(parse_datetime('start'))],
|
|
278
|
+
)
|
|
279
|
+
@rank_cmd.got(
|
|
280
|
+
'stop',
|
|
281
|
+
prompt='请输入你要查询的结束日期(如 2022-02-22)',
|
|
282
|
+
parameterless=[Depends(parse_datetime('stop'))],
|
|
283
|
+
)
|
|
284
|
+
@rank_cmd.got('group_id', prompt='请输入你要查询的群号。')
|
|
285
|
+
async def handle_rank(
|
|
286
|
+
state: T_State,
|
|
287
|
+
bot: Bot,
|
|
288
|
+
event: Event,
|
|
289
|
+
session: Session = Depends(get_session),
|
|
290
|
+
start: datetime = Arg(),
|
|
291
|
+
stop: datetime = Arg(),
|
|
292
|
+
):
|
|
293
|
+
if id := state['group_id']:
|
|
294
|
+
id = str(id)
|
|
295
|
+
logger.debug(f'group_id: {id}')
|
|
296
|
+
else:
|
|
297
|
+
id = session.scene.id
|
|
298
|
+
logger.debug(f'group_id: {id}')
|
|
299
|
+
|
|
300
|
+
if not id:
|
|
301
|
+
await saa.Text('没有指定群哦').finish()
|
|
302
|
+
|
|
303
|
+
keyword = state['keyword']
|
|
304
|
+
|
|
305
|
+
if plugin_config.counting_cache:
|
|
306
|
+
await saa.Text("缓存暂不支持").finish()
|
|
307
|
+
# if keyword:
|
|
308
|
+
# await saa.Text('已开启缓存~缓存不支持关键词查询哦').finish()
|
|
309
|
+
# t1 = t.time()
|
|
310
|
+
# raw_rank = await get_cache(start, stop, id)
|
|
311
|
+
# logger.debug(f'获取计数消息花费时间:{t.time() - t1}')
|
|
312
|
+
else:
|
|
313
|
+
t1 = t.time()
|
|
314
|
+
messages = await get_message_records(
|
|
315
|
+
scene_ids=[id],
|
|
316
|
+
types=['message'], # 排除机器人自己发的消息
|
|
317
|
+
time_start=start,
|
|
318
|
+
time_stop=stop,
|
|
319
|
+
exclude_user_ids=plugin_config.excluded_people,
|
|
320
|
+
)
|
|
321
|
+
raw_rank = msg_counter(messages, keyword)
|
|
322
|
+
logger.debug(f'获取计数消息花费时间:{t.time() - t1}')
|
|
323
|
+
|
|
324
|
+
if not raw_rank:
|
|
325
|
+
await saa.Text(
|
|
326
|
+
'没有获取到排行榜数据哦,请确认时间范围和群号是否正确或者关键词是否存在~'
|
|
327
|
+
).finish()
|
|
328
|
+
|
|
329
|
+
rank = got_rank(raw_rank)
|
|
330
|
+
ids = await persist_id2user_id([int(i[0]) for i in rank])
|
|
331
|
+
for i in range(len(rank)):
|
|
332
|
+
rank[i][0] = str(ids[i])
|
|
333
|
+
logger.debug(rank[i])
|
|
334
|
+
|
|
335
|
+
t1 = t.time()
|
|
336
|
+
rank2 = await get_user_infos(bot, event, rank)
|
|
337
|
+
logger.debug(f'获取用户信息花费时间:{t.time() - t1}')
|
|
338
|
+
|
|
339
|
+
string: str = ''
|
|
340
|
+
if plugin_config.show_text_rank:
|
|
341
|
+
if keyword:
|
|
342
|
+
string += f'关于{keyword}的话痨榜结果:\n'
|
|
343
|
+
else:
|
|
344
|
+
string += '话痨榜:\n'
|
|
345
|
+
|
|
346
|
+
for i in rank2:
|
|
347
|
+
logger.debug(i.user_name)
|
|
348
|
+
for i in range(len(rank2)):
|
|
349
|
+
str_example = plugin_config.string_format.format(
|
|
350
|
+
index=rank2[i].user_index,
|
|
351
|
+
nickname=rank2[i].user_nickname,
|
|
352
|
+
chatdatanum=rank2[i].user_bnum,
|
|
353
|
+
)
|
|
354
|
+
string += str_example
|
|
355
|
+
|
|
356
|
+
msg = saa.Text(string)
|
|
357
|
+
|
|
358
|
+
if plugin_config.visualization:
|
|
359
|
+
t1 = t.time()
|
|
360
|
+
image = await get_rank_image(rank2)
|
|
361
|
+
msg += saa.Image(image)
|
|
362
|
+
logger.debug(f'群聊消息渲染图片花费时间:{t.time() - t1}')
|
|
363
|
+
|
|
364
|
+
if plugin_config.suffix:
|
|
365
|
+
timecost = t.time() - state['t1']
|
|
366
|
+
suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost))
|
|
367
|
+
msg += suffix
|
|
368
|
+
if not msg:
|
|
369
|
+
await saa.Text('你把可视化都关了哪来的排行榜?').finish()
|
|
370
|
+
|
|
371
|
+
if plugin_config.aggregate_transmission:
|
|
372
|
+
await saa.AggregatedMessageFactory([msg]).finish()
|
|
373
|
+
else:
|
|
374
|
+
await msg.finish(reply=True)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""update dialectlist
|
|
2
|
+
|
|
3
|
+
迁移 ID: fb88e4d27eb8
|
|
4
|
+
父迁移: 60daff81fcdc
|
|
5
|
+
创建时间: 2025-04-20 11:00:50.931679
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
|
|
12
|
+
from alembic import op
|
|
13
|
+
import sqlalchemy as sa
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
revision: str = 'fb88e4d27eb8'
|
|
17
|
+
down_revision: str | Sequence[str] | None = '60daff81fcdc'
|
|
18
|
+
branch_labels: str | Sequence[str] | None = None
|
|
19
|
+
depends_on: str | Sequence[str] | None = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade(name: str = "") -> None:
|
|
23
|
+
if name:
|
|
24
|
+
return
|
|
25
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
26
|
+
op.create_table('sessionmodel',
|
|
27
|
+
sa.Column('id', sa.Integer(), nullable=False),
|
|
28
|
+
sa.Column('bot_id', sa.String(length=64), nullable=False),
|
|
29
|
+
sa.Column('bot_type', sa.String(length=32), nullable=False),
|
|
30
|
+
sa.Column('platform', sa.String(length=32), nullable=False),
|
|
31
|
+
sa.Column('level', sa.Integer(), nullable=False),
|
|
32
|
+
sa.Column('id1', sa.String(length=64), nullable=False),
|
|
33
|
+
sa.Column('id2', sa.String(length=64), nullable=False),
|
|
34
|
+
sa.Column('id3', sa.String(length=64), nullable=False),
|
|
35
|
+
sa.PrimaryKeyConstraint('id', name=op.f('pk_sessionmodel')),
|
|
36
|
+
sa.UniqueConstraint('bot_id', 'bot_type', 'platform', 'level', 'id1', 'id2', 'id3', name='unique_session'),
|
|
37
|
+
info={'bind_key': ''}
|
|
38
|
+
)
|
|
39
|
+
# ### end Alembic commands ###
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def downgrade(name: str = "") -> None:
|
|
43
|
+
if name:
|
|
44
|
+
return
|
|
45
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
46
|
+
op.drop_table('sessionmodel')
|
|
47
|
+
# ### end Alembic commands ###
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from typing import Union
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
from nonebot_plugin_orm import Model
|
|
5
5
|
from nonebot_plugin_userinfo import UserInfo
|
|
6
|
+
from sqlalchemy import Integer
|
|
6
7
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
7
8
|
|
|
8
9
|
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import json
|
|
2
|
+
import os
|
|
3
3
|
from datetime import datetime
|
|
4
|
-
from sqlalchemy import delete, or_, select
|
|
5
4
|
|
|
6
5
|
from nonebot import get_driver
|
|
6
|
+
from nonebot.adapters import Bot, Event
|
|
7
7
|
from nonebot.log import logger
|
|
8
|
-
from nonebot.params import Depends
|
|
9
|
-
from nonebot.adapters import Event, Bot
|
|
10
8
|
from nonebot.message import event_postprocessor
|
|
11
|
-
|
|
12
|
-
from .model import MessageCountCache
|
|
13
|
-
from .config import plugin_config
|
|
14
|
-
|
|
15
|
-
from nonebot_plugin_localstore import get_data_file
|
|
9
|
+
from nonebot.params import Depends
|
|
16
10
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
17
11
|
from nonebot_plugin_chatrecorder.utils import remove_timezone
|
|
18
|
-
from
|
|
19
|
-
from
|
|
12
|
+
from nonebot_plugin_uninfo import Session, get_session
|
|
13
|
+
from nonebot_plugin_uninfo.orm import SessionModel,get_session_persist_id
|
|
14
|
+
from nonebot_plugin_localstore import get_data_file
|
|
20
15
|
from nonebot_plugin_orm import get_session
|
|
16
|
+
from sqlalchemy import delete, or_, select
|
|
17
|
+
|
|
18
|
+
from .config import plugin_config
|
|
19
|
+
from .model import MessageCountCache
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
async def get_cache(time_start: datetime, time_stop: datetime, group_id: str):
|
|
@@ -132,3 +131,6 @@ async def _(bot: Bot, event: Event, session: Session = Depends(extract_session))
|
|
|
132
131
|
db_session.add(user_cache)
|
|
133
132
|
await db_session.commit()
|
|
134
133
|
logger.debug("已计入缓存")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# TODO: 修复缓存储存
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
from zoneinfo import ZoneInfo
|
|
2
|
-
from typing import Optional, Union
|
|
3
1
|
from datetime import datetime, time, tzinfo
|
|
2
|
+
from typing import Optional, Union
|
|
3
|
+
from zoneinfo import ZoneInfo
|
|
4
4
|
|
|
5
|
+
from nonebot.adapters import Message
|
|
5
6
|
from nonebot.params import Arg
|
|
6
7
|
from nonebot.typing import T_State
|
|
7
|
-
from nonebot.adapters import Message
|
|
8
|
-
|
|
9
|
-
from nonebot_plugin_apscheduler import scheduler
|
|
10
8
|
from nonebot_plugin_alconna import AlconnaMatcher
|
|
9
|
+
from nonebot_plugin_apscheduler import scheduler
|
|
11
10
|
|
|
12
11
|
from .config import plugin_config
|
|
13
12
|
|