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.
Files changed (147) hide show
  1. nonebot_plugin_l4d2_server/__init__.py +10 -93
  2. nonebot_plugin_l4d2_server/__main__.py +140 -0
  3. nonebot_plugin_l4d2_server/config.py +35 -0
  4. nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
  5. nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
  6. nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
  7. nonebot_plugin_l4d2_server/l4_help/Help.json +102 -0
  8. nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
  9. nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
  10. nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
  11. nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
  12. nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
  13. nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
  14. nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
  15. nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
  16. nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
  17. nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
  18. nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
  19. nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
  20. nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
  21. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
  22. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
  23. nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
  24. nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
  25. nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
  26. nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
  27. nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
  28. nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
  29. nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
  30. nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
  31. nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
  32. nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
  33. nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
  34. nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
  35. nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
  36. nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
  37. nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
  38. nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
  39. nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
  40. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
  41. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
  42. nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
  43. nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
  44. nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
  45. nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
  46. nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  47. nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  48. nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  49. nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  50. nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  51. nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
  52. nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
  53. nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
  54. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +11 -35
  55. nonebot_plugin_l4d2_server/l4_image/html_img.py +105 -0
  56. nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
  57. nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/back.png +0 -0
  58. nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
  59. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/head/head.png +0 -0
  60. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/logo.png +0 -0
  61. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/player1.jpg +0 -0
  62. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +299 -0
  63. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  64. nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
  65. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +341 -0
  66. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  67. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +355 -0
  68. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  69. nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
  70. nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
  71. nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
  72. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/l.svg +0 -1
  73. nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
  74. nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +247 -0
  75. nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
  76. nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
  77. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/w.svg +1 -1
  78. nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
  79. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +4 -2
  80. nonebot_plugin_l4d2_server/l4_request/__init__.py +143 -0
  81. nonebot_plugin_l4d2_server/l4_request/draw_msg.py +83 -0
  82. nonebot_plugin_l4d2_server/utils/api/api.py +10 -0
  83. nonebot_plugin_l4d2_server/utils/api/models.py +137 -0
  84. nonebot_plugin_l4d2_server/utils/api/request.py +337 -0
  85. nonebot_plugin_l4d2_server/utils/database/models.py +18 -0
  86. nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +60 -63
  87. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +57 -66
  88. nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
  89. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +1 -1
  90. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -263
  91. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -231
  92. nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
  93. nonebot_plugin_l4d2_server/data/img/white.png +0 -0
  94. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
  95. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
  96. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
  97. nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
  98. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
  99. nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
  100. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
  101. nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
  102. nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
  103. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
  104. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
  105. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
  106. nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
  107. nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
  108. nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
  109. nonebot_plugin_l4d2_server/l4d2_image/__init__.py +0 -125
  110. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
  111. nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
  112. nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
  113. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
  114. nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
  115. nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
  116. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
  117. nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
  118. nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
  119. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
  120. nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
  121. nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
  122. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
  123. nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
  124. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
  125. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
  126. nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
  127. nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
  128. nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
  129. nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
  130. nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
  131. nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
  132. nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
  133. nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
  134. nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
  135. nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
  136. nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
  137. nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
  138. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
  139. nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
  140. nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
  141. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/anne.html +0 -0
  142. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/group_ip.html +0 -0
  143. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/ip.html +0 -0
  144. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/fingerprint.svg +0 -0
  145. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/vue.css +0 -0
  146. /nonebot_plugin_l4d2_server/{l4d2_data/database.py → l4_request/utils.py} +0 -0
  147. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -1,69 +0,0 @@
