nonebot-plugin-l4d2-server 1.0.0a1__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 (136) hide show
  1. nonebot_plugin_l4d2_server/__init__.py +4 -4
  2. nonebot_plugin_l4d2_server/__main__.py +64 -14
  3. nonebot_plugin_l4d2_server/config.py +6 -1
  4. nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
  5. nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
  6. nonebot_plugin_l4d2_server/l4_help/Help.json +59 -22
  7. nonebot_plugin_l4d2_server/l4_help/__init__.py +2 -2
  8. nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
  9. nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
  10. nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
  11. nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
  12. nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
  13. nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
  14. nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
  15. nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
  16. nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
  17. nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
  18. nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
  19. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
  20. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
  21. nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
  22. nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
  23. nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
  24. nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
  25. nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
  26. nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
  27. nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
  28. nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
  29. nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
  30. nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
  31. nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
  32. nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
  33. nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
  34. nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
  35. nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
  36. nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
  37. nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
  38. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
  39. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
  40. nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
  41. nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
  42. nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
  43. nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
  44. nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  45. nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  46. nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  47. nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  48. nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  49. nonebot_plugin_l4d2_server/l4_image/__init__.py +4 -4
  50. nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
  51. nonebot_plugin_l4d2_server/l4_image/convert.py +1 -1
  52. nonebot_plugin_l4d2_server/l4_image/download.py +5 -5
  53. nonebot_plugin_l4d2_server/l4_image/html_img.py +45 -74
  54. nonebot_plugin_l4d2_server/l4_image/image_tools.py +11 -11
  55. nonebot_plugin_l4d2_server/l4_image/img/anne/back.png +0 -0
  56. nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
  57. nonebot_plugin_l4d2_server/l4_image/img/head/head.png +0 -0
  58. nonebot_plugin_l4d2_server/l4_image/img/header/logo.png +0 -0
  59. nonebot_plugin_l4d2_server/l4_image/img/header/player1.jpg +0 -0
  60. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +17 -30
  61. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  62. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +17 -26
  63. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  64. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +48 -14
  65. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  66. nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +14 -24
  67. nonebot_plugin_l4d2_server/{data/img → l4_image/img/template}/vac.png +0 -0
  68. nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
  69. nonebot_plugin_l4d2_server/l4_image/vtfs.py +3 -3
  70. nonebot_plugin_l4d2_server/l4_request/__init__.py +68 -9
  71. nonebot_plugin_l4d2_server/l4_request/draw_msg.py +38 -43
  72. nonebot_plugin_l4d2_server/l4_request/utils.py +0 -0
  73. nonebot_plugin_l4d2_server/utils/api/api.py +8 -2
  74. nonebot_plugin_l4d2_server/utils/api/models.py +108 -0
  75. nonebot_plugin_l4d2_server/utils/api/request.py +257 -39
  76. nonebot_plugin_l4d2_server/utils/database/models.py +12 -23
  77. nonebot_plugin_l4d2_server/utils/utils.py +10 -10
  78. {nonebot_plugin_l4d2_server-1.0.0a1.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +19 -11
  79. nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
  80. nonebot_plugin_l4d2_server/data/L4D2/image/head/head.png +0 -0
  81. nonebot_plugin_l4d2_server/data/L4D2/image/header/logo.png +0 -0
  82. nonebot_plugin_l4d2_server/data/L4D2/image/header/player1.jpg +0 -0
  83. nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +0 -68
  84. nonebot_plugin_l4d2_server/data/L4D2/image/template/back.png +0 -0
  85. nonebot_plugin_l4d2_server/data/L4D2/image/template/fingerprint.svg +0 -15
  86. nonebot_plugin_l4d2_server/data/L4D2/image/template/group_ip.html +0 -258
  87. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -262
  88. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -269
  89. nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +0 -54
  90. nonebot_plugin_l4d2_server/data/L4D2/image/template/l.svg +0 -10
  91. nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
  92. nonebot_plugin_l4d2_server/data/L4D2/image/template/vue.css +0 -531
  93. nonebot_plugin_l4d2_server/data/L4D2/image/template/w.svg +0 -1
  94. nonebot_plugin_l4d2_server/data/icon//344/273/213/347/273/215.png +0 -0
  95. nonebot_plugin_l4d2_server/data/icon//344/273/273/345/212/241.png +0 -0
  96. nonebot_plugin_l4d2_server/data/icon//344/277/241/346/201/257.png +0 -0
  97. nonebot_plugin_l4d2_server/data/icon//345/205/254/345/221/212.png +0 -0
  98. nonebot_plugin_l4d2_server/data/icon//345/210/200/345/211/221.png +0 -0
  99. nonebot_plugin_l4d2_server/data/icon//345/210/207/346/215/242.png +0 -0
  100. nonebot_plugin_l4d2_server/data/icon//345/210/240/351/231/244.png +0 -0
  101. nonebot_plugin_l4d2_server/data/icon//345/210/267/346/226/260.png +0 -0
  102. nonebot_plugin_l4d2_server/data/icon//345/215/241/347/273/204.png +0 -0
  103. nonebot_plugin_l4d2_server/data/icon//345/223/252/351/207/214.png +0 -0
  104. nonebot_plugin_l4d2_server/data/icon//345/234/260/345/233/276.png +0 -0
  105. nonebot_plugin_l4d2_server/data/icon//345/257/274/345/205/245.png +0 -0
  106. nonebot_plugin_l4d2_server/data/icon//345/257/274/345/207/272.png +0 -0
  107. nonebot_plugin_l4d2_server/data/icon//345/275/261.png +0 -0
  108. nonebot_plugin_l4d2_server/data/icon//346/213/274/345/233/276.png +0 -0
  109. nonebot_plugin_l4d2_server/data/icon//346/216/242/347/264/242.png +0 -0
  110. nonebot_plugin_l4d2_server/data/icon//346/216/250/351/200/201.png +0 -0
  111. nonebot_plugin_l4d2_server/data/icon//346/224/266/351/233/206.png +0 -0
  112. nonebot_plugin_l4d2_server/data/icon//346/224/273/347/225/245.png +0 -0
  113. nonebot_plugin_l4d2_server/data/icon//346/233/264/346/226/260.png +0 -0
  114. nonebot_plugin_l4d2_server/data/icon//346/235/220/346/226/231.png +0 -0
  115. nonebot_plugin_l4d2_server/data/icon//346/237/245/350/257/242.png +0 -0
  116. nonebot_plugin_l4d2_server/data/icon//346/240/241/351/252/214.png +0 -0
  117. nonebot_plugin_l4d2_server/data/icon//346/257/217/346/234/210.png +0 -0
  118. nonebot_plugin_l4d2_server/data/icon//346/267/261/346/270/212.png +0 -0
  119. nonebot_plugin_l4d2_server/data/icon//346/267/273/345/212/240.png +0 -0
  120. nonebot_plugin_l4d2_server/data/icon//346/270/205/351/231/244.png +0 -0
  121. nonebot_plugin_l4d2_server/data/icon//347/212/266/346/200/201.png +0 -0
  122. nonebot_plugin_l4d2_server/data/icon//347/255/276/345/210/260.png +0 -0
  123. nonebot_plugin_l4d2_server/data/icon//347/273/221/345/256/232.png +0 -0
  124. nonebot_plugin_l4d2_server/data/icon//350/241/250.png +0 -0
  125. nonebot_plugin_l4d2_server/data/icon//350/241/250/346/203/205.png +0 -0
  126. nonebot_plugin_l4d2_server/data/icon//350/247/222/350/211/262.png +0 -0
  127. nonebot_plugin_l4d2_server/data/icon//350/256/260/345/275/225.png +0 -0
  128. nonebot_plugin_l4d2_server/data/icon//351/205/215/347/275/256.png +0 -0
  129. nonebot_plugin_l4d2_server/data/icon//351/207/215/345/220/257.png +0 -0
  130. nonebot_plugin_l4d2_server/data/img/l4d2.png +0 -0
  131. nonebot_plugin_l4d2_server/data/img/linux.png +0 -0
  132. nonebot_plugin_l4d2_server/data/img/white.png +0 -0
  133. nonebot_plugin_l4d2_server/l4_image/img/template//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  134. nonebot_plugin_l4d2_server-1.0.0a1.dist-info/RECORD +0 -144
  135. {nonebot_plugin_l4d2_server-1.0.0a1.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +0 -0
  136. {nonebot_plugin_l4d2_server-1.0.0a1.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -17,15 +17,15 @@
17
17
 
18
18
  from nonebot import get_driver, require
19
19
 
20
- require("nonebot_plugin_htmlrender") # noqa: F401
20
+ require("nonebot_plugin_htmlrender")
21
21
  require("nonebot_plugin_alconna")
22
+ require("nonebot_plugin_tortoise_orm")
22
23
 
23
- from nonebot import require
24
- from nonebot.plugin import PluginMetadata, inherit_supported_adapters
24
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters # noqa: E402
25
25
 
26
26
  from . import __main__ as __main__ # noqa: E402
27
27
  from .config import ConfigModel # noqa: E402
28
- from .l4_help import __version__
28
+ from .l4_help import __version__ # noqa: E402
29
29
 
30
30
  driver = get_driver()
31
31
 
@@ -15,25 +15,37 @@
15
15
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
  """
17
17
 
18
- from typing import Optional
18
+ from typing import TYPE_CHECKING, List, Optional
19
19
 
20
- from nonebot import require
21
20
  from nonebot.adapters import Message
22
21
  from nonebot.log import logger
23
22
  from nonebot.matcher import Matcher
24
23
  from nonebot.params import CommandArg, CommandStart, RawCommand
25
24
  from nonebot.plugin import on_command
26
-
27
- require("nonebot_plugin_alconna")
28
25
  from nonebot_plugin_alconna import UniMessage
29
26
 
27
+ from .config import config
30
28
  from .l4_help import get_l4d2_core_help
31
- from .l4_request import COMMAND, get_ip_server, get_server_detail, reload_ip
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()
32
42
 
33
- l4_help = on_command("l4帮助", aliases={"l4help", "l4d2帮助"})
34
- l4_request = on_command("anne", aliases=COMMAND)
35
- l4_reload = on_command("l4重载", aliases={"l4刷新"})
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全服"})
36
47
  l4_connect = on_command("connect", aliases={"l4连接"})
48
+ l4_find_player = on_command("l4find", aliases={"l4查找"})
37
49
 
38
50
 
39
51
  @l4_help.handle()
@@ -41,7 +53,6 @@ async def _(matcher: Matcher):
41
53
  """帮助"""
42
54
  logger.info("开始执行[l4d2帮助]")
43
55
  im = await get_l4d2_core_help()
44
- print(type(im))
45
56
  if isinstance(im, str):
46
57
  await matcher.finish(im)
47
58
  await UniMessage.image(raw=im).send()
@@ -65,6 +76,8 @@ async def _(
65
76
  if command == "anne":
66
77
  command = "云"
67
78
  _id: Optional[str] = args.extract_plain_text()
79
+ if _id is not None and not _id.isdigit() and _id:
80
+ return
68
81
  if not _id:
69
82
  _id = None
70
83
  logger.info(f"组:{command} ;数字:{_id}")
@@ -72,9 +85,34 @@ async def _(
72
85
  if msg is not None:
73
86
  if isinstance(msg, str):
74
87
  await UniMessage.text(msg).finish()
75
- await UniMessage.image(raw=msg).finish()
88
+ if isinstance(msg, bytes):
89
+ await UniMessage.image(raw=msg).finish()
76
90
  else:
77
- await UniMessage.text("没有这个服呢").send()
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()
78
116
 
79
117
 
80
118
  @l4_connect.handle()
@@ -84,7 +122,19 @@ async def _(args: Message = CommandArg()):
84
122
  await UniMessage.text(await get_ip_server(ip)).finish()
85
123
 
86
124
 
125
+ # anne部分
126
+ if config.l4_anne:
127
+ logger.info("加载anne功能")
128
+ from .l4_anne import * # noqa: F403
129
+
130
+
87
131
  @l4_reload.handle()
88
- async def _():
89
- reload_ip()
90
- logger.success("重载ip完成")
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())
@@ -5,6 +5,7 @@ from pydantic import BaseModel
5
5
 
6
6
  DATAPATH = Path(__file__).parent.joinpath("data")
7
7
  DATAOUT = Path("data/L4D2")
8
+ print(DATAOUT.absolute())
8
9
  server_all_path = DATAOUT / "l4d2"
9
10
  server_all_path.mkdir(parents=True, exist_ok=True)
10
11
 
@@ -12,7 +13,7 @@ ICONPATH = DATAPATH / "icon"
12
13
 
13
14
 
14
15
  class ConfigModel(BaseModel):
15
- l4_anne: bool = False
16
+ l4_anne: bool = True
16
17
  """是否启用anne电信服相关功能"""
17
18
  l4_enable: bool = True
18
19
  """是否全局启用求生功能"""
@@ -25,6 +26,10 @@ class ConfigModel(BaseModel):
25
26
  l4_players: int = 4
26
27
  """查询总图的时候展示的用户数量"""
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
28
33
 
29
34
 
30
35
  config = get_plugin_config(ConfigModel)
@@ -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
+ """
@@ -3,59 +3,96 @@
3
3
  "desc": "无需任何权限",
4
4
  "data": [
5
5
  {
6
- "name": "l4全服",
7
- "desc": "返回可以查询的所有服务器组",
8
- "eg": "l4全服",
6
+ "name": "(组)",
7
+ "desc": "返回一个组的服务器信息",
8
+ "eg": "/云",
9
9
  "need_ck": false,
10
10
  "need_sk": false,
11
11
  "need_admin": false
12
12
  },
13
13
  {
14
- "name": "(组指令)",
15
- "desc": "返回一个组的服务器信息",
16
- "eg": "",
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查找 云 爱丽数码",
17
25
  "need_ck": false,
18
26
  "need_sk": false,
19
27
  "need_admin": false
20
28
  },
21
29
  {
22
- "name": "雀魂切换uid",
23
- "desc": "切换你的雀魂UID",
24
- "eg": "雀魂切换uid123456",
30
+ "name": "l4全服",
31
+ "desc": "返回可以查询的所有服务器组(未完成)",
32
+ "eg": "/l4全服",
25
33
  "need_ck": false,
26
34
  "need_sk": false,
27
35
  "need_admin": false
28
36
  }
29
37
  ]
30
38
  },
31
- "查询服务": {
32
- "desc": "查询一些基本信息, 需要在金之间拥有一定场次的对局",
39
+ "电信服anne服务": {
40
+ "desc": "电信anne服相关服务",
33
41
  "data": [
34
42
  {
35
- "name": "雀魂搜索",
36
- "desc": "搜索雀魂玩家",
37
- "eg": "雀魂搜索Wuyi",
38
- "need_ck": true,
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,
39
55
  "need_sk": false,
40
56
  "need_admin": false
41
57
  },
42
58
  {
43
- "name": "雀魂查询",
44
- "desc": "查询雀魂数据一览",
45
- "eg": "雀魂查询1148850",
46
- "need_ck": true,
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,
47
71
  "need_sk": false,
48
72
  "need_admin": false
49
73
  }
50
74
  ]
51
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
+ },
52
89
  "其他服务": {
53
90
  "desc": "一些杂项服务",
54
91
  "data": [
55
92
  {
56
- "name": "雀魂帮助",
57
- "desc": "呼出该帮助界面",
58
- "eg": "雀魂帮助",
93
+ "name": "connect",
94
+ "desc": "直接发送求生链接返回信息",
95
+ "eg": "connect 127.0.0.1:27015",
59
96
  "need_ck": false,
60
97
  "need_sk": false,
61
98
  "need_admin": false
@@ -10,7 +10,7 @@ from ..l4_image.convert import core_font
10
10
  from ..l4_image.model import PluginHelp
11
11
  from .draw import get_help
12
12
 
13
- __version__ = "1.0.0a1"
13
+ __version__ = "1.0.0a2"
14
14
  TEXT_PATH = Path(__file__).parent / "texture2d"
15
15
  HELP_DATA = Path(__file__).parent / "Help.json"
16
16
 
@@ -39,7 +39,7 @@ async def get_l4d2_core_help() -> Union[bytes, str]:
39
39
  bg_out.paste(bg_new, None, bg_new)
40
40
 
41
41
  return await get_help(
42
- "CS2UID",
42
+ "L4插件",
43
43
  f"版本号:{__version__}",
44
44
  help_data,
45
45
  bg_out,
@@ -1,15 +1,15 @@
1
- from typing import List
1
+ from typing import List # noqa:
2
2
 
3
3
  from ..utils.api.models import OutServer
4
4
  from .html_img import server_ip_pic
5
5
 
6
6
 
7
- async def msg_to_image(server_dict: List[OutServer], mode="html"):
7
+ async def msg_to_image(server_dict: List[OutServer], mode_: str = "html"):
8
8
  """信息构造图片"""
9
- if mode == "html":
9
+ if mode_ == "html":
10
10
  """用浏览器作图"""
11
11
  return await server_ip_pic(server_dict)
12
- if mode == "pil":
12
+ if mode_ == "pil":
13
13
  """用pil作图"""
14
14
  return None
15
15
  """返回文字"""
@@ -0,0 +1,17 @@
1
+ from pathlib import Path
2
+
3
+ from nonebot_plugin_l4d2_server.utils.api.models import AnnePlayer2
4
+ from PIL import Image, ImageFont
5
+
6
+ from ..config import config
7
+
8
+ font = ImageFont.truetype(config.l4_font)
9
+
10
+ anne_path = Path(__file__).parent / "img" / "anne"
11
+
12
+
13
+ async def anne_player_info(msg: AnnePlayer2):
14
+ back_img = Image.open(anne_path / "back1.jpg")
15
+ base_img = Image.new("RGBA", (back_img.size), (255, 255, 255, 50))
16
+ back_img.paste(base_img, (0, 0), base_img)
17
+ return msg
@@ -169,7 +169,7 @@ async def text2pic(text: str, max_size: int = 800, font_size: int = 24):
169
169
  core_font(font_size),
170
170
  "black",
171
171
  max_size - 80,
172
- True,
172
+ True, # noqa: FBT003
173
173
  )
174
174
  img = img.crop((0, 0, max_size, int(y + 80)))
175
175
  return await convert_img(img)
@@ -33,7 +33,7 @@ async def download_url(url: str) -> bytes:
33
33
  async def download_head(user_id: str) -> bytes:
34
34
  url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=640"
35
35
  data = await download_url(url)
36
- if hashlib.md5(data).hexdigest() == "acef72340ac0e914090bd35799f5594e":
36
+ if hashlib.md5(data).hexdigest() == "acef72340ac0e914090bd35799f5594e": # noqa: S324
37
37
  url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=100"
38
38
  data = await download_url(url)
39
39
  return data
@@ -50,7 +50,7 @@ def square_to_circle(im: ImageS):
50
50
  return im
51
51
 
52
52
 
53
- async def get_head_by_user_id_and_save(user_id):
53
+ async def get_head_by_user_id_and_save(user_id: str):
54
54
  """qq转头像"""
55
55
  user_id = str(user_id)
56
56
 
@@ -61,7 +61,7 @@ async def get_head_by_user_id_and_save(user_id):
61
61
  os.listdir(default_header_path),
62
62
  )
63
63
  default_head = default_head_path / random.choice(os.listdir(default_head_path))
64
- ## im头像 im2头像框 im3合成
64
+ # im头像 im2头像框 im3合成
65
65
  if user_head_path.exists():
66
66
  logger.info("使用本地头像")
67
67
  im = Image.open(user_head_path).resize((280, 280)).convert("RGBA")
@@ -86,8 +86,8 @@ async def get_head_by_user_id_and_save(user_id):
86
86
  return None
87
87
  im2 = Image.open(default_head).resize((450, 450)).convert("RGBA")
88
88
  im3 = Image.new("RGBA", im2.size, (255, 255, 255, 0))
89
- r, g, b, a1 = im.split()
90
- r, g, b, a2 = im2.split()
89
+ _, _, _, a1 = im.split()
90
+ _, _, _, a2 = im2.split()
91
91
  im = square_to_circle(im)
92
92
  im3.paste(im, (75, 75), mask=a1)
93
93
  im3.paste(im2, mask=a2)