nonebot-plugin-l4d2-server 0.6.6__py3-none-any.whl → 1.0.0a2__py3-none-any.whl
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_l4d2_server/__init__.py +10 -93
- nonebot_plugin_l4d2_server/__main__.py +140 -0
- nonebot_plugin_l4d2_server/config.py +35 -0
- nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
- nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
- nonebot_plugin_l4d2_server/l4_help/Help.json +102 -0
- nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
- nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
- nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
- nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
- nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +11 -35
- nonebot_plugin_l4d2_server/l4_image/html_img.py +105 -0
- nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/back.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/head/head.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/logo.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/player1.jpg +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +299 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +341 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +355 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/l.svg +0 -1
- nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +247 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/w.svg +1 -1
- nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
- nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +4 -2
- nonebot_plugin_l4d2_server/l4_request/__init__.py +143 -0
- nonebot_plugin_l4d2_server/l4_request/draw_msg.py +83 -0
- nonebot_plugin_l4d2_server/utils/api/api.py +10 -0
- nonebot_plugin_l4d2_server/utils/api/models.py +137 -0
- nonebot_plugin_l4d2_server/utils/api/request.py +337 -0
- nonebot_plugin_l4d2_server/utils/database/models.py +18 -0
- nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +60 -63
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +57 -66
- nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +1 -1
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -263
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -231
- nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
- nonebot_plugin_l4d2_server/data/img/white.png +0 -0
- nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
- nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
- nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
- nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
- nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
- nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
- nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
- nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
- nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
- nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
- nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
- nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
- nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
- nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
- nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
- nonebot_plugin_l4d2_server/l4d2_image/__init__.py +0 -125
- nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
- nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
- nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
- nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
- nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
- nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
- nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
- nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
- nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
- nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
- nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
- nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
- nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
- nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
- nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
- nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
- nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
- nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
- nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
- nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
- nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
- nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
- nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
- nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
- nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
- nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
- nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
- nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/anne.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/group_ip.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/ip.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/fingerprint.svg +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/vue.css +0 -0
- /nonebot_plugin_l4d2_server/{l4d2_data/database.py → l4_request/utils.py} +0 -0
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -17,112 +17,29 @@
|
|
17
17
|
|
18
18
|
from nonebot import get_driver, require
|
19
19
|
|
20
|
-
require("
|
21
|
-
require("
|
22
|
-
require("
|
23
|
-
require("nonebot_plugin_txt2img") # noqa: F401
|
24
|
-
scheduler = require("nonebot_plugin_apscheduler").scheduler
|
20
|
+
require("nonebot_plugin_htmlrender")
|
21
|
+
require("nonebot_plugin_alconna")
|
22
|
+
require("nonebot_plugin_tortoise_orm")
|
25
23
|
|
26
|
-
from nonebot.
|
27
|
-
from nonebot.log import logger
|
28
|
-
from nonebot.matcher import Matcher
|
29
|
-
from nonebot.plugin import PluginMetadata
|
30
|
-
from nonebot.typing import T_State
|
24
|
+
from nonebot.plugin import PluginMetadata, inherit_supported_adapters # noqa: E402
|
31
25
|
|
32
|
-
from .
|
33
|
-
|
34
|
-
|
35
|
-
from .l4d2_image.steam import url_to_byte_name
|
36
|
-
from .l4d2_push import scheduler # noqa: F401
|
37
|
-
from .l4d2_utils.command import help_, search_api
|
38
|
-
from .l4d2_utils.config import l4_config
|
39
|
-
from .l4d2_utils.utils import upload_file
|
40
|
-
from .l4d2_web import web, webUI # noqa: F401
|
26
|
+
from . import __main__ as __main__ # noqa: E402
|
27
|
+
from .config import ConfigModel # noqa: E402
|
28
|
+
from .l4_help import __version__ # noqa: E402
|
41
29
|
|
42
30
|
driver = get_driver()
|
43
31
|
|
44
|
-
|
32
|
+
|
45
33
|
__plugin_meta__ = PluginMetadata(
|
46
34
|
name="求生之路小助手",
|
47
35
|
description="可用于管理求生之路查服和本地管理",
|
48
36
|
usage="群内对有关求生之路的查询和操作",
|
37
|
+
config=ConfigModel,
|
49
38
|
type="application",
|
50
39
|
homepage="https://github.com/Agnes4m/nonebot_plugin_l4d2_server",
|
51
|
-
supported_adapters=
|
40
|
+
supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"),
|
52
41
|
extra={
|
53
42
|
"version": __version__,
|
54
43
|
"author": "Agnes4m <Z735803792@163.com>",
|
55
44
|
},
|
56
45
|
)
|
57
|
-
|
58
|
-
|
59
|
-
"""相当于启动就检查数据库"""
|
60
|
-
|
61
|
-
|
62
|
-
@help_.handle()
|
63
|
-
async def _(matcher: Matcher):
|
64
|
-
msg = """=====求生机器人帮助=====
|
65
|
-
1、电信服战绩查询【求生anne | Ranne[id/steamid/@]】
|
66
|
-
2、电信服绑定【求生绑定[id/steamid]】",
|
67
|
-
3、电信服状态查询【云xx】
|
68
|
-
4、创意工坊下载【创意工坊下载[物品id/链接]】
|
69
|
-
5、指定ip查询【求生ip[ip]】(可以是域名)
|
70
|
-
6、求生喷漆制作【求生喷漆】
|
71
|
-
7、本地服务器相关【l4地图上传】【l4地图改名】【l4地图删除】【l4路径】【l4插件】
|
72
|
-
8、ip导入(私聊发送json文件,格式参考下方链接中readme)
|
73
|
-
9、内置ip更新【l4公益服更新】【求生更新anne】
|
74
|
-
项目地址:https://github.com/Agnes4m/nonebot_plugin_l4d2_server
|
75
|
-
"""
|
76
|
-
await matcher.finish(msg)
|
77
|
-
|
78
|
-
|
79
|
-
@search_api.got("is_sure", prompt='如果需要上传,请发送 "yes"')
|
80
|
-
async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State):
|
81
|
-
if not l4_config.l4_group_upload:
|
82
|
-
return
|
83
|
-
is_sure = str(state["is_sure"])
|
84
|
-
if is_sure == "yes":
|
85
|
-
data_dict: dict = state["maps"][0]
|
86
|
-
if isinstance(data_dict, dict):
|
87
|
-
logger.info("开始上传")
|
88
|
-
if l4_config.l4_only:
|
89
|
-
reu = await url_to_byte_name(data_dict["url"], "htp")
|
90
|
-
else:
|
91
|
-
reu = await url_to_byte_name(data_dict["url"])
|
92
|
-
if not reu:
|
93
|
-
return
|
94
|
-
data_file, file_name = reu
|
95
|
-
if data_file:
|
96
|
-
await matcher.send("获取地址成功,尝试上传")
|
97
|
-
await upload_file(bot, event, data_file, file_name)
|
98
|
-
else:
|
99
|
-
await search_api.send("出错了,原因是下载链接不存在")
|
100
|
-
else:
|
101
|
-
...
|
102
|
-
# logger.info("开始上传")
|
103
|
-
# for data_one in data_dict:
|
104
|
-
# reu = await url_to_byte_name(data_one["url"])
|
105
|
-
# if not reu:
|
106
|
-
# return
|
107
|
-
# data_file, file_name = reu
|
108
|
-
# await all_zip_to_one()
|
109
|
-
# await upload_file(bot, event, data_file, file_name)
|
110
|
-
else:
|
111
|
-
await matcher.finish("已取消上传")
|
112
|
-
|
113
|
-
|
114
|
-
# @reload_ip.handle()
|
115
|
-
# async def _(matcher:Matcher):
|
116
|
-
# global matchers
|
117
|
-
# await matcher.send('正在重载ip,可能需要一点时间')
|
118
|
-
# for _, l4_matchers in matchers.items():
|
119
|
-
# for l4_matcher in l4_matchers:
|
120
|
-
# l4_matcher.destroy()
|
121
|
-
# await get_des_ip()
|
122
|
-
# await matcher.finish('已重载ip')
|
123
|
-
|
124
|
-
|
125
|
-
@driver.on_shutdown
|
126
|
-
async def close_db():
|
127
|
-
"""关闭数据库"""
|
128
|
-
sq_L4D2._close() # noqa: SLF001
|
@@ -0,0 +1,140 @@
|
|
1
|
+
"""
|
2
|
+
* Copyright (c) 2023, Agnes Digital
|
3
|
+
*
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
7
|
+
* (at your option) any later version.
|
8
|
+
*
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
* GNU General Public License for more details.
|
13
|
+
*
|
14
|
+
* You should have received a copy of the GNU General Public License
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
+
"""
|
17
|
+
|
18
|
+
from typing import TYPE_CHECKING, List, Optional
|
19
|
+
|
20
|
+
from nonebot.adapters import Message
|
21
|
+
from nonebot.log import logger
|
22
|
+
from nonebot.matcher import Matcher
|
23
|
+
from nonebot.params import CommandArg, CommandStart, RawCommand
|
24
|
+
from nonebot.plugin import on_command
|
25
|
+
from nonebot_plugin_alconna import UniMessage
|
26
|
+
|
27
|
+
from .config import config
|
28
|
+
from .l4_help import get_l4d2_core_help
|
29
|
+
from .l4_request import (
|
30
|
+
COMMAND,
|
31
|
+
get_all_server_detail,
|
32
|
+
get_ip_server,
|
33
|
+
get_server_detail,
|
34
|
+
reload_ip,
|
35
|
+
)
|
36
|
+
from .utils.api.request import L4API
|
37
|
+
|
38
|
+
if TYPE_CHECKING:
|
39
|
+
from .utils.api.models import OutServer
|
40
|
+
|
41
|
+
reload_ip()
|
42
|
+
|
43
|
+
l4_help = on_command("l4help", aliases={"l4帮助", "l4d2帮助"})
|
44
|
+
l4_request = on_command("anne", aliases=COMMAND, priority=10)
|
45
|
+
l4_reload = on_command("l4reload", aliases={"l4刷新,l4重载"})
|
46
|
+
l4_all = on_command("l4all", aliases={"l4全服"})
|
47
|
+
l4_connect = on_command("connect", aliases={"l4连接"})
|
48
|
+
l4_find_player = on_command("l4find", aliases={"l4查找"})
|
49
|
+
|
50
|
+
|
51
|
+
@l4_help.handle()
|
52
|
+
async def _(matcher: Matcher):
|
53
|
+
"""帮助"""
|
54
|
+
logger.info("开始执行[l4d2帮助]")
|
55
|
+
im = await get_l4d2_core_help()
|
56
|
+
if isinstance(im, str):
|
57
|
+
await matcher.finish(im)
|
58
|
+
await UniMessage.image(raw=im).send()
|
59
|
+
|
60
|
+
|
61
|
+
@l4_request.handle()
|
62
|
+
async def _(
|
63
|
+
start: str = CommandStart(),
|
64
|
+
command: str = RawCommand(),
|
65
|
+
args: Message = CommandArg(),
|
66
|
+
):
|
67
|
+
"""例:
|
68
|
+
指令: /橘5
|
69
|
+
start: /(command开头指令)
|
70
|
+
command: /橘(响应的全部指令)
|
71
|
+
args: 5(响应的指令后的数字)
|
72
|
+
"""
|
73
|
+
|
74
|
+
if start:
|
75
|
+
command = command.replace(start, "")
|
76
|
+
if command == "anne":
|
77
|
+
command = "云"
|
78
|
+
_id: Optional[str] = args.extract_plain_text()
|
79
|
+
if _id is not None and not _id.isdigit() and _id:
|
80
|
+
return
|
81
|
+
if not _id:
|
82
|
+
_id = None
|
83
|
+
logger.info(f"组:{command} ;数字:{_id}")
|
84
|
+
msg = await get_server_detail(command, _id)
|
85
|
+
if msg is not None:
|
86
|
+
if isinstance(msg, str):
|
87
|
+
await UniMessage.text(msg).finish()
|
88
|
+
if isinstance(msg, bytes):
|
89
|
+
await UniMessage.image(raw=msg).finish()
|
90
|
+
else:
|
91
|
+
await UniMessage.text("服务器无响应").finish()
|
92
|
+
|
93
|
+
|
94
|
+
@l4_find_player.handle()
|
95
|
+
async def _(
|
96
|
+
args: Message = CommandArg(),
|
97
|
+
):
|
98
|
+
msg: str = args.extract_plain_text().strip()
|
99
|
+
tag_list: List[str] = msg.split(" ", maxsplit=1)
|
100
|
+
if len(tag_list) < 2:
|
101
|
+
return await UniMessage.text("格式错误,正确格式:/l4find 组名 玩家名").finish()
|
102
|
+
group, name = tag_list
|
103
|
+
out: List[OutServer] = await get_server_detail(group, is_img=False) # type: ignore
|
104
|
+
out_msg = "未找到玩家"
|
105
|
+
for one in out:
|
106
|
+
for player in one["player"]:
|
107
|
+
if name in player.name:
|
108
|
+
out_msg = await get_ip_server(f"{one['host']}:{one['port']}")
|
109
|
+
|
110
|
+
return await UniMessage.text(out_msg).finish()
|
111
|
+
|
112
|
+
|
113
|
+
@l4_all.handle()
|
114
|
+
async def _():
|
115
|
+
await UniMessage.text(await get_all_server_detail()).finish()
|
116
|
+
|
117
|
+
|
118
|
+
@l4_connect.handle()
|
119
|
+
async def _(args: Message = CommandArg()):
|
120
|
+
ip: Optional[str] = args.extract_plain_text()
|
121
|
+
if ip is not None:
|
122
|
+
await UniMessage.text(await get_ip_server(ip)).finish()
|
123
|
+
|
124
|
+
|
125
|
+
# anne部分
|
126
|
+
if config.l4_anne:
|
127
|
+
logger.info("加载anne功能")
|
128
|
+
from .l4_anne import * # noqa: F403
|
129
|
+
|
130
|
+
|
131
|
+
@l4_reload.handle()
|
132
|
+
async def _(args: Message = CommandArg()):
|
133
|
+
arg = args.extract_plain_text().strip()
|
134
|
+
print(arg)
|
135
|
+
if not arg:
|
136
|
+
reload_ip()
|
137
|
+
logger.success("重载ip完成")
|
138
|
+
await UniMessage.text("重载ip完成").finish()
|
139
|
+
else:
|
140
|
+
print(await L4API.get_sourceban())
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from nonebot import get_plugin_config
|
4
|
+
from pydantic import BaseModel
|
5
|
+
|
6
|
+
DATAPATH = Path(__file__).parent.joinpath("data")
|
7
|
+
DATAOUT = Path("data/L4D2")
|
8
|
+
print(DATAOUT.absolute())
|
9
|
+
server_all_path = DATAOUT / "l4d2"
|
10
|
+
server_all_path.mkdir(parents=True, exist_ok=True)
|
11
|
+
|
12
|
+
ICONPATH = DATAPATH / "icon"
|
13
|
+
|
14
|
+
|
15
|
+
class ConfigModel(BaseModel):
|
16
|
+
l4_anne: bool = True
|
17
|
+
"""是否启用anne电信服相关功能"""
|
18
|
+
l4_enable: bool = True
|
19
|
+
"""是否全局启用求生功能"""
|
20
|
+
l4_image: bool = False
|
21
|
+
"""是否启用图片"""
|
22
|
+
l4_connect: bool = True
|
23
|
+
"""是否在查服命令后加入connect ip"""
|
24
|
+
l4_path: str = "data/L4D2"
|
25
|
+
"""插件数据路径"""
|
26
|
+
l4_players: int = 4
|
27
|
+
"""查询总图的时候展示的用户数量"""
|
28
|
+
l4_style: str = "default"
|
29
|
+
"""图片风格"""
|
30
|
+
l4_font: str = str(Path(__file__).parent.joinpath("data/font/loli.ttf"))
|
31
|
+
"""字体"""
|
32
|
+
l4_show_ip: bool = True
|
33
|
+
|
34
|
+
|
35
|
+
config = get_plugin_config(ConfigModel)
|
Binary file
|
@@ -0,0 +1,124 @@
|
|
1
|
+
from nonebot import log as log, on_command # noqa: N999
|
2
|
+
from nonebot.adapters import Event, Message
|
3
|
+
from nonebot.log import logger
|
4
|
+
from nonebot.params import CommandArg
|
5
|
+
from nonebot_plugin_alconna import UniMessage
|
6
|
+
|
7
|
+
from ..utils.api.request import L4API
|
8
|
+
from ..utils.database.models import SteamUser
|
9
|
+
from ..utils.utils import get_message_at
|
10
|
+
from .ranne import get_anne_rank_out
|
11
|
+
|
12
|
+
anne_bind = on_command("Banne", aliases={"l4绑定", "anne绑定"}, priority=5, block=True)
|
13
|
+
anne_search = on_command("Sanne", aliases={"anne搜索"})
|
14
|
+
anne_rank = on_command("Ranne", aliases={"anne成绩"}, block=True, priority=1)
|
15
|
+
|
16
|
+
anne_del = on_command(
|
17
|
+
"Danne",
|
18
|
+
aliases={"l4删除", "anne删除", "l4解绑", "anne解绑"},
|
19
|
+
priority=5,
|
20
|
+
block=True,
|
21
|
+
)
|
22
|
+
|
23
|
+
|
24
|
+
@anne_search.handle()
|
25
|
+
async def _(args: Message = CommandArg()):
|
26
|
+
name: str = args.extract_plain_text().strip()
|
27
|
+
print(name)
|
28
|
+
user_list = await L4API.get_anne_steamid(name)
|
29
|
+
if user_list is None:
|
30
|
+
await UniMessage.text("未找到玩家").finish()
|
31
|
+
msg = f"---有{len(user_list)}个玩家---"
|
32
|
+
for index, user in enumerate(user_list, start=1):
|
33
|
+
if index >= 10:
|
34
|
+
break
|
35
|
+
msg += f"""
|
36
|
+
{index}. {user["name"]} | [{user["score"]}] | {user["play_time"]}
|
37
|
+
{user["steamid"]}
|
38
|
+
"""
|
39
|
+
if msg:
|
40
|
+
await UniMessage.text("\n".join(msg.splitlines())).finish()
|
41
|
+
else:
|
42
|
+
await UniMessage.text("没有找到玩家").finish()
|
43
|
+
|
44
|
+
|
45
|
+
@anne_bind.handle()
|
46
|
+
async def _(ev: Event, args: Message = CommandArg()):
|
47
|
+
arg: str = args.extract_plain_text()
|
48
|
+
if not arg:
|
49
|
+
await UniMessage.text("虚空绑定?").finish()
|
50
|
+
|
51
|
+
user = await SteamUser.get_or_none(userid=int(ev.get_user_id()))
|
52
|
+
if user is None:
|
53
|
+
user = await SteamUser.create(userid=int(ev.get_user_id()))
|
54
|
+
|
55
|
+
if len(arg) == 17:
|
56
|
+
# steamid64
|
57
|
+
logger.info(f"SteamID64:{arg}")
|
58
|
+
user.SteamID64 = arg
|
59
|
+
msg = "绑定steamid64"
|
60
|
+
|
61
|
+
elif arg.startswith("STEAM_"):
|
62
|
+
# steamid
|
63
|
+
logger.info(f"SteamID:{arg}")
|
64
|
+
user.SteamID = arg
|
65
|
+
msg = "绑定steamid"
|
66
|
+
|
67
|
+
else:
|
68
|
+
# name
|
69
|
+
logger.info(f"Name:{arg}")
|
70
|
+
user.Name = arg
|
71
|
+
msg = "绑定名字"
|
72
|
+
await user.save()
|
73
|
+
|
74
|
+
return await UniMessage.text(f"{msg}成功").finish()
|
75
|
+
|
76
|
+
|
77
|
+
@anne_del.handle()
|
78
|
+
async def _(ev: Event):
|
79
|
+
if record := await SteamUser.get_or_none(userid=int(ev.get_user_id())):
|
80
|
+
logger.info(f"删除用户:{record}")
|
81
|
+
await record.delete()
|
82
|
+
await record.save()
|
83
|
+
return await UniMessage.text("删除成功").finish()
|
84
|
+
return await UniMessage.text("没有绑定信息呢").finish()
|
85
|
+
|
86
|
+
|
87
|
+
@anne_rank.handle()
|
88
|
+
async def _(ev: Event, args: Message = CommandArg()):
|
89
|
+
uid = await get_message_at(str(ev.json()))
|
90
|
+
if uid is None:
|
91
|
+
uid = int(int(ev.get_user_id()))
|
92
|
+
steamid = ""
|
93
|
+
arg: str = args.extract_plain_text().strip()
|
94
|
+
logger.info(f"arg:{arg}")
|
95
|
+
# 优先从数据库查询
|
96
|
+
if not arg:
|
97
|
+
msg = await SteamUser.get_or_none(userid=uid)
|
98
|
+
if msg is not None:
|
99
|
+
steamid = msg.SteamID
|
100
|
+
if not steamid:
|
101
|
+
name = msg.Name
|
102
|
+
if not name:
|
103
|
+
await UniMessage.text("未绑定名字/steamid").finish()
|
104
|
+
msg_dict = await L4API.get_anne_steamid(name)
|
105
|
+
if not msg_dict:
|
106
|
+
await UniMessage.text("绑定的昵称找不到呢").finish()
|
107
|
+
steamid = msg_dict[0]["steamid"]
|
108
|
+
logger.info(f"steamid:{steamid}")
|
109
|
+
|
110
|
+
# 再从arg中查找
|
111
|
+
else:
|
112
|
+
if arg.startswith("STEAM_"):
|
113
|
+
steamid = arg
|
114
|
+
else:
|
115
|
+
arg_dict = await L4API.get_anne_steamid(arg)
|
116
|
+
if not arg_dict:
|
117
|
+
await UniMessage.text("未找到该昵称玩家").finish()
|
118
|
+
steamid = arg_dict[0]["steamid"]
|
119
|
+
if not steamid:
|
120
|
+
await UniMessage.text("未找到玩家,请使用指令`l4搜索`查找").finish()
|
121
|
+
out_msg = await get_anne_rank_out(steamid)
|
122
|
+
if out_msg is None:
|
123
|
+
await UniMessage.text("未找到玩家").finish()
|
124
|
+
await UniMessage.text(out_msg).finish()
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
# anne战绩查询
|
3
|
+
from ..utils.api.request import L4API
|
4
|
+
|
5
|
+
|
6
|
+
async def get_anne_rank_out(steamid: str):
|
7
|
+
msg = await L4API.get_anne_playerdetail(steamid)
|
8
|
+
if msg is None:
|
9
|
+
return None
|
10
|
+
return f"""电信anne查询结果:
|
11
|
+
昵称:{msg['info']['name']}
|
12
|
+
排名:{msg['detail']['rank']}
|
13
|
+
分数:{msg['detail']["source"]}
|
14
|
+
击杀:{msg['detail']["kills"]}
|
15
|
+
爆头率:{msg['detail']["avg_source"]}
|
16
|
+
时间:{msg['info']['playtime']}
|
17
|
+
上次:{msg['info']['lasttime']}
|
18
|
+
"""
|
@@ -0,0 +1,102 @@
|
|
1
|
+
{
|
2
|
+
"基础服务": {
|
3
|
+
"desc": "无需任何权限",
|
4
|
+
"data": [
|
5
|
+
{
|
6
|
+
"name": "(组)",
|
7
|
+
"desc": "返回一个组的服务器信息",
|
8
|
+
"eg": "/云",
|
9
|
+
"need_ck": false,
|
10
|
+
"need_sk": false,
|
11
|
+
"need_admin": false
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"name": "(组)(id)",
|
15
|
+
"desc": "查询单服信息",
|
16
|
+
"eg": "/云1",
|
17
|
+
"need_ck": false,
|
18
|
+
"need_sk": false,
|
19
|
+
"need_admin": false
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"name": "l4查找(组)(玩家)",
|
23
|
+
"desc": "查询用户所在服务器状态",
|
24
|
+
"eg": "/l4查找 云 爱丽数码",
|
25
|
+
"need_ck": false,
|
26
|
+
"need_sk": false,
|
27
|
+
"need_admin": false
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "l4全服",
|
31
|
+
"desc": "返回可以查询的所有服务器组(未完成)",
|
32
|
+
"eg": "/l4全服",
|
33
|
+
"need_ck": false,
|
34
|
+
"need_sk": false,
|
35
|
+
"need_admin": false
|
36
|
+
}
|
37
|
+
]
|
38
|
+
},
|
39
|
+
"电信服anne服务": {
|
40
|
+
"desc": "电信anne服相关服务",
|
41
|
+
"data": [
|
42
|
+
{
|
43
|
+
"name": "Banne xx",
|
44
|
+
"desc": "绑定昵称/steamid",
|
45
|
+
"eg": "/Banne 爱丽数码",
|
46
|
+
"need_ck": false,
|
47
|
+
"need_sk": false,
|
48
|
+
"need_admin": false
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "Ranne(玩家)",
|
52
|
+
"desc": "查询anne个人信息,没有参数查自己",
|
53
|
+
"eg": "/Ranne 爱丽数码",
|
54
|
+
"need_ck": false,
|
55
|
+
"need_sk": false,
|
56
|
+
"need_admin": false
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"name": "Sanne(玩家)",
|
60
|
+
"desc": "按昵称查询anne玩家信息",
|
61
|
+
"eg": "/Sanne 爱丽数码",
|
62
|
+
"need_ck": false,
|
63
|
+
"need_sk": false,
|
64
|
+
"need_admin": false
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"name": "Danne(玩家)",
|
68
|
+
"desc": "删除anne玩家信息",
|
69
|
+
"eg": "/Danne 爱丽数码",
|
70
|
+
"need_ck": false,
|
71
|
+
"need_sk": false,
|
72
|
+
"need_admin": false
|
73
|
+
}
|
74
|
+
]
|
75
|
+
},
|
76
|
+
"管理员服务": {
|
77
|
+
"desc": "管理可以使用的指令",
|
78
|
+
"data": [
|
79
|
+
{
|
80
|
+
"name": "l4刷新",
|
81
|
+
"desc": "重载存储的ip数据",
|
82
|
+
"eg": "l4刷新",
|
83
|
+
"need_ck": false,
|
84
|
+
"need_sk": false,
|
85
|
+
"need_admin": true
|
86
|
+
}
|
87
|
+
]
|
88
|
+
},
|
89
|
+
"其他服务": {
|
90
|
+
"desc": "一些杂项服务",
|
91
|
+
"data": [
|
92
|
+
{
|
93
|
+
"name": "connect",
|
94
|
+
"desc": "直接发送求生链接返回信息",
|
95
|
+
"eg": "connect 127.0.0.1:27015",
|
96
|
+
"need_ck": false,
|
97
|
+
"need_sk": false,
|
98
|
+
"need_admin": false
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Dict, Union
|
3
|
+
|
4
|
+
import aiofiles
|
5
|
+
from msgspec import json as msgjson
|
6
|
+
from PIL import Image
|
7
|
+
|
8
|
+
from ..config import ICONPATH
|
9
|
+
from ..l4_image.convert import core_font
|
10
|
+
from ..l4_image.model import PluginHelp
|
11
|
+
from .draw import get_help
|
12
|
+
|
13
|
+
__version__ = "1.0.0a2"
|
14
|
+
TEXT_PATH = Path(__file__).parent / "texture2d"
|
15
|
+
HELP_DATA = Path(__file__).parent / "Help.json"
|
16
|
+
|
17
|
+
|
18
|
+
async def get_help_data() -> Union[Dict[str, PluginHelp], None]:
|
19
|
+
if HELP_DATA.exists():
|
20
|
+
async with aiofiles.open(HELP_DATA, "rb") as file:
|
21
|
+
return msgjson.decode(
|
22
|
+
await file.read(),
|
23
|
+
type=Dict[str, PluginHelp],
|
24
|
+
)
|
25
|
+
return None
|
26
|
+
|
27
|
+
|
28
|
+
async def get_l4d2_core_help() -> Union[bytes, str]:
|
29
|
+
help_data = await get_help_data()
|
30
|
+
if help_data is None:
|
31
|
+
return "暂未找到帮助数据..."
|
32
|
+
|
33
|
+
bg_out = Image.open(TEXT_PATH / "bg.jpg")
|
34
|
+
bg_new = Image.new(
|
35
|
+
"RGBA",
|
36
|
+
(bg_out.width, bg_out.height),
|
37
|
+
(255, 255, 255, 100),
|
38
|
+
)
|
39
|
+
bg_out.paste(bg_new, None, bg_new)
|
40
|
+
|
41
|
+
return await get_help(
|
42
|
+
"L4插件",
|
43
|
+
f"版本号:{__version__}",
|
44
|
+
help_data,
|
45
|
+
bg_out,
|
46
|
+
Image.open(TEXT_PATH / "icon.png"),
|
47
|
+
Image.open(TEXT_PATH / "badge.png"),
|
48
|
+
Image.open(TEXT_PATH / "banner.png"),
|
49
|
+
Image.open(TEXT_PATH / "button.png"),
|
50
|
+
core_font,
|
51
|
+
is_dark=False,
|
52
|
+
column=4,
|
53
|
+
is_gaussian=False,
|
54
|
+
text_color=(23, 67, 91),
|
55
|
+
sub_c=(49, 110, 144),
|
56
|
+
icon_path=ICONPATH,
|
57
|
+
)
|