1
- import json
2
- import os
3
- import platform
4
- import subprocess
5
- import sys
6
- import time
7
- from pathlib import Path
8
-
9
- import aiofiles
10
-
11
- # from ..utils.db_operation.db_operation import config_check
12
-
13
- bot_start = Path().cwd() / "bot.py"
14
- restart_sh_path = Path().cwd() / "gs_restart.sh"
15
- update_log_path = Path(__file__).parent / "update_log.json"
16
-
17
- _restart_sh = """#!/bin/bash
18
- kill -9 {}
19
- {} &"""
20
-
21
-
22
- async def get_restart_sh(extra: str) -> str:
23
- args = f"{extra} {bot_start.absolute()!s}"
24
- return _restart_sh.format(str(bot_start.absolute()), args)
25
-
26
-
27
- async def restart_genshinuid(send_type: str, send_id: str) -> None:
28
- # extra = ''
29
- # if await config_check('UsePoetry'):
30
- # extra = 'poetry run '
31
- extra = sys.executable
32
- restart_sh = await get_restart_sh(extra)
33
- if not restart_sh_path.exists():
34
- async with aiofiles.open(restart_sh_path, "w", encoding="utf8") as f:
35
- await f.write(restart_sh)
36
- if platform.system() == "Linux":
37
- os.system(f"chmod +x {restart_sh_path!s}") # noqa: ASYNC102
38
- os.system(f"chmod +x {bot_start!s}") # noqa: ASYNC102
39
- now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
40
- update_log = {
41
- "type": "restart",
42
- "msg": "重启完成!",
43
- "send_type": send_type,
44
- "send_to": send_id,
45
- "time": now_time,
46
- }
47
- async with aiofiles.open(str(update_log_path), mode="w", encoding="utf-8") as f:
48
- await f.write(json.dumps(update_log))
49
- if platform.system() == "Linux":
50
- os.execl(str(restart_sh_path), " ")
51
- else:
52
- pid = os.getpid()
53
- subprocess.Popen( # noqa: ASYNC101
54
- f"taskkill /F /PID {pid} & {extra} {bot_start}",
55
- shell=True,
56
- )
57
-
58
-
59
- async def restart_message() -> dict:
60
- if update_log_path.exists():
61
- async with aiofiles.open(update_log_path, "r", encoding="utf-8") as f:
62
- content = await f.read()
63
- update_log = json.loads(content)
64
- msg = f'{update_log["msg"]}\n重启时间:{update_log["time"]}'
65
- update_log["msg"] = msg
66
- update_log_path.unlink()
67
- restart_sh_path.unlink()
68
- return update_log
69
- return {}
@@ -1,53 +0,0 @@
1
- from pathlib import Path
2
- from typing import List, Union
3
-
4
- import git
5
- from git.exc import GitCommandError
6
- from nonebot.log import logger
7
-
8
- log_config = (
9
- {
10
- "key": "✨🐛🎨⚡🍱♻️",
11
- "num": 7,
12
- },
13
- )
14
-
15
-
16
- async def update_from_git(
17
- level: int = 0,
18
- repo_path: Union[str, Path, None] = None,
19
- log_config=log_config,
20
- is_update: bool = True,
21
- ) -> List[str]:
22
- if repo_path is None:
23
- repo_path = Path(__file__).parents[2]
24
- repo = git.Repo(repo_path) # type: ignore
25
- o = repo.remotes.origin
26
-
27
- if is_update:
28
- # 清空暂存
29
- if level >= 2:
30
- logger.warning("[l4更新] 正在执行 git clean --xdf")
31
- repo.git.clean("-xdf")
32
- # 还原上次更改
33
- if level >= 1:
34
- logger.warning("[l4更新] 正在执行 git reset --hard")
35
- repo.git.reset("--hard")
36
-
37
- try:
38
- pull_log = o.pull()
39
- logger.info(f"[l4更新] {pull_log}")
40
- except GitCommandError as e:
41
- logger.warning(e)
42
- return []
43
-
44
- commits = list(repo.iter_commits(max_count=40))
45
- log_list = []
46
- for commit in commits:
47
- if isinstance(commit.message, str):
48
- for key in log_config["key"]:
49
- if key in commit.message:
50
- log_list.append(commit.message.replace("\n", ""))
51
- if len(log_list) >= int(log_config["num"]):
52
- break
53
- return log_list
@@ -1,53 +0,0 @@
1
- from typing import List
2
-
3
- from pydantic import BaseModel
4
-
5
-
6
- class PlayerInfo(BaseModel):
7
- """读取玩家信息"""
8
-
9
- name: str = ""
10
- Score: int = 0
11
- Duration: str = ""
12
-
13
-
14
- class ServerStatus(BaseModel):
15
- """单服务器查询信息"""
16
-
17
- name: str = "null"
18
- """服务器名称"""
19
- map_: str = "null"
20
- """服务器地图"""
21
- players: int = 0
22
- """当前玩家数量"""
23
- Players: List[PlayerInfo] = []
24
- """当前玩家信息"""
25
- max_players: int = 0
26
- """最大玩家数量"""
27
- rank_players: str = "null"
28
- """玩家数量对比"""
29
- ping: str = "null"
30
- """服务器延迟"""
31
- number: str = "null"
32
- """服务器序号"""
33
- ip: str = "null"
34
- """服务器ip"""
35
- system: str = "m.svg"
36
- """服务器系统,["l","w","m"]"""
37
-
38
-
39
- class ServerGroup(BaseModel):
40
- """组服务器信息"""
41
-
42
- server_id: int = 0
43
- """服务器序号"""
44
- server_tag: str = "服务器"
45
- """服务器组名字"""
46
- server_number: int = 0
47
- """群组当期启动服务器数量"""
48
- server_all_number: int = 0
49
- """群组总服务器数量"""
50
- server_people: int = 0
51
- """群组当前在线人数"""
52
- server_all_people: int = 0
53
- """群组当前总容纳人数"""
@@ -1,23 +0,0 @@
1
- from nonebot import on_command
2
-
3
- from .config import MASTER
4
-
5
- help_ = on_command("l4_help", aliases={"求生帮助"}, priority=20, block=True)
6
-
7
-
8
- connect_rcon = on_command(
9
- "Rrcon",
10
- aliases={"求生连接", "求生链接", "求生rcon"},
11
- priority=50,
12
- block=False,
13
- )
14
- end_connect = ["stop", "结束", "连接结束", "结束连接"]
15
- search_api = on_command(
16
- "search",
17
- aliases={"求生三方"},
18
- priority=20,
19
- block=True,
20
- permission=MASTER,
21
- )
22
- # which_map = on_keyword("是什么图"), priority=20, block=False)
23
- reload_ip = on_command("l4_reload", aliases={"重载ip"}, priority=30, permission=MASTER)
@@ -1,201 +0,0 @@
1
- import platform
2
- from pathlib import Path
3
- from typing import Any, Dict, List
4
-
5
- from nonebot import get_driver
6
- from nonebot.adapters.onebot.v11.permission import (
7
- GROUP_ADMIN,
8
- GROUP_OWNER,
9
- PRIVATE_FRIEND,
10
- )
11
- from nonebot.permission import SUPERUSER
12
- from pydantic import BaseModel, Field
13
- from ruamel import yaml
14
-
15
- file_format = (".vpk", ".zip", ".7z", "rar")
16
- # 权限
17
-
18
- driver = get_driver()
19
- COMMAND_START = list(driver.config.command_start)
20
-
21
- headers = {
22
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0", # noqa: E501
23
- }
24
-
25
- try:
26
- NICKNAME: str = next(iter(driver.config.nickname))
27
- except Exception:
28
- NICKNAME = "bot"
29
- CHECK_FILE: int = 0
30
-
31
-
32
- re_master = SUPERUSER | GROUP_OWNER
33
- MASTER = SUPERUSER | GROUP_ADMIN | GROUP_OWNER
34
- ADMINISTRATOR = SUPERUSER | GROUP_ADMIN | GROUP_OWNER | PRIVATE_FRIEND
35
- # file 填写求生服务器所在路径
36
-
37
- DATA_PATH = Path() / "data" / "L4D2"
38
- CONFIG_PATH = DATA_PATH / "l4d2.yml"
39
- CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
40
-
41
-
42
- class L4d2GroupConfig(BaseModel):
43
- enable: bool = Field(True, alias="是否启用求生功能")
44
- map_master: List[str] = Field([], alias="分群地图管理员")
45
-
46
- def update(self, **kwargs):
47
- for key, value in kwargs.items():
48
- if key in self.__fields__:
49
- self.__setattr__(key, value)
50
-
51
-
52
- class L4d2Config(BaseModel):
53
- total_enable: bool = Field(True, alias="是否全局启用求生功能")
54
- l4_image: bool = Field(False, alias="是否启用图片")
55
- web_username: str = Field("l4d2", alias="后台管理用户名")
56
- web_password: str = Field("admin", alias="后台管理密码")
57
- l4_style: str = Field("standard", alias="图片风格")
58
- l4_img_name: int = Field(4, alias="图片显示玩家数量")
59
- l4_ipall: List[Dict[str, Any]] = Field(
60
- [
61
- {
62
- "id_rank": "1",
63
- "place": False,
64
- "location": "C:\\l4d2",
65
- "host": "127.0.0.1",
66
- "port": "20715",
67
- "rcon": "114514",
68
- "server_id": "本地地图",
69
- },
70
- {
71
- "id_rank": "2",
72
- "place": True,
73
- "location": "/home/unbuntu/coop",
74
- "host": "11.4.51.4",
75
- "port": "20715",
76
- "rcon": "9191810",
77
- "account": "root",
78
- "password": "114514",
79
- "server_id": "远程地图",
80
- },
81
- ],
82
- alias="l4服务器ip集合",
83
- )
84
- l4_zl_tag: List[str] = Field(["云"], alias="坐牢三指令")
85
- l4_number: int = Field(1, alias="第几个地图路径")
86
- web_secret_key: str = Field(
87
- "49c294d32f69b732ef6447c18379451ce1738922a75cd1d4812ef150318a2ed0",
88
- alias="后台管理token密钥",
89
- )
90
- l4_master: List[str] = Field(default=["114514919"], alias="求生地图全局管理员qq")
91
- # l4_ip:bool = Field(False, alias='查询地图是否显示ip')
92
- l4_font: str = Field(default="simsun.ttc", alias="字体")
93
- l4_only: bool = Field(default=False, alias="下载地图是是否阻碍其他指令")
94
- l4_push_interval: int = Field(default=3, alias="定时任务间隔")
95
- l4_push_times: int = Field(default=10, alias="定时任务次数")
96
- l4_connect: bool = Field(default=True, alias="是否在查服命令后加入connect ip")
97
- l4_group_upload: bool = Field(
98
- default=False, alias="是否在群里传地图的时候,提示上传服务器"
99
- )
100
- group_config: Dict[int, L4d2GroupConfig] = Field(
101
- default_factory=dict, alias="分群配置"
102
- )
103
-
104
- def update(self, **kwargs):
105
- for key, value in kwargs.items():
106
- if key in self.__fields__:
107
- self.__setattr__(key, value)
108
-
109
-
110
- class L4d2ConfigManager:
111
- def __init__(self):
112
- self.file_path = CONFIG_PATH
113
- if self.file_path.exists():
114
- self.config = L4d2Config.parse_obj(
115
- yaml.load(
116
- self.file_path.read_text(encoding="utf-8"),
117
- Loader=yaml.Loader,
118
- ),
119
- )
120
- else:
121
- self.config = L4d2Config() # type: ignore
122
- self.save()
123
-
124
- def get_group_config(self, group_id: int) -> L4d2GroupConfig:
125
- if group_id not in self.config.group_config:
126
- self.config.group_config[group_id] = L4d2GroupConfig() # type: ignore
127
- self.save()
128
- return self.config.group_config[group_id]
129
-
130
- @property
131
- def config_list(self) -> List[str]:
132
- return list(self.config.dict(by_alias=True).keys())
133
-
134
- def save(self):
135
- with self.file_path.open("w", encoding="utf-8") as f:
136
- yaml.dump(
137
- self.config.dict(by_alias=True),
138
- f,
139
- indent=2,
140
- Dumper=yaml.RoundTripDumper,
141
- allow_unicode=True,
142
- )
143
-
144
-
145
- # 参数设置为全局变量
146
- global config_manager, l4_config
147
- config_manager = L4d2ConfigManager()
148
- l4_config = config_manager.config
149
-
150
-
151
- class UserModel(BaseModel):
152
- username: str
153
- password: str
154
-
155
-
156
- """
157
- 地图路径
158
- """
159
- vpk_path = "left4dead2/addons"
160
-
161
-
162
- PLAYERSDATA = Path() / "data/L4D2/image/players"
163
- """用户数据路径"""
164
- TEXT_PATH = Path(__file__).parent.parent / "data/L4D2/image"
165
- """图片存储路径"""
166
- TEXT_XPATH = Path() / "data/L4D2/image"
167
- """内置图片路径"""
168
-
169
-
170
- PLAYERSDATA = Path() / "data/L4D2/sql"
171
- """数据库路径"""
172
- DATASQLITE = Path().parent.parent / "data/L4D2/sql/L4D2.db"
173
- """数据库!"""
174
-
175
- table_data = ["L4d2_players", "L4D2_server"]
176
- """数据库表"""
177
- L4d2_players_tag = ["qq", "nickname", "steamid"]
178
- """数据库表1"""
179
- L4d2_server_tag = ["id", "qqgroup", "host", "port", "rcon"]
180
- """数据库表2"""
181
- L4d2_INTEGER = ["id", "qq", "qqgroup", "port"]
182
- """INITEGER的表头"""
183
- L4d2_TEXT = ["nickname", "steamid", "host", "rcon", "path"]
184
- """TEXT的表头"""
185
- L4d2_BOOLEAN = ["use"]
186
- """BOOLEAN的表头"""
187
-
188
- tables_columns = {table_data[0]: L4d2_players_tag, table_data[1]: L4d2_server_tag}
189
-
190
- # 求生anne服务器
191
- anne_url = "https://sb.trygek.com/"
192
-
193
-
194
- # 系统
195
- if platform.system() == "Windows":
196
- systems: str = "win"
197
- elif platform.system() == "Linux":
198
- systems: str = "linux"
199
- else:
200
- systems: str = "others"
201
- ANNE_IP: Dict[str, List[Dict[str, str]]] = {}
@@ -1,59 +0,0 @@
1
- # 坐牢
2
- PRISON = {
3
- 1: [
4
- "⭐低级牢房",
5
- "⭐牢动最光荣",
6
- "⭐能者多牢",
7
- "⭐年年有牢",
8
- ],
9
- 2: [
10
- "⭐⭐中级牢房",
11
- "⭐⭐牢不可破",
12
- "⭐⭐牢不可破联盟",
13
- "⭐⭐牢底坐穿联盟",
14
- "⭐⭐牢饭恰饱联盟",
15
- "⭐⭐个个都是人才说话又好听",
16
- "⭐⭐来点狱卒",
17
- ],
18
- 3: [
19
- "⭐⭐⭐曼德拉的前半生",
20
- "⭐⭐⭐肖申克的救赎",
21
- "⭐⭐⭐甲级战犯",
22
- "⭐⭐⭐刘培强正在尝试逃离冷冻仓",
23
- ],
24
- }
25
-
26
- QUEREN = {
27
- 1: [
28
- "📞📞1Q3速来坐牢",
29
- "📞📞📞发起了anne坐牢",
30
- "📞📞📞摇人摇人,一个人玩个锤子",
31
- "📞📞📞1=3速来坐牢",
32
- "📞📞📞差三个速来",
33
- ],
34
- 2: [
35
- "📞📞2Q2速来坐牢",
36
- "📞📞2=2这牢十分的珍贵,让同志们先做",
37
- "📞📞牢房过半,速速人牢",
38
- "📞📞2Q2有大佬带逛街速来",
39
- "📞📞2=2速来坐牢",
40
- ],
41
- 3: [
42
- "📞牢房三缺一,速来",
43
- "📞3Q1来个大佬带逛街",
44
- "📞3Q1就等你了",
45
- "📞别来他们三个还没一个人分高",
46
- ],
47
- 4: [
48
- "📞有人旁观,速来",
49
- "📞有人越狱,呼叫支援",
50
- "📞别让牢房成为寂寞",
51
- "📞有人还没进,希望你网络比他好",
52
- ],
53
- }
54
- KAILAO = [
55
- "🏠又来坐牢了?",
56
- "🏠已经变成牢房的样子了!",
57
- "🏠是谁在呼唤牢房?",
58
- "🏠牢房青云阁雅座四位",
59
- ]
@@ -1,35 +0,0 @@
1
- from nonebot.adapters.onebot.v11 import Message, NoticeEvent
2
- from nonebot.params import CommandArg, Depends
3
- from nonebot.rule import Rule
4
-
5
- from .config import file_format, l4_config
6
-
7
-
8
- async def full_command(arg: Message = CommandArg()) -> bool:
9
- return not bool(str(arg))
10
-
11
-
12
- def FullCommand() -> Rule: # noqa: N802
13
- return Rule(full_command)
14
-
15
-
16
- def FullCommandDepend(): # noqa: N802
17
- return Depends(full_command)
18
-
19
-
20
- def wenjian(event: NoticeEvent):
21
- args = event.dict()
22
- try:
23
- name: str = args["file"]["name"]
24
- usr_id = str(args["user_id"])
25
- except KeyError:
26
- return False
27
- if args["notice_type"] == "offline_file":
28
- if l4_config.l4_master:
29
- return name.endswith(file_format) and usr_id in l4_config.l4_master
30
- return name.endswith(file_format)
31
- if args["notice_type"] == "group_upload":
32
- if l4_config.l4_master:
33
- return usr_id in l4_config.l4_master and name.endswith(file_format)
34
- return False
35
- return False
@@ -1,43 +0,0 @@
1
- import httpx
2
- from bs4 import BeautifulSoup
3
-
4
-
5
- def anne_search(name: str):
6
- """输入名字返回列表["""
7
- url = "https://sb.trygek.com/l4d_stats/ranking/search.php"
8
- data = {"search": name}
9
- headers = {"Content-Type": "application/x-www-form-urlencoded"}
10
- data = httpx.post(url, data=data, headers=headers, timeout=60).content.decode(
11
- "utf-8",
12
- )
13
- soup = BeautifulSoup(data, "html.parser")
14
- # 获取标题
15
- title = []
16
- thead = soup.find("thead")
17
- if not thead:
18
- return None
19
- for i in thead.find_all("td"): # type: ignore
20
- tag = i.text.strip()
21
- title.append(tag)
22
- title.append("steamid")
23
- # 角色信息
24
- datas_table = soup.find("table")
25
- if not datas_table:
26
- return None
27
- datas_tbody = datas_table.find("tbody")
28
- if not datas_tbody:
29
- return None
30
- datas = datas_tbody.find_all("tr") # type: ignore
31
- return [datas, title]
32
-
33
-
34
- def name_steamid_html(name):
35
- """您称通过网页来返回求生steamid"""
36
- data_title = anne_search(name)
37
- if not data_title:
38
- return None
39
- data = data_title[0]
40
- for i in data:
41
- onclick: str = i["onclick"]
42
- return onclick.split("=")[2].strip("'")
43
- return None
@@ -1,32 +0,0 @@
1
- import base64
2
- from typing import Optional
3
-
4
- from nonebot_plugin_saa import Image, MessageFactory, Text
5
- from nonebot_plugin_txt2img import Txt2Img
6
-
7
- from .config import l4_config
8
-
9
- l4_font = l4_config.l4_font
10
- """直接超的智障回复"""
11
-
12
-
13
- async def mode_txt_to_img(
14
- title: str,
15
- text: str,
16
- ex_text: Optional[str] = None,
17
- font_size: int = 32,
18
- ex_msg: Optional[str] = None,
19
- ):
20
- """文字转图片,如果有额外的信息则构造图文"""
21
- txt2img = Txt2Img()
22
- txt2img.set_font_size(font_size)
23
- pic = txt2img.draw(title, text)
24
- pic = base64.b64decode(pic)
25
- if ex_text:
26
- ex_msg = ex_text
27
- if not ex_msg:
28
- msg = MessageFactory([Image(pic)])
29
- else:
30
- msg = MessageFactory([Image(pic), Text(ex_msg)])
31
- await msg.finish()
32
- return