nonebot-plugin-railwaytools 2.2.0__tar.gz → 2.2.2__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.0 → nonebot_plugin_railwaytools-2.2.2}/PKG-INFO +82 -27
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/README.md +81 -26
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/__init__.py +3 -2
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/emu_function.py +1 -1
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/route_info.py +21 -3
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/station_info.py +3 -1
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/station_screen.py +1 -1
- nonebot_plugin_railwaytools-2.2.2/nonebot_plugin_railwaytools/train_info.py +213 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/utils.py +0 -1
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools.egg-info/PKG-INFO +82 -27
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/pyproject.toml +1 -1
- nonebot_plugin_railwaytools-2.2.0/nonebot_plugin_railwaytools/train_info.py +0 -111
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/LICENSE +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/api.py +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools/picture_function.py +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools.egg-info/SOURCES.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools.egg-info/requires.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/nonebot_plugin_railwaytools.egg-info/top_level.txt +0 -0
- {nonebot_plugin_railwaytools-2.2.0 → nonebot_plugin_railwaytools-2.2.2}/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.2
|
|
4
4
|
Summary: 这是一个火车迷也许觉得很好用的铁路机器人工具箱
|
|
5
5
|
Author-email: leaf2006 <leafdeveloper@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -68,14 +68,15 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
68
68
|
|
|
69
69
|
| 指令 | 说明 |
|
|
70
70
|
|:-----:|:----:|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
71
|
+
| `/车号` [动车组车次] | 通过车次查询担当的动车组车组号(例如:`/车号` D3211)|
|
|
72
|
+
| `/车次` [动车组车组号] | 通过动车组车组号查询担当车次(例如:`/车次` CRH2A-2001) |
|
|
73
|
+
| `/查询` [列车车次] | 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表(例如:`/查询` Z225)|
|
|
74
|
+
| `/查询` [列车车次] - `实时` | 子命令`-实时`可以查询列车正晚点与当前已到达哪一站(例如:`/查询` Z225 -`实时` |
|
|
75
|
+
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
76
|
+
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
77
|
+
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
78
|
+
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` DF7C-5030)|
|
|
79
|
+
| `/help` | 查看帮助信息 |
|
|
79
80
|
|
|
80
81
|
#### 功能详细介绍
|
|
81
82
|
|
|
@@ -111,7 +112,7 @@ CRH2A-2001近8次担当的车次为:
|
|
|
111
112
|
2025-11-25 12:36:C3897
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
115
|
+
<!-- - 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
115
116
|
```
|
|
116
117
|
example:
|
|
117
118
|
🤵:/查询 Z99
|
|
@@ -127,6 +128,54 @@ example:
|
|
|
127
128
|
3.金华:20:40到,20:46发,停车6分
|
|
128
129
|
4.广州白云:09:45到,--:--发,停车--分
|
|
129
130
|
------------------------------
|
|
131
|
+
|
|
132
|
+
(这一部分在注释中保留,再见!驶向记忆深处的Z99!)
|
|
133
|
+
|
|
134
|
+
``` -->
|
|
135
|
+
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及开行状态,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z225)
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
example:
|
|
139
|
+
🤵:/查询 Z225
|
|
140
|
+
🤖:
|
|
141
|
+
车次:Z225(北京丰台——合肥)
|
|
142
|
+
担当客运段:合肥客运段
|
|
143
|
+
车型信息:25TAC380V
|
|
144
|
+
配属:合肥车辆段
|
|
145
|
+
Z225次02月06日北京丰台方面正常开行
|
|
146
|
+
|
|
147
|
+
----------停站信息----------
|
|
148
|
+
1.北京丰台:--:--到,21:59开,停车--分
|
|
149
|
+
2.阜阳:04:44到,04:50开,停车6分
|
|
150
|
+
3.霍邱:05:45到,05:49开,停车4分
|
|
151
|
+
4.六安:06:31到,06:34开,停车3分
|
|
152
|
+
5.合肥:07:41到,--:--开,停车--分
|
|
153
|
+
------------------------------
|
|
154
|
+
|
|
155
|
+
数据来源:12306
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
该功能同时还附带一个子命令:`/查询 -实时`,可以查询列车正晚点与当前已到达哪一站
|
|
159
|
+
```
|
|
160
|
+
example:
|
|
161
|
+
🤵:/查询 Z225 -实时
|
|
162
|
+
🤖:
|
|
163
|
+
车次:Z225(北京丰台——合肥)
|
|
164
|
+
担当客运段:合肥客运段
|
|
165
|
+
车型信息:25TAC380V
|
|
166
|
+
配属:合肥车辆段
|
|
167
|
+
Z225次02月06日北京丰台方面正常开行
|
|
168
|
+
列车始发站待发
|
|
169
|
+
|
|
170
|
+
----------停站信息----------
|
|
171
|
+
1.北京丰台:--:--到,21:59开,停车--分,正点运行
|
|
172
|
+
2.阜阳:04:44到,04:50开,停车6分,预计正点
|
|
173
|
+
3.霍邱:05:45到,05:49开,停车4分,预计正点
|
|
174
|
+
4.六安:06:31到,06:34开,停车3分,预计正点
|
|
175
|
+
5.合肥:07:41到,--:--开,停车--分,预计正点
|
|
176
|
+
------------------------------
|
|
177
|
+
|
|
178
|
+
数据来源:12306
|
|
130
179
|
```
|
|
131
180
|
|
|
132
181
|
- 通过车站名称查看车站大屏:`/大屏` [车站名称] 或 `/dp` [车站名称] (例如:/大屏 上海)
|
|
@@ -271,26 +320,31 @@ example:
|
|
|
271
320
|
example:
|
|
272
321
|
🤵:/help
|
|
273
322
|
🤖:
|
|
274
|
-
|
|
275
|
-
|
|
323
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
324
|
+
|
|
276
325
|
----------使用方法----------
|
|
277
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
278
|
-
|
|
279
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
280
|
-
|
|
281
|
-
③
|
|
282
|
-
|
|
283
|
-
|
|
326
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
327
|
+
|
|
328
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
329
|
+
|
|
330
|
+
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
331
|
+
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
332
|
+
|
|
333
|
+
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
334
|
+
|
|
335
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
336
|
+
|
|
337
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
338
|
+
|
|
339
|
+
⑦ 通过车号查询下关站机车户口照:/下关站 或 /xgz (例如:/下关站 DF7C-5030)
|
|
340
|
+
|
|
341
|
+
⑧ 帮助:/帮助 或 /help
|
|
342
|
+
|
|
343
|
+
更多功能正在开发中,尽情期待!
|
|
344
|
+
------------------------------
|
|
284
345
|
|
|
285
|
-
⑤ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
286
|
-
|
|
287
|
-
⑥ 帮助:/帮助 或 /help
|
|
288
|
-
|
|
289
|
-
更多功能正在开发中,尽情期待!
|
|
290
|
-
------------------------------
|
|
291
|
-
|
|
292
346
|
Powered by Nonebot2
|
|
293
|
-
Copyright © Leaf developer 2023-
|
|
347
|
+
Copyright © Leaf developer 2023-2026
|
|
294
348
|
```
|
|
295
349
|
|
|
296
350
|
## Features(Testing)🚨
|
|
@@ -307,6 +361,7 @@ Copyright © Leaf developer 2023-2025
|
|
|
307
361
|
|
|
308
362
|
## TODO 🔜
|
|
309
363
|
|
|
364
|
+
- ~~当前`/线路`功能存在某线路沿途车站过多而触发`IndexError: list index out of range`的Bug,正在努力修复~~**(已修复)**
|
|
310
365
|
- ~~修复`/大屏`功能~~**(已修复)**
|
|
311
366
|
- ~~计划加入生成模拟列车检票大屏的图片的功能,类似CRsim的这种~~ **(这个我计划另写一个插件)**
|
|
312
367
|
- ~~计划加入12306车站大屏功能~~ **(已实现)**
|
|
@@ -50,14 +50,15 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
50
50
|
|
|
51
51
|
| 指令 | 说明 |
|
|
52
52
|
|:-----:|:----:|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
53
|
+
| `/车号` [动车组车次] | 通过车次查询担当的动车组车组号(例如:`/车号` D3211)|
|
|
54
|
+
| `/车次` [动车组车组号] | 通过动车组车组号查询担当车次(例如:`/车次` CRH2A-2001) |
|
|
55
|
+
| `/查询` [列车车次] | 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表(例如:`/查询` Z225)|
|
|
56
|
+
| `/查询` [列车车次] - `实时` | 子命令`-实时`可以查询列车正晚点与当前已到达哪一站(例如:`/查询` Z225 -`实时` |
|
|
57
|
+
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
58
|
+
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
59
|
+
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
60
|
+
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` DF7C-5030)|
|
|
61
|
+
| `/help` | 查看帮助信息 |
|
|
61
62
|
|
|
62
63
|
#### 功能详细介绍
|
|
63
64
|
|
|
@@ -93,7 +94,7 @@ CRH2A-2001近8次担当的车次为:
|
|
|
93
94
|
2025-11-25 12:36:C3897
|
|
94
95
|
```
|
|
95
96
|
|
|
96
|
-
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
97
|
+
<!-- - 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
97
98
|
```
|
|
98
99
|
example:
|
|
99
100
|
🤵:/查询 Z99
|
|
@@ -109,6 +110,54 @@ example:
|
|
|
109
110
|
3.金华:20:40到,20:46发,停车6分
|
|
110
111
|
4.广州白云:09:45到,--:--发,停车--分
|
|
111
112
|
------------------------------
|
|
113
|
+
|
|
114
|
+
(这一部分在注释中保留,再见!驶向记忆深处的Z99!)
|
|
115
|
+
|
|
116
|
+
``` -->
|
|
117
|
+
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及开行状态,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z225)
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
example:
|
|
121
|
+
🤵:/查询 Z225
|
|
122
|
+
🤖:
|
|
123
|
+
车次:Z225(北京丰台——合肥)
|
|
124
|
+
担当客运段:合肥客运段
|
|
125
|
+
车型信息:25TAC380V
|
|
126
|
+
配属:合肥车辆段
|
|
127
|
+
Z225次02月06日北京丰台方面正常开行
|
|
128
|
+
|
|
129
|
+
----------停站信息----------
|
|
130
|
+
1.北京丰台:--:--到,21:59开,停车--分
|
|
131
|
+
2.阜阳:04:44到,04:50开,停车6分
|
|
132
|
+
3.霍邱:05:45到,05:49开,停车4分
|
|
133
|
+
4.六安:06:31到,06:34开,停车3分
|
|
134
|
+
5.合肥:07:41到,--:--开,停车--分
|
|
135
|
+
------------------------------
|
|
136
|
+
|
|
137
|
+
数据来源:12306
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
该功能同时还附带一个子命令:`/查询 -实时`,可以查询列车正晚点与当前已到达哪一站
|
|
141
|
+
```
|
|
142
|
+
example:
|
|
143
|
+
🤵:/查询 Z225 -实时
|
|
144
|
+
🤖:
|
|
145
|
+
车次:Z225(北京丰台——合肥)
|
|
146
|
+
担当客运段:合肥客运段
|
|
147
|
+
车型信息:25TAC380V
|
|
148
|
+
配属:合肥车辆段
|
|
149
|
+
Z225次02月06日北京丰台方面正常开行
|
|
150
|
+
列车始发站待发
|
|
151
|
+
|
|
152
|
+
----------停站信息----------
|
|
153
|
+
1.北京丰台:--:--到,21:59开,停车--分,正点运行
|
|
154
|
+
2.阜阳:04:44到,04:50开,停车6分,预计正点
|
|
155
|
+
3.霍邱:05:45到,05:49开,停车4分,预计正点
|
|
156
|
+
4.六安:06:31到,06:34开,停车3分,预计正点
|
|
157
|
+
5.合肥:07:41到,--:--开,停车--分,预计正点
|
|
158
|
+
------------------------------
|
|
159
|
+
|
|
160
|
+
数据来源:12306
|
|
112
161
|
```
|
|
113
162
|
|
|
114
163
|
- 通过车站名称查看车站大屏:`/大屏` [车站名称] 或 `/dp` [车站名称] (例如:/大屏 上海)
|
|
@@ -253,26 +302,31 @@ example:
|
|
|
253
302
|
example:
|
|
254
303
|
🤵:/help
|
|
255
304
|
🤖:
|
|
256
|
-
|
|
257
|
-
|
|
305
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
306
|
+
|
|
258
307
|
----------使用方法----------
|
|
259
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
260
|
-
|
|
261
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
262
|
-
|
|
263
|
-
③
|
|
264
|
-
|
|
265
|
-
|
|
308
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
309
|
+
|
|
310
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
311
|
+
|
|
312
|
+
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
313
|
+
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
314
|
+
|
|
315
|
+
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
316
|
+
|
|
317
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
318
|
+
|
|
319
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
320
|
+
|
|
321
|
+
⑦ 通过车号查询下关站机车户口照:/下关站 或 /xgz (例如:/下关站 DF7C-5030)
|
|
322
|
+
|
|
323
|
+
⑧ 帮助:/帮助 或 /help
|
|
324
|
+
|
|
325
|
+
更多功能正在开发中,尽情期待!
|
|
326
|
+
------------------------------
|
|
266
327
|
|
|
267
|
-
⑤ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
268
|
-
|
|
269
|
-
⑥ 帮助:/帮助 或 /help
|
|
270
|
-
|
|
271
|
-
更多功能正在开发中,尽情期待!
|
|
272
|
-
------------------------------
|
|
273
|
-
|
|
274
328
|
Powered by Nonebot2
|
|
275
|
-
Copyright © Leaf developer 2023-
|
|
329
|
+
Copyright © Leaf developer 2023-2026
|
|
276
330
|
```
|
|
277
331
|
|
|
278
332
|
## Features(Testing)🚨
|
|
@@ -289,6 +343,7 @@ Copyright © Leaf developer 2023-2025
|
|
|
289
343
|
|
|
290
344
|
## TODO 🔜
|
|
291
345
|
|
|
346
|
+
- ~~当前`/线路`功能存在某线路沿途车站过多而触发`IndexError: list index out of range`的Bug,正在努力修复~~**(已修复)**
|
|
292
347
|
- ~~修复`/大屏`功能~~**(已修复)**
|
|
293
348
|
- ~~计划加入生成模拟列车检票大屏的图片的功能,类似CRsim的这种~~ **(这个我计划另写一个插件)**
|
|
294
349
|
- ~~计划加入12306车站大屏功能~~ **(已实现)**
|
|
@@ -44,11 +44,12 @@ information_helper = on_command("help",aliases={"帮助"},priority=6,block=True)
|
|
|
44
44
|
@information_helper.handle() #帮助页面
|
|
45
45
|
async def handle_information_helper():
|
|
46
46
|
information_Helper_message = Message([
|
|
47
|
-
"
|
|
47
|
+
"✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨ \n \n",
|
|
48
48
|
"----------使用方法----------\n",
|
|
49
49
|
"① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211) \n \n",
|
|
50
50
|
"② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001) \n \n",
|
|
51
|
-
"③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询
|
|
51
|
+
"③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)\n"
|
|
52
|
+
"【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)\n \n"
|
|
52
53
|
"④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)\n \n"
|
|
53
54
|
"⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路) \n \n"
|
|
54
55
|
"⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海) \n \n"
|
|
@@ -88,7 +88,7 @@ async def handle_train_number(args: Message = CommandArg()): # type: ignore
|
|
|
88
88
|
except json.JSONDecodeError:
|
|
89
89
|
result = "输入的动车组车组号格式错误!"
|
|
90
90
|
except Exception as error:
|
|
91
|
-
result = "发生异常," + error
|
|
91
|
+
result = "发生异常," + str(error)
|
|
92
92
|
|
|
93
93
|
await train_number.finish(result) # type: ignore
|
|
94
94
|
else:
|
|
@@ -17,12 +17,16 @@ route_info = on_command("线路",aliases={"xl","线路信息","线","铁路"},pr
|
|
|
17
17
|
async def handle_route_info(args: Message = CommandArg()):
|
|
18
18
|
if route_name_input := args.extract_plain_text():
|
|
19
19
|
|
|
20
|
+
is_hsr = False
|
|
20
21
|
if "铁路" in route_name_input: # 防止搜索出现错误
|
|
21
22
|
route_name_input = route_name_input.replace("铁路","")
|
|
23
|
+
# is_hsr = False
|
|
22
24
|
elif "线" in route_name_input:
|
|
23
25
|
route_name_input = route_name_input.replace("线","")
|
|
26
|
+
# is_hsr = False
|
|
24
27
|
elif "高铁" in route_name_input:
|
|
25
28
|
route_name_input = route_name_input.replace("高铁","")
|
|
29
|
+
is_hsr = True # 判定是否为高速铁路
|
|
26
30
|
else:
|
|
27
31
|
pass
|
|
28
32
|
|
|
@@ -34,9 +38,15 @@ async def handle_route_info(args: Message = CommandArg()):
|
|
|
34
38
|
else:
|
|
35
39
|
for i in range(len(res_search_data)): # 搜索在所有搜索结果中属于“铁路”类别的条目
|
|
36
40
|
if res_search_data[i][1] == "RAIL":
|
|
37
|
-
|
|
41
|
+
if is_hsr == False:
|
|
42
|
+
if "高速" not in res_search_data[i][2]:
|
|
43
|
+
break
|
|
44
|
+
else:
|
|
45
|
+
break
|
|
46
|
+
|
|
38
47
|
rail_id = res_search_data[i][0]
|
|
39
48
|
|
|
49
|
+
# print(rail_id)
|
|
40
50
|
url_route_info = f"{API.api_cnrail_geogv}rail/{rail_id}?locale=zhcn"
|
|
41
51
|
route_info_res = await client.get(url_route_info)
|
|
42
52
|
route_info_raw_data = json.loads(route_info_res.text)
|
|
@@ -82,16 +92,22 @@ async def handle_route_info(args: Message = CommandArg()):
|
|
|
82
92
|
raw_diagram = route_info_data['diagram']['records']
|
|
83
93
|
# route_info_diagram = raw_diagram[num][3][0][2]
|
|
84
94
|
route_info_diagram = ""
|
|
85
|
-
num =
|
|
95
|
+
num = 0
|
|
96
|
+
count = 1
|
|
86
97
|
count_raw_diagram = len(raw_diagram) - 1
|
|
87
98
|
while num < count_raw_diagram:
|
|
99
|
+
if not raw_diagram[num][3] or raw_diagram[num][2] not in ['SST','MST']:
|
|
100
|
+
num += 1
|
|
101
|
+
continue
|
|
102
|
+
|
|
88
103
|
station_name = raw_diagram[num][3][0][2]
|
|
89
104
|
raw_kilometerage = str(raw_diagram[num][1])
|
|
90
105
|
if raw_kilometerage.strip() == "":
|
|
91
106
|
kilometerage = ""
|
|
92
107
|
else:
|
|
93
108
|
kilometerage = f"{raw_kilometerage}Km"
|
|
94
|
-
route_info_diagram += f"【{str(
|
|
109
|
+
route_info_diagram += f"【{str(count)}】{station_name} {kilometerage} \n"
|
|
110
|
+
count += 1
|
|
95
111
|
num += 1
|
|
96
112
|
|
|
97
113
|
|
|
@@ -112,6 +128,8 @@ async def handle_route_info(args: Message = CommandArg()):
|
|
|
112
128
|
|
|
113
129
|
except (httpx.ReadTimeout,httpx.ConnectTimeout):
|
|
114
130
|
route_info_result = "请求超时,请稍等一下再试"
|
|
131
|
+
except Exception as error:
|
|
132
|
+
route_info_result = "发生异常:" + str(error)
|
|
115
133
|
|
|
116
134
|
|
|
117
135
|
await route_info.finish(route_info_result)
|
|
@@ -126,7 +126,9 @@ async def handle_station_info(args: Message = CommandArg()):
|
|
|
126
126
|
])
|
|
127
127
|
except (httpx.ReadTimeout,httpx.ConnectTimeout):
|
|
128
128
|
sta_info_result = "请求超时,请稍等一下再试"
|
|
129
|
-
|
|
129
|
+
except Exception as error:
|
|
130
|
+
route_info_result = "发生异常:" + str(error)
|
|
131
|
+
|
|
130
132
|
await station_info.finish(sta_info_result)
|
|
131
133
|
|
|
132
134
|
else:
|
|
@@ -32,7 +32,7 @@ async def handle_station_screen(args: Message = CommandArg()):
|
|
|
32
32
|
res_train_list = await client.get(url_station_screen)
|
|
33
33
|
res_data = json.loads(res_train_list.text)
|
|
34
34
|
|
|
35
|
-
if "error" in res_data:
|
|
35
|
+
if "error" in res_data or not res_data['当前页车次列表']:
|
|
36
36
|
await station_screen.finish("您输入的车站名不存在或未收录,请重新输入!")
|
|
37
37
|
|
|
38
38
|
else:
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Copyright © Leaf developer 2023-2026
|
|
2
|
+
# 本文件负责实现“列车查询”功能,部分灵感来源于GitHub项目https://github.com/zmy15/ChinaRailway,特此注明
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import datetime
|
|
6
|
+
import httpx
|
|
7
|
+
from nonebot import on_command # type: ignore
|
|
8
|
+
from nonebot.adapters.onebot.v11 import Message, MessageSegment # type: ignore
|
|
9
|
+
from nonebot.plugin import PluginMetadata # type: ignore
|
|
10
|
+
from nonebot.params import CommandArg # type: ignore
|
|
11
|
+
from nonebot.rule import to_me # type: ignore
|
|
12
|
+
from .utils import utils
|
|
13
|
+
from .api import API
|
|
14
|
+
|
|
15
|
+
train_info = on_command("列车查询",aliases={"cx","查询"},priority=5,block=True)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@train_info.handle() # 通过车次查询列车具体信息,不只是能查询动车组,普速列车也可查询
|
|
19
|
+
async def handle_train_info(args: Message = CommandArg()): # type: ignore
|
|
20
|
+
if train_number_input := args.extract_plain_text():
|
|
21
|
+
|
|
22
|
+
is_real_time_query = False # 默认参数为False
|
|
23
|
+
|
|
24
|
+
if "-" in train_number_input: # /查询 功能的二级参数
|
|
25
|
+
if "-实时" in train_number_input:
|
|
26
|
+
is_real_time_query = True # 判断是否启用实时信息查询(列车当前到达何车站,正晚点情况)
|
|
27
|
+
|
|
28
|
+
train_number_input = train_number_input.split("-")[0].strip() # 提取“-”前的字符串
|
|
29
|
+
else:
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
async with httpx.AsyncClient(headers=API.headers) as client:
|
|
33
|
+
|
|
34
|
+
toDay = datetime.date.today().strftime("%Y%m%d") #获取今日时间,以%Y%m%d的格式形式输出
|
|
35
|
+
yesterday = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
|
|
36
|
+
tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
|
|
37
|
+
the_day_before_yesterday = (datetime.date.today() - datetime.timedelta(days=2)).strftime("%Y%m%d")
|
|
38
|
+
the_day_after_tomorrow = (datetime.date.today() + datetime.timedelta(days=2)).strftime("%Y%m%d")
|
|
39
|
+
|
|
40
|
+
request_dates = toDay
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
|
|
44
|
+
# 增加对于列车当日是否开行的判断。判断方法如下:
|
|
45
|
+
# 查询该列车当日的信息,如果无返回数据,则查询±1天与±2天的数据,如都没有,就是没有或长期停开;如果有,则输出那几天的数据,并注明“该列车当日不开行”
|
|
46
|
+
for i in range(5):
|
|
47
|
+
info_data = {
|
|
48
|
+
"trainCode" : train_number_input.upper(),
|
|
49
|
+
"startDay" : request_dates
|
|
50
|
+
}
|
|
51
|
+
info_res = await client.post(API.api_12306,data=info_data)
|
|
52
|
+
info_response_data = json.loads(info_res.text) # 对返回数据进行处理
|
|
53
|
+
request_details = info_response_data['data']['trainDetail']
|
|
54
|
+
|
|
55
|
+
if not request_details and request_dates == toDay:
|
|
56
|
+
request_dates = yesterday
|
|
57
|
+
elif not request_details and request_dates == yesterday:
|
|
58
|
+
request_dates = tomorrow
|
|
59
|
+
elif not request_details and request_dates == tomorrow:
|
|
60
|
+
request_dates = the_day_before_yesterday
|
|
61
|
+
elif not request_details and request_dates == the_day_before_yesterday:
|
|
62
|
+
request_dates = the_day_after_tomorrow
|
|
63
|
+
else:
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
# 对返回数据进行分析
|
|
67
|
+
stop_time = info_response_data['data']['trainDetail']['stopTime']
|
|
68
|
+
|
|
69
|
+
train_code = stop_time[0]['stationTrainCode'] # 车次
|
|
70
|
+
start_station_name = stop_time[0]['start_station_name'] # 始发站名
|
|
71
|
+
end_station_name = stop_time[0]['end_station_name'] # 终到站名
|
|
72
|
+
|
|
73
|
+
jiaolu_corporation_code = stop_time[0]["jiaolu_corporation_code"] # 担当客运段
|
|
74
|
+
if info_data["trainCode"][0] == "D" or info_data["trainCode"][0] == "G" or info_data["trainCode"][0] == "C":
|
|
75
|
+
# url_emu_code = API.api_rail_re + "train/" + info_data["trainCode"]
|
|
76
|
+
url_emu_code = f"{API.api_rail_re}train/{train_code}"
|
|
77
|
+
res_info_EMU = await client.get(url_emu_code)
|
|
78
|
+
info_EMU_code = json.loads(res_info_EMU.text)
|
|
79
|
+
if res_info_EMU.status_code == 404 or not info_EMU_code:
|
|
80
|
+
jiaolu_train_style = " " # Bug fix:判断rail.re的数据库里有没有这个车次的信息,没有的话就给车型信息赋一个空的值
|
|
81
|
+
else:
|
|
82
|
+
if info_EMU_code[0]['date'] == info_EMU_code[1]['date']: # 判定是否重联
|
|
83
|
+
jiaolu_train_style = f"{utils.EMU_code_formatter(info_EMU_code[0]['emu_no'])}与{utils.EMU_code_formatter(info_EMU_code[1]['emu_no'])}重联"
|
|
84
|
+
else:
|
|
85
|
+
jiaolu_train_style = utils.EMU_code_formatter(info_EMU_code[0]['emu_no'])
|
|
86
|
+
|
|
87
|
+
else:
|
|
88
|
+
jiaolu_train_style = stop_time[0]["jiaolu_train_style"] # 车底类型(普通车)
|
|
89
|
+
|
|
90
|
+
jiaolu_dept_train = stop_time[0]["jiaolu_dept_train"] # 车底配属
|
|
91
|
+
|
|
92
|
+
if request_dates == toDay:
|
|
93
|
+
train_schedule_info = f"{train_code}次{datetime.date.today().strftime("%m月%d日")}{start_station_name}方面正常开行"
|
|
94
|
+
else:
|
|
95
|
+
train_schedule_info = f"{train_code}次{datetime.date.today().strftime("%m月%d日")}{start_station_name}方面不开行或已停运,请关注车站公告"
|
|
96
|
+
|
|
97
|
+
stop_inf = []
|
|
98
|
+
stop_dict = {}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
for i, stop in enumerate(stop_time): # 遍历该列车的所有站点、到点、发点、停车时间
|
|
102
|
+
station = stop['stationName']
|
|
103
|
+
arrive_time = utils.time_Formatter_1(stop['arriveTime'])
|
|
104
|
+
start_time = utils.time_Formatter_1(stop['startTime'])
|
|
105
|
+
stopover_time = stop['stopover_time'] + "分"
|
|
106
|
+
ticketDelay = stop['ticketDelay']
|
|
107
|
+
day_difference = stop['dayDifference']
|
|
108
|
+
stop_time_count = len(stop_time)
|
|
109
|
+
|
|
110
|
+
if i == 0: # 判断始发/终到站,给不存在的到点/发点变成“--:--”
|
|
111
|
+
arrive_time = "--:--"
|
|
112
|
+
stopover_time = "--分"
|
|
113
|
+
elif i == stop_time_count -1:
|
|
114
|
+
start_time = "--:--"
|
|
115
|
+
stopover_time = "--分"
|
|
116
|
+
else:
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
if is_real_time_query == True:
|
|
120
|
+
stop_dict.setdefault("晚点",ticketDelay)
|
|
121
|
+
else:
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
stop_dict.setdefault("站点",station)
|
|
125
|
+
stop_dict.setdefault("到点",arrive_time)
|
|
126
|
+
stop_dict.setdefault("发点",start_time)
|
|
127
|
+
stop_dict.setdefault("停车时间",stopover_time)
|
|
128
|
+
stop_dict.setdefault("day_difference",day_difference)
|
|
129
|
+
stop_inf.append(stop_dict)
|
|
130
|
+
stop_dict = {}
|
|
131
|
+
|
|
132
|
+
if is_real_time_query == True: # TODO 这里有问题
|
|
133
|
+
now_time = datetime.datetime.now().strftime("%H:%M")
|
|
134
|
+
end_station_count = stop_time_count - 1
|
|
135
|
+
now_station_count = 0
|
|
136
|
+
train_arrival_status = ""
|
|
137
|
+
if now_time < utils.time_Formatter_1(stop_time[0]['startTime']):
|
|
138
|
+
train_arrival_status = "列车始发站待发"
|
|
139
|
+
elif now_time > utils.time_Formatter_1(stop_time[end_station_count]['arriveTime']) and stop_time[end_station_count]['dayDifference'] == 0:
|
|
140
|
+
train_arrival_status = "列车已经到达终点站"
|
|
141
|
+
now_station_count = end_station_count
|
|
142
|
+
else:
|
|
143
|
+
for station in range(stop_time_count-1):
|
|
144
|
+
if utils.time_Formatter_1(stop_time[station]['startTime']) < now_time and utils.time_Formatter_1(stop_time[station + 1]['arriveTime']) > now_time:
|
|
145
|
+
now_station = stop_time[station + 1]['stationName']
|
|
146
|
+
train_arrival_status = f"列车正在前往{now_station}站"
|
|
147
|
+
now_station_count = station
|
|
148
|
+
break
|
|
149
|
+
else:
|
|
150
|
+
train_arrival_status = ""
|
|
151
|
+
|
|
152
|
+
station_result = ""
|
|
153
|
+
count = 1 # 给时刻表标上序号
|
|
154
|
+
# day_difference_buffer = 0
|
|
155
|
+
# day_differences = [int(stop.get('day_difference', 0)) for stop in stop_inf]
|
|
156
|
+
for i,stop in enumerate(stop_inf): # 想办法整出时刻表的结果,最后将结果添加到Message中去
|
|
157
|
+
# day_difference_output = ""
|
|
158
|
+
|
|
159
|
+
if is_real_time_query == True:
|
|
160
|
+
if request_dates != toDay:
|
|
161
|
+
delay = ""
|
|
162
|
+
else:
|
|
163
|
+
if stop['晚点'] == "0" and i <= now_station_count:
|
|
164
|
+
delay = ",正点运行"
|
|
165
|
+
elif stop['晚点'] == "0" and i > now_station_count:
|
|
166
|
+
delay = ",预计正点"
|
|
167
|
+
else:
|
|
168
|
+
delay = f",晚点{stop['晚点']}分"
|
|
169
|
+
|
|
170
|
+
else:
|
|
171
|
+
delay = ""
|
|
172
|
+
|
|
173
|
+
# current_day_diff = day_differences[i]
|
|
174
|
+
# next_day_diff = day_differences[i+1] if i+1 < len(day_differences) else current_day_diff
|
|
175
|
+
# if current_day_diff != day_difference_buffer:
|
|
176
|
+
# day_difference_buffer = current_day_diff
|
|
177
|
+
# day_difference_output = f"(+{day_difference_buffer}天)\n"
|
|
178
|
+
|
|
179
|
+
station_result += str(count) + "." + stop['站点'] + ":" + stop['到点'] + "到," + stop['发点'] + "开,停车" + stop['停车时间'] + delay + "\n"
|
|
180
|
+
count += 1
|
|
181
|
+
|
|
182
|
+
train_info_output = Message([ # 结果Message
|
|
183
|
+
"车次:",train_code,
|
|
184
|
+
"(",start_station_name , "——" , end_station_name , ") \n",
|
|
185
|
+
"担当客运段:" , jiaolu_corporation_code , "\n",
|
|
186
|
+
"车型信息:" , jiaolu_train_style , "\n",
|
|
187
|
+
"配属:" , jiaolu_dept_train , "\n",
|
|
188
|
+
train_schedule_info , "\n",
|
|
189
|
+
train_arrival_status , "\n",
|
|
190
|
+
"----------停站信息----------\n",
|
|
191
|
+
station_result,
|
|
192
|
+
"------------------------------ \n \n",
|
|
193
|
+
"数据来源:12306",
|
|
194
|
+
]) # type: ignore
|
|
195
|
+
|
|
196
|
+
except KeyError:
|
|
197
|
+
# train_info_output = "输入车次格式错误或者车次未收录,亦又可能是该车次近日不开行。请重新输入!"
|
|
198
|
+
train_info_output = Message([
|
|
199
|
+
"您输入的车次",train_number_input.upper(),"无法查询,可能是以下两种原因导致:\n",
|
|
200
|
+
"------------------------------ \n",
|
|
201
|
+
"1.输入车次格式错误或者车次未收录 \n",
|
|
202
|
+
"2.该车次近期不开行 \n",
|
|
203
|
+
"------------------------------ \n",
|
|
204
|
+
"请重新输入!",
|
|
205
|
+
])
|
|
206
|
+
except Exception as error:
|
|
207
|
+
train_info_output = "发生异常:" + str(error)
|
|
208
|
+
|
|
209
|
+
await train_info.finish(train_info_output)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
else:
|
|
213
|
+
await train_info.finish("请输入正确的列车车次!(如:Z225)")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-railwaytools
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: 这是一个火车迷也许觉得很好用的铁路机器人工具箱
|
|
5
5
|
Author-email: leaf2006 <leafdeveloper@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -68,14 +68,15 @@ git clone https://github.com/leaf2006/nonebot-plugin-railwaytools.git
|
|
|
68
68
|
|
|
69
69
|
| 指令 | 说明 |
|
|
70
70
|
|:-----:|:----:|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
71
|
+
| `/车号` [动车组车次] | 通过车次查询担当的动车组车组号(例如:`/车号` D3211)|
|
|
72
|
+
| `/车次` [动车组车组号] | 通过动车组车组号查询担当车次(例如:`/车次` CRH2A-2001) |
|
|
73
|
+
| `/查询` [列车车次] | 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表(例如:`/查询` Z225)|
|
|
74
|
+
| `/查询` [列车车次] - `实时` | 子命令`-实时`可以查询列车正晚点与当前已到达哪一站(例如:`/查询` Z225 -`实时` |
|
|
75
|
+
| `/大屏` [车站名称] | 通过车站名称查看车站大屏(例如:`/大屏` 上海)|
|
|
76
|
+
| `/线路` [线路名称] | 查询某条铁路基本信息(例如:`/线路` 宣杭铁路)|
|
|
77
|
+
| `/车站` [车站名称] | 查询某车站基本信息(例如:`/车站` 上海)|
|
|
78
|
+
| `/下关站` [机车车号] | 通过车号查询下关站机车户口照(例如:`/下关站` DF7C-5030)|
|
|
79
|
+
| `/help` | 查看帮助信息 |
|
|
79
80
|
|
|
80
81
|
#### 功能详细介绍
|
|
81
82
|
|
|
@@ -111,7 +112,7 @@ CRH2A-2001近8次担当的车次为:
|
|
|
111
112
|
2025-11-25 12:36:C3897
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
115
|
+
<!-- - 通过列车车次查询该车次的始发终到、担当客运段、车型信息以及配属,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z99)
|
|
115
116
|
```
|
|
116
117
|
example:
|
|
117
118
|
🤵:/查询 Z99
|
|
@@ -127,6 +128,54 @@ example:
|
|
|
127
128
|
3.金华:20:40到,20:46发,停车6分
|
|
128
129
|
4.广州白云:09:45到,--:--发,停车--分
|
|
129
130
|
------------------------------
|
|
131
|
+
|
|
132
|
+
(这一部分在注释中保留,再见!驶向记忆深处的Z99!)
|
|
133
|
+
|
|
134
|
+
``` -->
|
|
135
|
+
- 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及开行状态,同时支持动车组与普速列车:`/查询` [列车车次] 或 `/cx` [列车车次] (例如:/查询 Z225)
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
example:
|
|
139
|
+
🤵:/查询 Z225
|
|
140
|
+
🤖:
|
|
141
|
+
车次:Z225(北京丰台——合肥)
|
|
142
|
+
担当客运段:合肥客运段
|
|
143
|
+
车型信息:25TAC380V
|
|
144
|
+
配属:合肥车辆段
|
|
145
|
+
Z225次02月06日北京丰台方面正常开行
|
|
146
|
+
|
|
147
|
+
----------停站信息----------
|
|
148
|
+
1.北京丰台:--:--到,21:59开,停车--分
|
|
149
|
+
2.阜阳:04:44到,04:50开,停车6分
|
|
150
|
+
3.霍邱:05:45到,05:49开,停车4分
|
|
151
|
+
4.六安:06:31到,06:34开,停车3分
|
|
152
|
+
5.合肥:07:41到,--:--开,停车--分
|
|
153
|
+
------------------------------
|
|
154
|
+
|
|
155
|
+
数据来源:12306
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
该功能同时还附带一个子命令:`/查询 -实时`,可以查询列车正晚点与当前已到达哪一站
|
|
159
|
+
```
|
|
160
|
+
example:
|
|
161
|
+
🤵:/查询 Z225 -实时
|
|
162
|
+
🤖:
|
|
163
|
+
车次:Z225(北京丰台——合肥)
|
|
164
|
+
担当客运段:合肥客运段
|
|
165
|
+
车型信息:25TAC380V
|
|
166
|
+
配属:合肥车辆段
|
|
167
|
+
Z225次02月06日北京丰台方面正常开行
|
|
168
|
+
列车始发站待发
|
|
169
|
+
|
|
170
|
+
----------停站信息----------
|
|
171
|
+
1.北京丰台:--:--到,21:59开,停车--分,正点运行
|
|
172
|
+
2.阜阳:04:44到,04:50开,停车6分,预计正点
|
|
173
|
+
3.霍邱:05:45到,05:49开,停车4分,预计正点
|
|
174
|
+
4.六安:06:31到,06:34开,停车3分,预计正点
|
|
175
|
+
5.合肥:07:41到,--:--开,停车--分,预计正点
|
|
176
|
+
------------------------------
|
|
177
|
+
|
|
178
|
+
数据来源:12306
|
|
130
179
|
```
|
|
131
180
|
|
|
132
181
|
- 通过车站名称查看车站大屏:`/大屏` [车站名称] 或 `/dp` [车站名称] (例如:/大屏 上海)
|
|
@@ -271,26 +320,31 @@ example:
|
|
|
271
320
|
example:
|
|
272
321
|
🤵:/help
|
|
273
322
|
🤖:
|
|
274
|
-
|
|
275
|
-
|
|
323
|
+
✨一个火车迷也许觉得很好用的铁路工具箱,具有多种功能✨
|
|
324
|
+
|
|
276
325
|
----------使用方法----------
|
|
277
|
-
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
278
|
-
|
|
279
|
-
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
280
|
-
|
|
281
|
-
③
|
|
282
|
-
|
|
283
|
-
|
|
326
|
+
① 通过车次查询担当的动车组车组号:/车号 或 /ch (例如:/车号 D3211)
|
|
327
|
+
|
|
328
|
+
② 通过动车组车组号查询担当车次:/车次 或 /cc (例如:/车次 CRH2A-2001)
|
|
329
|
+
|
|
330
|
+
③ 通过列车车次查询该车次的始发终到、担当客运段、车型信息、配属以及具体时刻表,同时支持动车组与普速列车:/查询 或 /cx (例如:/查询 Z225)
|
|
331
|
+
【子命令】 -实时:查询列车正晚点与当前已到达哪一站(例如:/查询 Z225 -实时)
|
|
332
|
+
|
|
333
|
+
④ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
334
|
+
|
|
335
|
+
⑤ 查询某条铁路基本信息:/线路 或 /xl (例如:/线路 宣杭铁路)
|
|
336
|
+
|
|
337
|
+
⑥ 查询某车站基本信息:/车站 或 /cz (例如:/车站 上海)
|
|
338
|
+
|
|
339
|
+
⑦ 通过车号查询下关站机车户口照:/下关站 或 /xgz (例如:/下关站 DF7C-5030)
|
|
340
|
+
|
|
341
|
+
⑧ 帮助:/帮助 或 /help
|
|
342
|
+
|
|
343
|
+
更多功能正在开发中,尽情期待!
|
|
344
|
+
------------------------------
|
|
284
345
|
|
|
285
|
-
⑤ 通过车站名称查看车站大屏:/大屏 或 /dp (例如:/大屏 上海)
|
|
286
|
-
|
|
287
|
-
⑥ 帮助:/帮助 或 /help
|
|
288
|
-
|
|
289
|
-
更多功能正在开发中,尽情期待!
|
|
290
|
-
------------------------------
|
|
291
|
-
|
|
292
346
|
Powered by Nonebot2
|
|
293
|
-
Copyright © Leaf developer 2023-
|
|
347
|
+
Copyright © Leaf developer 2023-2026
|
|
294
348
|
```
|
|
295
349
|
|
|
296
350
|
## Features(Testing)🚨
|
|
@@ -307,6 +361,7 @@ Copyright © Leaf developer 2023-2025
|
|
|
307
361
|
|
|
308
362
|
## TODO 🔜
|
|
309
363
|
|
|
364
|
+
- ~~当前`/线路`功能存在某线路沿途车站过多而触发`IndexError: list index out of range`的Bug,正在努力修复~~**(已修复)**
|
|
310
365
|
- ~~修复`/大屏`功能~~**(已修复)**
|
|
311
366
|
- ~~计划加入生成模拟列车检票大屏的图片的功能,类似CRsim的这种~~ **(这个我计划另写一个插件)**
|
|
312
367
|
- ~~计划加入12306车站大屏功能~~ **(已实现)**
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# Copyright © Leaf developer 2023-2026
|
|
2
|
-
# 本文件负责实现“列车查询”功能,部分灵感来源于GitHub项目https://github.com/zmy15/ChinaRailway,特此注明
|
|
3
|
-
|
|
4
|
-
import json
|
|
5
|
-
import datetime
|
|
6
|
-
import httpx
|
|
7
|
-
from nonebot import on_command # type: ignore
|
|
8
|
-
from nonebot.adapters.onebot.v11 import Message, MessageSegment # type: ignore
|
|
9
|
-
from nonebot.plugin import PluginMetadata # type: ignore
|
|
10
|
-
from nonebot.params import CommandArg # type: ignore
|
|
11
|
-
from nonebot.rule import to_me # type: ignore
|
|
12
|
-
from .utils import utils
|
|
13
|
-
from .api import API
|
|
14
|
-
|
|
15
|
-
train_info = on_command("列车查询",aliases={"cx","查询"},priority=5,block=True)
|
|
16
|
-
# def time_Formatter_1(time) -> str: # 格式化时间,1145 -> 11:45
|
|
17
|
-
# return time[:2] + ":" + time[2:]
|
|
18
|
-
|
|
19
|
-
# def EMU_code_formatter(str): # 格式化动车组车号 CRH2A2001 -> CRH2A-2001
|
|
20
|
-
# return str[:-4] + "-" + str[-4:]
|
|
21
|
-
@train_info.handle() # 通过车次查询列车具体信息,不只是能查询动车组,普速列车也可查询
|
|
22
|
-
async def handle_train_info(args: Message = CommandArg()): # type: ignore
|
|
23
|
-
if train_Number_in_Info := args.extract_plain_text():
|
|
24
|
-
|
|
25
|
-
async with httpx.AsyncClient(headers=API.headers) as client:
|
|
26
|
-
|
|
27
|
-
toDay = datetime.date.today().strftime("%Y%m%d") #获取今日时间,以%Y%m%d的格式形式输出
|
|
28
|
-
|
|
29
|
-
info_data = {
|
|
30
|
-
"trainCode" : train_Number_in_Info.upper(),
|
|
31
|
-
"startDay" : toDay
|
|
32
|
-
}
|
|
33
|
-
try:
|
|
34
|
-
|
|
35
|
-
info_res = await client.post(API.api_12306,data=info_data)
|
|
36
|
-
info_Back_data = json.loads(info_res.text) # 对返回数据进行处理
|
|
37
|
-
|
|
38
|
-
# 对返回数据进行分析
|
|
39
|
-
stop_time = info_Back_data['data']['trainDetail']['stopTime']
|
|
40
|
-
|
|
41
|
-
start_Station_name = stop_time[0]['start_station_name'] # 始发站名
|
|
42
|
-
end_Station_name = stop_time[0]['end_station_name'] # 终到站名
|
|
43
|
-
|
|
44
|
-
jiaolu_Corporation_code = stop_time[0]["jiaolu_corporation_code"] # 担当客运段
|
|
45
|
-
if info_data["trainCode"][0] == "D" or info_data["trainCode"][0] == "G" or info_data["trainCode"][0] == "C":
|
|
46
|
-
link_emu_number = API.api_rail_re + "train/" + info_data["trainCode"]
|
|
47
|
-
res_info_EMU = await client.get(link_emu_number)
|
|
48
|
-
info_EMU_code = json.loads(res_info_EMU.text)
|
|
49
|
-
if res_info_EMU.status_code == 404 or not info_EMU_code:
|
|
50
|
-
jiaolu_Train_style = " " # Bug fix:判断rail.re的数据库里有没有这个车次的信息,没有的话就给车型信息赋一个空的值
|
|
51
|
-
else:
|
|
52
|
-
if info_EMU_code[0]['date'] == info_EMU_code[1]['date']: # 判定是否重联
|
|
53
|
-
jiaolu_Train_style = f"{utils.EMU_code_formatter(info_EMU_code[0]['emu_no'])}与{utils.EMU_code_formatter(info_EMU_code[1]['emu_no'])}重联"
|
|
54
|
-
else:
|
|
55
|
-
jiaolu_Train_style = utils.EMU_code_formatter(info_EMU_code[0]['emu_no'])
|
|
56
|
-
|
|
57
|
-
else:
|
|
58
|
-
jiaolu_Train_style = stop_time[0]["jiaolu_train_style"] # 车底类型
|
|
59
|
-
|
|
60
|
-
jiaolu_Dept_train = stop_time[0]["jiaolu_dept_train"] # 车底配属
|
|
61
|
-
|
|
62
|
-
stop_inf = []
|
|
63
|
-
stop_dict = {}
|
|
64
|
-
|
|
65
|
-
for i, stop in enumerate(stop_time): # 遍历该列车的所有站点、到点、发点、停车时间
|
|
66
|
-
station = stop['stationName']
|
|
67
|
-
arrive_time = utils.time_Formatter_1(stop['arriveTime'])
|
|
68
|
-
start_time = utils.time_Formatter_1(stop['startTime'])
|
|
69
|
-
stopover_time = stop['stopover_time'] + "分"
|
|
70
|
-
|
|
71
|
-
if i == 0: # 判断始发/终到站,给不存在的到点/发点变成“--:--”
|
|
72
|
-
arrive_time = "--:--"
|
|
73
|
-
stopover_time = "--分"
|
|
74
|
-
elif i == len(stop_time) -1:
|
|
75
|
-
start_time = "--:--"
|
|
76
|
-
stopover_time = "--分"
|
|
77
|
-
|
|
78
|
-
stop_dict.setdefault("站点",station)
|
|
79
|
-
stop_dict.setdefault("到点",arrive_time)
|
|
80
|
-
stop_dict.setdefault("发点",start_time)
|
|
81
|
-
stop_dict.setdefault("停车时间",stopover_time)
|
|
82
|
-
stop_inf.append(stop_dict)
|
|
83
|
-
stop_dict = {}
|
|
84
|
-
|
|
85
|
-
station_result = ""
|
|
86
|
-
count = 1 # 给时刻表标上序号
|
|
87
|
-
for stop in stop_inf: # 想办法整出时刻表的结果,最后将结果添加到Message中去
|
|
88
|
-
station_result += str(count) + "." + stop['站点'] + ":" + stop['到点'] + "到," + stop['发点'] + "开,停车" + stop['停车时间'] + "\n"
|
|
89
|
-
count += 1
|
|
90
|
-
|
|
91
|
-
train_info_result = Message([ #结果Message
|
|
92
|
-
"车次:",train_Number_in_Info.upper(),
|
|
93
|
-
"(",start_Station_name , "——" , end_Station_name , ") \n",
|
|
94
|
-
"担当客运段:" , jiaolu_Corporation_code , "\n",
|
|
95
|
-
"车型信息:" , jiaolu_Train_style , "\n",
|
|
96
|
-
"配属:" , jiaolu_Dept_train , "\n \n",
|
|
97
|
-
"----------停站信息----------\n",
|
|
98
|
-
station_result,
|
|
99
|
-
"------------------------------",
|
|
100
|
-
]) # type: ignore
|
|
101
|
-
|
|
102
|
-
except KeyError:
|
|
103
|
-
train_info_result = "输入车次格式错误或者车次未收录,请重新输入"
|
|
104
|
-
except Exception as error:
|
|
105
|
-
train_info_result = "发生异常:" + error
|
|
106
|
-
|
|
107
|
-
await train_info.finish(train_info_result)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
else:
|
|
111
|
-
await train_info.finish("请输入正确的列车车次!(如:Z99)")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|