nonebot-plugin-railwaytools 2.2.6__tar.gz → 2.2.7__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_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/PKG-INFO +48 -32
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/README.md +47 -31
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/__init__.py +4 -2
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/api.py +1 -0
- nonebot_plugin_railwaytools-2.2.7/nonebot_plugin_railwaytools/locomotive_info.py +104 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/picture_function.py +33 -28
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools.egg-info/PKG-INFO +48 -32
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools.egg-info/SOURCES.txt +1 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/pyproject.toml +1 -1
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/LICENSE +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/emu_function.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/route_info.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/station_info.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/station_screen.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/train_info.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools/utils.py +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools.egg-info/requires.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/nonebot_plugin_railwaytools.egg-info/top_level.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.6 → nonebot_plugin_railwaytools-2.2.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-railwaytools
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: 这是一个火车迷也许觉得很好用的铁路机器人工具箱
|
|
5
5
|
Author-email: leaf2006 <leafdeveloper@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -75,9 +75,12 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
75
75
|
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
76
76
|
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
77
77
|
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
78
|
+
| `/机车信息` [机车车号] | 通过车号查询机车/动车组基本信息(例如:`/机车信息` HXD1D-1898)|
|
|
78
79
|
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` HXD1D-1898)|
|
|
79
80
|
| `/help` | 查看帮助信息 |
|
|
80
81
|
|
|
82
|
+
注⚠️:`/下关站` 功能将于v2.2.8废弃,建议使用`/机车信息`
|
|
83
|
+
|
|
81
84
|
#### 功能详细介绍
|
|
82
85
|
|
|
83
86
|
- 通过车次查询担当的动车组车组号:`/车号` [动车组车次] 或 `/ch` [动车组车次](例如:/车号 D3211)
|
|
@@ -312,49 +315,60 @@ example:
|
|
|
312
315
|
|
|
313
316
|
由于cnrail的更新,现在还支持查询地铁车站。建议在查询地铁站时,在地铁站名后加“地铁站”二字,方便搜索
|
|
314
317
|
|
|
315
|
-
-
|
|
318
|
+
- 通过车号查询机车/动车组基本信息:`/机车信息` [机车车号] 或 `/jccx` [机车车号] (例如:/机车信息 HXD1D-1898)
|
|
319
|
+
|
|
320
|
+
新版的功能采用两个数据源:轨上名录(leaf2006/CR-Locomotive-Allocation)与下关站(xiaguanzhan.com),查询时会优先使用轨上名录的数据,结果返回速度提升显著
|
|
321
|
+
|
|
316
322
|
```
|
|
317
323
|
example:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
🤵:/机车信息 HXD1D-1898
|
|
325
|
+
🤖:
|
|
326
|
+
【HXD1D-1898】共检索到1个结果:
|
|
327
|
+
------------------------------
|
|
328
|
+
【HXD1D-1898在下关站中的配图】
|
|
329
|
+
车号:HXD1D-1898
|
|
330
|
+
配属:上局沪段
|
|
331
|
+
生产厂家:中车株洲机车
|
|
332
|
+
拍摄者:PVG的拂晓ALPHA
|
|
333
|
+
拍摄日期:202107
|
|
334
|
+
------------------------------
|
|
335
|
+
数据来源:轨上名录 CR-Locomotive-Allocation
|
|
336
|
+
项目地址:github.com/leaf2006/CR-Locomotive-Allocation
|
|
328
337
|
```
|
|
329
338
|
|
|
339
|
+
如轨上名录上没有结果(通常因为车型过老),则自动使用下关站数据源进行查询
|
|
340
|
+
|
|
341
|
+
- ~~通过车号查询下关站收录的机车户口照:`/下关站` [机车车号] 或 `/xgz` [机车车号] (例如:/下关站 HXD1D-1898)~~(⚠️该功能将在v2.2.8废弃,建议您使用`/机车信息`功能,体验更佳)
|
|
342
|
+
|
|
343
|
+
|
|
330
344
|
- 帮助:`/帮助` 或 `/help`
|
|
331
345
|
```
|
|
332
346
|
example:
|
|
333
347
|
🤵:/help
|
|
334
348
|
🤖:
|
|
335
|
-
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
336
|
-
|
|
349
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
350
|
+
|
|
337
351
|
----------使用方法----------
|
|
338
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
339
|
-
|
|
340
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
341
|
-
|
|
352
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
353
|
+
|
|
354
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
355
|
+
|
|
342
356
|
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
343
357
|
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
344
|
-
|
|
358
|
+
|
|
345
359
|
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
346
|
-
|
|
347
|
-
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
348
|
-
|
|
349
|
-
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
350
|
-
|
|
351
|
-
⑦
|
|
352
|
-
|
|
353
|
-
⑧ 帮助:/帮助 或 /help
|
|
354
|
-
|
|
355
|
-
更多功能正在开发中,尽情期待!
|
|
356
|
-
------------------------------
|
|
357
|
-
|
|
360
|
+
|
|
361
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
362
|
+
|
|
363
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
364
|
+
|
|
365
|
+
⑦ 通过车号查询机车/动车组基本信息:/机车信息 或 /jcxx (例如:/机车信息 HXD1D-1898)
|
|
366
|
+
|
|
367
|
+
⑧ 帮助:/帮助 或 /help
|
|
368
|
+
|
|
369
|
+
更多功能正在开发中,尽情期待!
|
|
370
|
+
------------------------------
|
|
371
|
+
|
|
358
372
|
Powered by Nonebot2
|
|
359
373
|
Copyright © Leaf developer 2023-2026
|
|
360
374
|
```
|
|
@@ -385,7 +399,9 @@ Copyright © Leaf developer 2023-2026
|
|
|
385
399
|
|
|
386
400
|
## 数据来源
|
|
387
401
|
- 动车组交路数据来源于:https://rail.re
|
|
388
|
-
-
|
|
402
|
+
- 机车/动车组信息来源于:
|
|
403
|
+
- 轨上名录(CR-Locomotive-Allocation):https://github.com/leaf2006/CR-Locomotive-Allocation
|
|
404
|
+
- 下关站:http://www.xiaguanzhan.com/
|
|
389
405
|
- 列车查询数据来源于12306
|
|
390
406
|
- 车站大屏数据来源于第三方API
|
|
391
407
|
- 车站、线路基本信息来源于:http://cnrail.geogv.org/zhcn/
|
|
@@ -57,9 +57,12 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
57
57
|
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
58
58
|
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
59
59
|
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
60
|
+
| `/机车信息` [机车车号] | 通过车号查询机车/动车组基本信息(例如:`/机车信息` HXD1D-1898)|
|
|
60
61
|
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` HXD1D-1898)|
|
|
61
62
|
| `/help` | 查看帮助信息 |
|
|
62
63
|
|
|
64
|
+
注⚠️:`/下关站` 功能将于v2.2.8废弃,建议使用`/机车信息`
|
|
65
|
+
|
|
63
66
|
#### 功能详细介绍
|
|
64
67
|
|
|
65
68
|
- 通过车次查询担当的动车组车组号:`/车号` [动车组车次] 或 `/ch` [动车组车次](例如:/车号 D3211)
|
|
@@ -294,49 +297,60 @@ example:
|
|
|
294
297
|
|
|
295
298
|
由于cnrail的更新,现在还支持查询地铁车站。建议在查询地铁站时,在地铁站名后加“地铁站”二字,方便搜索
|
|
296
299
|
|
|
297
|
-
-
|
|
300
|
+
- 通过车号查询机车/动车组基本信息:`/机车信息` [机车车号] 或 `/jccx` [机车车号] (例如:/机车信息 HXD1D-1898)
|
|
301
|
+
|
|
302
|
+
新版的功能采用两个数据源:轨上名录(leaf2006/CR-Locomotive-Allocation)与下关站(xiaguanzhan.com),查询时会优先使用轨上名录的数据,结果返回速度提升显著
|
|
303
|
+
|
|
298
304
|
```
|
|
299
305
|
example:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
🤵:/机车信息 HXD1D-1898
|
|
307
|
+
🤖:
|
|
308
|
+
【HXD1D-1898】共检索到1个结果:
|
|
309
|
+
------------------------------
|
|
310
|
+
【HXD1D-1898在下关站中的配图】
|
|
311
|
+
车号:HXD1D-1898
|
|
312
|
+
配属:上局沪段
|
|
313
|
+
生产厂家:中车株洲机车
|
|
314
|
+
拍摄者:PVG的拂晓ALPHA
|
|
315
|
+
拍摄日期:202107
|
|
316
|
+
------------------------------
|
|
317
|
+
数据来源:轨上名录 CR-Locomotive-Allocation
|
|
318
|
+
项目地址:github.com/leaf2006/CR-Locomotive-Allocation
|
|
310
319
|
```
|
|
311
320
|
|
|
321
|
+
如轨上名录上没有结果(通常因为车型过老),则自动使用下关站数据源进行查询
|
|
322
|
+
|
|
323
|
+
- ~~通过车号查询下关站收录的机车户口照:`/下关站` [机车车号] 或 `/xgz` [机车车号] (例如:/下关站 HXD1D-1898)~~(⚠️该功能将在v2.2.8废弃,建议您使用`/机车信息`功能,体验更佳)
|
|
324
|
+
|
|
325
|
+
|
|
312
326
|
- 帮助:`/帮助` 或 `/help`
|
|
313
327
|
```
|
|
314
328
|
example:
|
|
315
329
|
🤵:/help
|
|
316
330
|
🤖:
|
|
317
|
-
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
318
|
-
|
|
331
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
332
|
+
|
|
319
333
|
----------使用方法----------
|
|
320
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
321
|
-
|
|
322
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
323
|
-
|
|
334
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
335
|
+
|
|
336
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
337
|
+
|
|
324
338
|
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
325
339
|
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
326
|
-
|
|
340
|
+
|
|
327
341
|
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
328
|
-
|
|
329
|
-
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
330
|
-
|
|
331
|
-
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
332
|
-
|
|
333
|
-
⑦
|
|
334
|
-
|
|
335
|
-
⑧ 帮助:/帮助 或 /help
|
|
336
|
-
|
|
337
|
-
更多功能正在开发中,尽情期待!
|
|
338
|
-
------------------------------
|
|
339
|
-
|
|
342
|
+
|
|
343
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
344
|
+
|
|
345
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
346
|
+
|
|
347
|
+
⑦ 通过车号查询机车/动车组基本信息:/机车信息 或 /jcxx (例如:/机车信息 HXD1D-1898)
|
|
348
|
+
|
|
349
|
+
⑧ 帮助:/帮助 或 /help
|
|
350
|
+
|
|
351
|
+
更多功能正在开发中,尽情期待!
|
|
352
|
+
------------------------------
|
|
353
|
+
|
|
340
354
|
Powered by Nonebot2
|
|
341
355
|
Copyright © Leaf developer 2023-2026
|
|
342
356
|
```
|
|
@@ -367,7 +381,9 @@ Copyright © Leaf developer 2023-2026
|
|
|
367
381
|
|
|
368
382
|
## 数据来源
|
|
369
383
|
- 动车组交路数据来源于:https://rail.re
|
|
370
|
-
-
|
|
384
|
+
- 机车/动车组信息来源于:
|
|
385
|
+
- 轨上名录(CR-Locomotive-Allocation):https://github.com/leaf2006/CR-Locomotive-Allocation
|
|
386
|
+
- 下关站:http://www.xiaguanzhan.com/
|
|
371
387
|
- 列车查询数据来源于12306
|
|
372
388
|
- 车站大屏数据来源于第三方API
|
|
373
389
|
- 车站、线路基本信息来源于:http://cnrail.geogv.org/zhcn/
|
|
@@ -13,6 +13,7 @@ from .train_info import handle_train_info
|
|
|
13
13
|
from .station_screen import handle_station_screen
|
|
14
14
|
from .route_info import handle_route_info
|
|
15
15
|
from .station_info import handle_station_info
|
|
16
|
+
from .locomotive_info import handle_locomotive_info
|
|
16
17
|
|
|
17
18
|
# 插件配置页
|
|
18
19
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -26,6 +27,7 @@ __plugin_meta__ = PluginMetadata(
|
|
|
26
27
|
/线路 [线路名称] - 查询某条铁路基本信息
|
|
27
28
|
/车站 [车站名称] - 查询某车站基本信息
|
|
28
29
|
/下关站 [机车车号] - 通过车号查看下关站机车户口照
|
|
30
|
+
/机车信息 [机车车号] - 通过车号查询机车/动车组基本信息
|
|
29
31
|
/help - 查看帮助信息
|
|
30
32
|
""",
|
|
31
33
|
|
|
@@ -53,13 +55,13 @@ async def handle_information_helper():
|
|
|
53
55
|
"④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)\n \n"
|
|
54
56
|
"⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路) \n \n"
|
|
55
57
|
"⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海) \n \n"
|
|
56
|
-
"⑦
|
|
58
|
+
"⑦ 通过车号查询机车/动车组基本信息:/机车信息 或 /jcxx (例如:/机车信息 HXD1D-1898) \n \n",
|
|
57
59
|
"⑧ 帮助:/帮助 或 /help \n \n",
|
|
58
60
|
"更多功能正在开发中,尽情期待! \n",
|
|
59
61
|
"------------------------------ \n \n",
|
|
60
62
|
"Powered by Nonebot2\n",
|
|
61
63
|
"Copyright © Leaf developer 2023-2026"
|
|
62
64
|
|
|
63
|
-
])
|
|
65
|
+
])
|
|
64
66
|
|
|
65
67
|
await information_helper.finish(information_Helper_message)
|
|
@@ -8,6 +8,7 @@ class API:
|
|
|
8
8
|
api_xiaguanzhan = "http://www.xiaguanzhan.com/soso.asp"
|
|
9
9
|
api_station_screen = "https://apis.uctb.cn/api/12306?"
|
|
10
10
|
api_cnrail_geogv = "http://cnrail.geogv.org/api/"
|
|
11
|
+
api_cr_locomotive_allocation = "https://cdn.jsdelivr.net/gh/leaf2006/CR-Locomotive-Allocation@main/data/raw_result.json"
|
|
11
12
|
|
|
12
13
|
headers = { # 加个请求头,保险一点
|
|
13
14
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Copyright © Leaf developer 2023-2026
|
|
2
|
+
# 本文件负责实现“查询列车与动车组信息”功能,由原“/下关站”演化而来
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
import json
|
|
6
|
+
from httpx import AsyncClient
|
|
7
|
+
from nonebot import on_command
|
|
8
|
+
from nonebot.adapters import Event
|
|
9
|
+
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
|
10
|
+
from nonebot.params import CommandArg
|
|
11
|
+
from nonebot.rule import to_me
|
|
12
|
+
from .utils import utils
|
|
13
|
+
from .api import API
|
|
14
|
+
|
|
15
|
+
locomotive_info = on_command("机车信息",aliases={"jcxx"},priority=5,block=True)
|
|
16
|
+
|
|
17
|
+
# 查询思路:根据优先级,逐级查询,如果第一级没有,就去第二级查
|
|
18
|
+
# leaf2006/CR-Locomotive-Allocation存档 -> 下关站
|
|
19
|
+
@locomotive_info.handle() # 查询车型信息
|
|
20
|
+
async def handle_locomotive_info(event:Event, args: Message = CommandArg()):
|
|
21
|
+
raw_message = str(event.get_message()).strip()
|
|
22
|
+
command_part = utils.get_command_part(raw_message)
|
|
23
|
+
valid_commands = ['机车信息','jcxx']
|
|
24
|
+
if command_part not in valid_commands:
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
if input_train_id := args.extract_plain_text():
|
|
28
|
+
await locomotive_info.send("正在加载,时间可能略久...")
|
|
29
|
+
|
|
30
|
+
hr_line = "------------------------------\n"
|
|
31
|
+
# leaf2006/CR-Locomotive-Allocation 查询
|
|
32
|
+
async with httpx.AsyncClient(headers=API.headers, timeout=30.0) as client:
|
|
33
|
+
resp = await client.get(API.api_cr_locomotive_allocation)
|
|
34
|
+
|
|
35
|
+
resp_data = json.loads(resp.text)
|
|
36
|
+
match_raw_result = []
|
|
37
|
+
for model_type, trains in resp_data.items():
|
|
38
|
+
if isinstance(trains, list):
|
|
39
|
+
for train in trains:
|
|
40
|
+
if isinstance(train, dict) and train.get("id") == input_train_id.upper():
|
|
41
|
+
match_raw_result.append(train)
|
|
42
|
+
result = ""
|
|
43
|
+
if match_raw_result:
|
|
44
|
+
for train in match_raw_result:
|
|
45
|
+
train_id = "车号:" + train.get('id') + "\n" if train.get('id') else ""
|
|
46
|
+
allocation = "配属:" + train.get('allocation') + "\n" if train.get('allocation') else ""
|
|
47
|
+
manufacturer = "生产厂家:" + train.get('manufacturer') + "\n" if train.get('manufacturer') else ""
|
|
48
|
+
pro_id = train.get('pro_id', '')
|
|
49
|
+
photo_author = "拍摄者:" + train.get('photo_author') + "\n" if train.get('photo_author') else ""
|
|
50
|
+
photo_date = "拍摄日期:" + train.get('photo_date') + "\n" if train.get('photo_date') else ""
|
|
51
|
+
photo_url = train.get('photo_url','')
|
|
52
|
+
if photo_url:
|
|
53
|
+
photo = MessageSegment.image(photo_url)
|
|
54
|
+
else:
|
|
55
|
+
photo = ""
|
|
56
|
+
|
|
57
|
+
result += photo + train_id + allocation + manufacturer + photo_author + photo_date + hr_line
|
|
58
|
+
attribution = "数据来源:轨上名录 CR-Locomotive-Allocation\n项目地址:github.com/leaf2006/CR-Locomotive-Allocation"
|
|
59
|
+
locomotive_output = "【" + input_train_id.upper() + "】共检索到" + str(len(match_raw_result)) + "个结果:\n" + hr_line + result + attribution
|
|
60
|
+
await locomotive_info.finish(locomotive_output)
|
|
61
|
+
else:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
# www.xiaguanzhan.com
|
|
65
|
+
try:
|
|
66
|
+
async with httpx.AsyncClient(headers=API.headers, timeout=30.0) as client:
|
|
67
|
+
data = {
|
|
68
|
+
"keyword": input_train_id.lower()
|
|
69
|
+
}
|
|
70
|
+
resp = await client.post(API.api_xiaguanzhan, data=data)
|
|
71
|
+
resp.encoding = "gb2312"
|
|
72
|
+
|
|
73
|
+
# 获取基本信息
|
|
74
|
+
first_match = utils.xiaguanzhan_first_match
|
|
75
|
+
title = first_match(r'<h1><span class="blue"><a href="ProView\.asp\?ProId=[^"]*" title="[^"]*" target="_blank">(.*?)</a></span></h1>', resp.text)
|
|
76
|
+
if title == None:
|
|
77
|
+
await locomotive_info.finish(f"暂无{input_train_id.upper()}的信息!")
|
|
78
|
+
manufacturer = first_match(r'生产厂商:(.*?)<BR>', resp.text) or "暂无数据"
|
|
79
|
+
shoot_date = first_match(r'拍摄日期:(.*?)<BR>', resp.text) or "暂无数据"
|
|
80
|
+
shoot_author = first_match(r'拍摄作者:(.*?)</FONT>', resp.text) or "暂无数据"
|
|
81
|
+
photo_url = first_match(r'下载地址:<a href="(.*?)" target="_blank">', resp.text) or "暂无数据"
|
|
82
|
+
locomotive_allocation = first_match(r'拍摄配属:(.*?)<BR>', resp.text) or "暂无数据"
|
|
83
|
+
|
|
84
|
+
title_separate = title.split(' ')
|
|
85
|
+
locomotive_no = title_separate[1]
|
|
86
|
+
|
|
87
|
+
xiaguanzhan_photo_output = Message ([
|
|
88
|
+
hr_line,
|
|
89
|
+
MessageSegment.image(photo_url),
|
|
90
|
+
f"车号:{locomotive_no}\n",
|
|
91
|
+
f"配属:{locomotive_allocation}\n",
|
|
92
|
+
f"生产厂家:{manufacturer}\n",
|
|
93
|
+
f"拍摄者:{shoot_author}\n",
|
|
94
|
+
f"拍摄日期:{shoot_date}\n",
|
|
95
|
+
hr_line,
|
|
96
|
+
"数据来源:下关站-铁路摄影馆",
|
|
97
|
+
])
|
|
98
|
+
await locomotive_info.finish(xiaguanzhan_photo_output)
|
|
99
|
+
|
|
100
|
+
except httpx.ReadTimeout:
|
|
101
|
+
await locomotive_info.finish("暂时无法访问下关站,请稍后再试!")
|
|
102
|
+
|
|
103
|
+
else:
|
|
104
|
+
await locomotive_info.finish("请输入正确的车号!如:CRH2A-2001")
|
|
@@ -24,36 +24,41 @@ async def handle_xiaguanzhan_photo(event:Event, args: Message = CommandArg()): #
|
|
|
24
24
|
|
|
25
25
|
if number := args.extract_plain_text():
|
|
26
26
|
await xiaguanzhan_photo.send("正在加载图片,时间可能略久...")
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
try:
|
|
28
|
+
async with httpx.AsyncClient(headers=API.headers, timeout=30.0) as client:
|
|
29
|
+
data = {
|
|
30
|
+
"keyword": number.lower() # Fix bug:小补丁
|
|
31
|
+
}
|
|
32
|
+
xiaguanzhan_resp = await client.post(API.api_xiaguanzhan, data=data)
|
|
33
|
+
xiaguanzhan_resp.encoding = "gb2312"
|
|
34
|
+
# 获取基本信息
|
|
35
|
+
first_match = utils.xiaguanzhan_first_match
|
|
36
|
+
title = first_match(r'<h1><span class="blue"><a href="ProView\.asp\?ProId=[^"]*" title="[^"]*" target="_blank">(.*?)</a></span></h1>', xiaguanzhan_resp.text)
|
|
37
|
+
if title == None:
|
|
38
|
+
await xiaguanzhan_photo.finish(f"暂无{number}的信息")
|
|
39
|
+
manufacturer = first_match(r'生产厂商:(.*?)<BR>', xiaguanzhan_resp.text)
|
|
40
|
+
shoot_date = first_match(r'拍摄日期:(.*?)<BR>', xiaguanzhan_resp.text)
|
|
41
|
+
shoot_author = first_match(r'拍摄作者:(.*?)</FONT>', xiaguanzhan_resp.text)
|
|
42
|
+
photo_url = first_match(r'下载地址:<a href="(.*?)" target="_blank">', xiaguanzhan_resp.text)
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
title_separate = title.split(' ')
|
|
45
|
+
locomotive_no = title_separate[1]
|
|
46
|
+
locomotive_allocation = title_separate[2]
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
xiaguanzhan_photo_output = Message ([
|
|
49
|
+
MessageSegment.image(photo_url),
|
|
50
|
+
f"【{locomotive_no}】\n",
|
|
51
|
+
f"配属:{locomotive_allocation}\n",
|
|
52
|
+
f"生产厂商:{manufacturer}\n",
|
|
53
|
+
f"拍摄日期:{shoot_date}\n",
|
|
54
|
+
f"拍摄作者:{shoot_author}\n\n",
|
|
55
|
+
"数据来源:下关站-铁路摄影馆\n\n",
|
|
56
|
+
"⚠️该功能将在v2.2.8废弃,建议您使用 /机车信息 功能,体验更佳⚠️"
|
|
57
|
+
])
|
|
58
|
+
await xiaguanzhan_photo.finish(xiaguanzhan_photo_output)
|
|
59
|
+
|
|
60
|
+
except httpx.ReadTimeout:
|
|
61
|
+
await xiaguanzhan_photo.finish("无法访问下关站,请稍后再试!")
|
|
57
62
|
|
|
58
63
|
else:
|
|
59
64
|
await xiaguanzhan_photo.finish("请输入正确的车号!,如:HXD1D-1898")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-railwaytools
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: 这是一个火车迷也许觉得很好用的铁路机器人工具箱
|
|
5
5
|
Author-email: leaf2006 <leafdeveloper@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -75,9 +75,12 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
75
75
|
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
76
76
|
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
77
77
|
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
78
|
+
| `/机车信息` [机车车号] | 通过车号查询机车/动车组基本信息(例如:`/机车信息` HXD1D-1898)|
|
|
78
79
|
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` HXD1D-1898)|
|
|
79
80
|
| `/help` | 查看帮助信息 |
|
|
80
81
|
|
|
82
|
+
注⚠️:`/下关站` 功能将于v2.2.8废弃,建议使用`/机车信息`
|
|
83
|
+
|
|
81
84
|
#### 功能详细介绍
|
|
82
85
|
|
|
83
86
|
- 通过车次查询担当的动车组车组号:`/车号` [动车组车次] 或 `/ch` [动车组车次](例如:/车号 D3211)
|
|
@@ -312,49 +315,60 @@ example:
|
|
|
312
315
|
|
|
313
316
|
由于cnrail的更新,现在还支持查询地铁车站。建议在查询地铁站时,在地铁站名后加“地铁站”二字,方便搜索
|
|
314
317
|
|
|
315
|
-
-
|
|
318
|
+
- 通过车号查询机车/动车组基本信息:`/机车信息` [机车车号] 或 `/jccx` [机车车号] (例如:/机车信息 HXD1D-1898)
|
|
319
|
+
|
|
320
|
+
新版的功能采用两个数据源:轨上名录(leaf2006/CR-Locomotive-Allocation)与下关站(xiaguanzhan.com),查询时会优先使用轨上名录的数据,结果返回速度提升显著
|
|
321
|
+
|
|
316
322
|
```
|
|
317
323
|
example:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
🤵:/机车信息 HXD1D-1898
|
|
325
|
+
🤖:
|
|
326
|
+
【HXD1D-1898】共检索到1个结果:
|
|
327
|
+
------------------------------
|
|
328
|
+
【HXD1D-1898在下关站中的配图】
|
|
329
|
+
车号:HXD1D-1898
|
|
330
|
+
配属:上局沪段
|
|
331
|
+
生产厂家:中车株洲机车
|
|
332
|
+
拍摄者:PVG的拂晓ALPHA
|
|
333
|
+
拍摄日期:202107
|
|
334
|
+
------------------------------
|
|
335
|
+
数据来源:轨上名录 CR-Locomotive-Allocation
|
|
336
|
+
项目地址:github.com/leaf2006/CR-Locomotive-Allocation
|
|
328
337
|
```
|
|
329
338
|
|
|
339
|
+
如轨上名录上没有结果(通常因为车型过老),则自动使用下关站数据源进行查询
|
|
340
|
+
|
|
341
|
+
- ~~通过车号查询下关站收录的机车户口照:`/下关站` [机车车号] 或 `/xgz` [机车车号] (例如:/下关站 HXD1D-1898)~~(⚠️该功能将在v2.2.8废弃,建议您使用`/机车信息`功能,体验更佳)
|
|
342
|
+
|
|
343
|
+
|
|
330
344
|
- 帮助:`/帮助` 或 `/help`
|
|
331
345
|
```
|
|
332
346
|
example:
|
|
333
347
|
🤵:/help
|
|
334
348
|
🤖:
|
|
335
|
-
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
336
|
-
|
|
349
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
350
|
+
|
|
337
351
|
----------使用方法----------
|
|
338
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
339
|
-
|
|
340
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
341
|
-
|
|
352
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
353
|
+
|
|
354
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
355
|
+
|
|
342
356
|
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
343
357
|
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
344
|
-
|
|
358
|
+
|
|
345
359
|
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
346
|
-
|
|
347
|
-
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
348
|
-
|
|
349
|
-
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
350
|
-
|
|
351
|
-
⑦
|
|
352
|
-
|
|
353
|
-
⑧ 帮助:/帮助 或 /help
|
|
354
|
-
|
|
355
|
-
更多功能正在开发中,尽情期待!
|
|
356
|
-
------------------------------
|
|
357
|
-
|
|
360
|
+
|
|
361
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
362
|
+
|
|
363
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
364
|
+
|
|
365
|
+
⑦ 通过车号查询机车/动车组基本信息:/机车信息 或 /jcxx (例如:/机车信息 HXD1D-1898)
|
|
366
|
+
|
|
367
|
+
⑧ 帮助:/帮助 或 /help
|
|
368
|
+
|
|
369
|
+
更多功能正在开发中,尽情期待!
|
|
370
|
+
------------------------------
|
|
371
|
+
|
|
358
372
|
Powered by Nonebot2
|
|
359
373
|
Copyright © Leaf developer 2023-2026
|
|
360
374
|
```
|
|
@@ -385,7 +399,9 @@ Copyright © Leaf developer 2023-2026
|
|
|
385
399
|
|
|
386
400
|
## 数据来源
|
|
387
401
|
- 动车组交路数据来源于:https://rail.re
|
|
388
|
-
-
|
|
402
|
+
- 机车/动车组信息来源于:
|
|
403
|
+
- 轨上名录(CR-Locomotive-Allocation):https://github.com/leaf2006/CR-Locomotive-Allocation
|
|
404
|
+
- 下关站:http://www.xiaguanzhan.com/
|
|
389
405
|
- 列车查询数据来源于12306
|
|
390
406
|
- 车站大屏数据来源于第三方API
|
|
391
407
|
- 车站、线路基本信息来源于:http://cnrail.geogv.org/zhcn/
|
|
@@ -4,6 +4,7 @@ pyproject.toml
|
|
|
4
4
|
nonebot_plugin_railwaytools/__init__.py
|
|
5
5
|
nonebot_plugin_railwaytools/api.py
|
|
6
6
|
nonebot_plugin_railwaytools/emu_function.py
|
|
7
|
+
nonebot_plugin_railwaytools/locomotive_info.py
|
|
7
8
|
nonebot_plugin_railwaytools/picture_function.py
|
|
8
9
|
nonebot_plugin_railwaytools/route_info.py
|
|
9
10
|
nonebot_plugin_railwaytools/station_info.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|