nonebot-plugin-dialectlist 2.0.1__tar.gz → 2.0.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.0.1 → nonebot_plugin_dialectlist-2.0.4}/PKG-INFO +3 -1
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist/__init__.py +29 -35
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist/config.py +0 -7
- nonebot_plugin_dialectlist-2.0.4/nonebot_plugin_dialectlist/render.py +1 -0
- nonebot_plugin_dialectlist-2.0.4/nonebot_plugin_dialectlist/storage.py +1 -0
- nonebot_plugin_dialectlist-2.0.4/nonebot_plugin_dialectlist/time.py +1 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist/utils.py +24 -5
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist.egg-info/PKG-INFO +3 -1
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist.egg-info/SOURCES.txt +3 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist.egg-info/requires.txt +2 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/pyproject.toml +18 -1
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/README.md +0 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist/usage.py +0 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/nonebot_plugin_dialectlist.egg-info/top_level.txt +0 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/setup.cfg +0 -0
- {nonebot_plugin_dialectlist-2.0.1 → nonebot_plugin_dialectlist-2.0.4}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot_plugin_dialectlist
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Default template for PDM package
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -14,6 +14,8 @@ Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
|
14
14
|
Requires-Dist: nonebot-plugin-alconna>=0.46.6
|
|
15
15
|
Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
16
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
|
|
17
19
|
Provides-Extra: dev
|
|
18
20
|
Requires-Dist: ruff>=0.4.9; extra == "dev"
|
|
19
21
|
Requires-Dist: setuptools>=70.0.0; extra == "dev"
|
|
@@ -2,14 +2,18 @@ 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
11
|
import nonebot_plugin_saa as saa
|
|
12
12
|
|
|
13
|
+
from pyecharts.charts import Bar
|
|
14
|
+
from pyecharts import options as opts
|
|
15
|
+
from pyecharts.globals import ThemeType
|
|
16
|
+
|
|
13
17
|
from typing import Union, Optional, List
|
|
14
18
|
from datetime import datetime, timedelta
|
|
15
19
|
from arclet.alconna import ArparmaBehavior
|
|
@@ -37,6 +41,8 @@ from nonebot_plugin_alconna import (
|
|
|
37
41
|
)
|
|
38
42
|
|
|
39
43
|
from nonebot_plugin_chatrecorder import get_message_records
|
|
44
|
+
from nonebot_plugin_localstore import get_cache_file
|
|
45
|
+
from nonebot_plugin_htmlrender import html_to_pic
|
|
40
46
|
from nonebot_plugin_userinfo import get_user_info
|
|
41
47
|
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
|
42
48
|
|
|
@@ -50,6 +56,7 @@ from .utils import (
|
|
|
50
56
|
got_rank,
|
|
51
57
|
msg_counter,
|
|
52
58
|
persist_id2user_id,
|
|
59
|
+
parse_datetime
|
|
53
60
|
)
|
|
54
61
|
|
|
55
62
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -74,25 +81,25 @@ class SameTime(ArparmaBehavior):
|
|
|
74
81
|
if type is None and time:
|
|
75
82
|
interface.behave_fail()
|
|
76
83
|
|
|
84
|
+
def wrapper(slot: Union[int, str], content: Optional[str]) -> str:
|
|
85
|
+
if slot == "type" and content:
|
|
86
|
+
return content
|
|
87
|
+
return "" # pragma: no cover
|
|
77
88
|
|
|
78
89
|
rank_cmd = on_alconna(
|
|
79
90
|
Alconna(
|
|
80
91
|
"B话榜",
|
|
81
92
|
Args["type?", ["今日", "昨日", "本周", "上周", "本月", "上月", "年度", "历史"]][
|
|
82
|
-
"time?", str
|
|
93
|
+
"time?", str,
|
|
94
|
+
"group_id?", int
|
|
83
95
|
],
|
|
84
96
|
behaviors=[SameTime()],
|
|
85
97
|
),
|
|
98
|
+
aliases={"废话榜"},
|
|
86
99
|
use_cmd_start=True,
|
|
87
100
|
)
|
|
88
101
|
|
|
89
102
|
|
|
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
103
|
rank_cmd.shortcut(
|
|
97
104
|
r"(?P<type>今日|昨日|本周|上周|本月|上月|年度|历史)B话榜",
|
|
98
105
|
{
|
|
@@ -103,41 +110,21 @@ rank_cmd.shortcut(
|
|
|
103
110
|
},
|
|
104
111
|
)
|
|
105
112
|
|
|
106
|
-
|
|
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[int] = None,
|
|
137
121
|
):
|
|
138
122
|
|
|
139
123
|
dt = get_datetime_now_with_timezone()
|
|
140
124
|
|
|
125
|
+
if not group_id:
|
|
126
|
+
state["group_id"] = session.id2
|
|
127
|
+
|
|
141
128
|
if not type:
|
|
142
129
|
await rank_cmd.finish(__plugin_meta__.usage)
|
|
143
130
|
|
|
@@ -211,7 +198,6 @@ async def handle_rank(
|
|
|
211
198
|
start: datetime = Arg(),
|
|
212
199
|
stop: datetime = Arg(),
|
|
213
200
|
):
|
|
214
|
-
"""生成词云"""
|
|
215
201
|
messages = await get_message_records(
|
|
216
202
|
session=session,
|
|
217
203
|
id_type=SessionIdType.GROUP,
|
|
@@ -252,4 +238,12 @@ async def handle_rank(
|
|
|
252
238
|
)
|
|
253
239
|
string += str_example
|
|
254
240
|
|
|
255
|
-
|
|
241
|
+
bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
|
|
242
|
+
bar.add_xaxis(nicknames)
|
|
243
|
+
bar.add_yaxis("B话数量", [i[1] for i in rank]) # type: ignore
|
|
244
|
+
bar.render(str(get_cache_file("nonebot_plugin_dialectlist","cache.html")))
|
|
245
|
+
with open(get_cache_file("nonebot_plugin_dialectlist","cache.html")) as f:
|
|
246
|
+
a = f.read()
|
|
247
|
+
image = await html_to_pic(a,device_scale_factor=3.2)
|
|
248
|
+
|
|
249
|
+
await (saa.Text(string)+saa.Image(image)).finish(reply=True)
|
|
@@ -13,13 +13,6 @@ class ScopedConfig(BaseModel):
|
|
|
13
13
|
excluded_people: List[str] = [] # 排除的人的QQ号
|
|
14
14
|
visualization_type: Literal["饼图", "圆环图", "柱状图"] = "圆环图" # 可视化方案
|
|
15
15
|
|
|
16
|
-
@field_validator("get_num")
|
|
17
|
-
@classmethod
|
|
18
|
-
def check_priority(cls, v: int) -> int:
|
|
19
|
-
if v >= 1:
|
|
20
|
-
return v
|
|
21
|
-
raise ValueError("表中的人数必须大于一")
|
|
22
|
-
|
|
23
16
|
|
|
24
17
|
class Config(BaseModel):
|
|
25
18
|
dialectlist: ScopedConfig = ScopedConfig()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO 更好的图片渲染,支持自定义模板渲染。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO 使用计数缓存进行数据库查询优化,避免一次性查询过多消息导致内存爆炸。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO 时间处理模块,用于处理时间相关操作。
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import contextlib
|
|
2
1
|
from datetime import datetime, time, tzinfo
|
|
3
2
|
from typing import Optional, Dict, List, Union
|
|
4
3
|
from zoneinfo import ZoneInfo
|
|
@@ -6,22 +5,42 @@ from sqlalchemy import or_, select
|
|
|
6
5
|
from sqlalchemy.sql import ColumnElement
|
|
7
6
|
|
|
8
7
|
from nonebot.log import logger
|
|
9
|
-
from nonebot.params import Depends
|
|
8
|
+
from nonebot.params import Arg, Depends
|
|
9
|
+
from nonebot.typing import T_State
|
|
10
10
|
from nonebot.matcher import Matcher
|
|
11
|
-
|
|
12
|
-
# from nonebot.permission import SUPERUSER
|
|
11
|
+
from nonebot.adapters import Message
|
|
13
12
|
|
|
14
13
|
from nonebot_plugin_orm import get_session
|
|
15
|
-
from nonebot_plugin_saa import PlatformTarget, get_target
|
|
16
14
|
from nonebot_plugin_session import Session, SessionLevel, extract_session
|
|
17
15
|
from nonebot_plugin_session_orm import SessionModel
|
|
18
16
|
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
|
19
17
|
from nonebot_plugin_apscheduler import scheduler
|
|
20
18
|
from nonebot_plugin_chatrecorder import MessageRecord
|
|
19
|
+
from nonebot_plugin_alconna import AlconnaMatcher
|
|
20
|
+
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
from .config import plugin_config
|
|
24
24
|
|
|
25
|
+
def parse_datetime(key: str):
|
|
26
|
+
"""解析数字,并将结果存入 state 中"""
|
|
27
|
+
|
|
28
|
+
async def _key_parser(
|
|
29
|
+
matcher: AlconnaMatcher,
|
|
30
|
+
state: T_State,
|
|
31
|
+
input: Union[datetime, Message] = Arg(key),
|
|
32
|
+
):
|
|
33
|
+
if isinstance(input, datetime):
|
|
34
|
+
return
|
|
35
|
+
|
|
36
|
+
plaintext = input.extract_plain_text()
|
|
37
|
+
try:
|
|
38
|
+
state[key] = get_datetime_fromisoformat_with_timezone(plaintext)
|
|
39
|
+
except ValueError:
|
|
40
|
+
await matcher.reject_arg(key, "请输入正确的日期,不然我没法理解呢!")
|
|
41
|
+
|
|
42
|
+
return _key_parser
|
|
43
|
+
|
|
25
44
|
|
|
26
45
|
def get_datetime_now_with_timezone() -> datetime:
|
|
27
46
|
"""获取当前时间,并包含时区信息"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot_plugin_dialectlist
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Default template for PDM package
|
|
5
5
|
Author-email: Chen_Xu233 <woyerpa@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -14,6 +14,8 @@ Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
|
|
|
14
14
|
Requires-Dist: nonebot-plugin-alconna>=0.46.6
|
|
15
15
|
Requires-Dist: nonebot-plugin-cesaa>=0.4.0
|
|
16
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
|
|
17
19
|
Provides-Extra: dev
|
|
18
20
|
Requires-Dist: ruff>=0.4.9; extra == "dev"
|
|
19
21
|
Requires-Dist: setuptools>=70.0.0; extra == "dev"
|
|
@@ -3,6 +3,9 @@ pyproject.toml
|
|
|
3
3
|
setup.py
|
|
4
4
|
nonebot_plugin_dialectlist/__init__.py
|
|
5
5
|
nonebot_plugin_dialectlist/config.py
|
|
6
|
+
nonebot_plugin_dialectlist/render.py
|
|
7
|
+
nonebot_plugin_dialectlist/storage.py
|
|
8
|
+
nonebot_plugin_dialectlist/time.py
|
|
6
9
|
nonebot_plugin_dialectlist/usage.py
|
|
7
10
|
nonebot_plugin_dialectlist/utils.py
|
|
8
11
|
nonebot_plugin_dialectlist.egg-info/PKG-INFO
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot_plugin_dialectlist"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.4"
|
|
4
4
|
description = "Default template for PDM package"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
|
@@ -14,6 +14,8 @@ dependencies = [
|
|
|
14
14
|
"nonebot-plugin-alconna>=0.46.6",
|
|
15
15
|
"nonebot-plugin-cesaa>=0.4.0",
|
|
16
16
|
"nonebot-plugin-userinfo>=0.2.4",
|
|
17
|
+
"pyecharts>=2.0.5",
|
|
18
|
+
"nonebot-plugin-htmlrender>=0.3.2",
|
|
17
19
|
]
|
|
18
20
|
requires-python = ">=3.10,<4.0"
|
|
19
21
|
readme = "README.md"
|
|
@@ -35,3 +37,18 @@ line-length = 80
|
|
|
35
37
|
[tool.ruff.format]
|
|
36
38
|
quote-style = "single"
|
|
37
39
|
indent-style = "tab"
|
|
40
|
+
|
|
41
|
+
[tool.pdm.scripts]
|
|
42
|
+
|
|
43
|
+
build = 'pdm run setup.py sdist bdist_wheel'
|
|
44
|
+
publish = 'pdm run python -m twine upload dist/*'
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# 以下为智普 AI 生成,还不知道这玩意有啥用。
|
|
48
|
+
# [tool.pdm.dev-dependencies]
|
|
49
|
+
# black = "^23.1.0"
|
|
50
|
+
# isort = "^5.10.1"
|
|
51
|
+
# pre-commit = "^2.20.0"
|
|
52
|
+
|
|
53
|
+
# [tool.pdm.global-options]
|
|
54
|
+
# --no-pip-version-check = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|