nonebot-plugin-cnrail 0.2.2.dev1__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-cnrail
3
- Version: 0.2.2.dev1
3
+ Version: 0.2.3
4
4
  Summary: NoneBot2 plugin for query the train time table
5
5
  Home-page: https://github.com/lgc-NB2Dev/nonebot-plugin-cnrail
6
6
  Author-Email: student_2333 <lgc2333@126.com>, XieXiLin <support@xiexilin.com>
@@ -131,7 +131,11 @@ plugins = [
131
131
 
132
132
  ### 效果图
133
133
 
134
- ![效果图](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/cnrail/g3720.png)
134
+ <details>
135
+
136
+ ![效果图](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/cnrail/t301.png)
137
+
138
+ </details>
135
139
 
136
140
  ## 📞 联系
137
141
 
@@ -142,27 +146,29 @@ Telegram:[@lgc2333](https://t.me/lgc2333)
142
146
 
143
147
  ## 💡 鸣谢
144
148
 
145
- ### [海兰德小助手](https://qun.qq.com/qunpro/robot/qunshare?robot_uin=3889001607) & [Train-QQbot 插件](https://github.com/staytomorrow/FindTrain)
149
+ ### [海兰德小助手](https://qun.qq.com/qunpro/robot/qunshare?robot_uin=3889001607) & [Train-QQBot 插件](https://github.com/staytomorrow/FindTrain)
146
150
 
147
151
  灵感来源
148
152
 
149
- ### [12306](https://www.12306.cn)
153
+ ### [MoeFactory 提供的查询 API](https://train.moefactory.com/)
150
154
 
151
155
  数据来源
152
156
 
153
157
  ## 💰 赞助
154
158
 
159
+ **[赞助我](https://blog.lgc2333.top/donate)**
160
+
155
161
  感谢大家的赞助!你们的赞助将是我继续创作的动力!
156
162
 
157
- - [爱发电](https://afdian.net/@lgc2333)
158
- - <details>
159
- <summary>赞助二维码(点击展开)</summary>
163
+ ## 📝 更新日志
164
+
165
+ ### 0.2.3
160
166
 
161
- ![讨饭](https://raw.githubusercontent.com/lgc2333/ShigureBotMenu/master/src/imgs/sponsor.png)
167
+ - 更换上游 API 域名
162
168
 
163
- </details>
169
+ ### 0.2.2
164
170
 
165
- ## 📝 更新日志
171
+ - 修复列车行驶进度条计算问题(fix by [@This-is-XiaoDeng](https://github.com/This-is-XiaoDeng))
166
172
 
167
173
  ### 0.2.1
168
174
 
@@ -114,7 +114,11 @@ plugins = [
114
114
 
115
115
  ### 效果图
116
116
 
117
- ![效果图](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/cnrail/g3720.png)
117
+ <details>
118
+
119
+ ![效果图](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/cnrail/t301.png)
120
+
121
+ </details>
118
122
 
119
123
  ## 📞 联系
120
124
 
@@ -125,27 +129,29 @@ Telegram:[@lgc2333](https://t.me/lgc2333)
125
129
 
126
130
  ## 💡 鸣谢
127
131
 
128
- ### [海兰德小助手](https://qun.qq.com/qunpro/robot/qunshare?robot_uin=3889001607) & [Train-QQbot 插件](https://github.com/staytomorrow/FindTrain)
132
+ ### [海兰德小助手](https://qun.qq.com/qunpro/robot/qunshare?robot_uin=3889001607) & [Train-QQBot 插件](https://github.com/staytomorrow/FindTrain)
129
133
 
130
134
  灵感来源
131
135
 
132
- ### [12306](https://www.12306.cn)
136
+ ### [MoeFactory 提供的查询 API](https://train.moefactory.com/)
133
137
 
134
138
  数据来源
135
139
 
136
140
  ## 💰 赞助
137
141
 
142
+ **[赞助我](https://blog.lgc2333.top/donate)**
143
+
138
144
  感谢大家的赞助!你们的赞助将是我继续创作的动力!
139
145
 
140
- - [爱发电](https://afdian.net/@lgc2333)
141
- - <details>
142
- <summary>赞助二维码(点击展开)</summary>
146
+ ## 📝 更新日志
147
+
148
+ ### 0.2.3
143
149
 
144
- ![讨饭](https://raw.githubusercontent.com/lgc2333/ShigureBotMenu/master/src/imgs/sponsor.png)
150
+ - 更换上游 API 域名
145
151
 
146
- </details>
152
+ ### 0.2.2
147
153
 
148
- ## 📝 更新日志
154
+ - 修复列车行驶进度条计算问题(fix by [@This-is-XiaoDeng](https://github.com/This-is-XiaoDeng))
149
155
 
150
156
  ### 0.2.1
151
157
 
@@ -6,7 +6,7 @@ require("nonebot_plugin_htmlrender")
6
6
  from . import __main__ as __main__ # noqa: E402
7
7
  from .config import ConfigModel # noqa: E402
8
8
 
9
- __version__ = "0.2.2.dev1"
9
+ __version__ = "0.2.3"
10
10
  __plugin_meta__ = PluginMetadata(
11
11
  name="CNRail",
12
12
  description="查询 12306 列车时刻表",
@@ -1,6 +1,6 @@
1
1
  import string
2
2
  from contextlib import suppress
3
- from datetime import date, datetime
3
+ from datetime import date, datetime, timedelta
4
4
  from typing import Optional
5
5
 
6
6
  from arclet.alconna import Alconna, Args, Arparma, CommandMeta
@@ -31,9 +31,17 @@ def parse_date(date_str: str) -> date:
31
31
  .replace(year=today_date.year)
32
32
  .date() # noqa: DTZ007
33
33
  )
34
- if parsed < today_date:
35
- parsed = parsed.replace(year=today_date.year + 1)
36
- return parsed
34
+ for parsed_date in [
35
+ parsed,
36
+ parsed.replace(year=today_date.year - 1),
37
+ parsed.replace(year=today_date.year + 1),
38
+ ]:
39
+ if (
40
+ (today_date - timedelta(days=2))
41
+ <= parsed_date
42
+ <= (today_date + timedelta(days=14))
43
+ ):
44
+ return parsed_date
37
45
  return None
38
46
 
39
47
  date_formats = ("%m/%d", "%m-%d", "%m月%d日", "%m月%d号", "%m月%d")
@@ -12,7 +12,7 @@ from playwright.async_api import Request, Route
12
12
  from .config import config
13
13
  from .models import ReturnData, TrainDetailData, TrainSearchResult, TrainSNData
14
14
 
15
- MOERAIL_API_BASE = "https://train.moefactory.com/api/"
15
+ MOERAIL_API_BASE = "https://rail.moefactory.com/api/"
16
16
 
17
17
  TEMPLATE_PATH = Path(__file__).parent / "templates" / "train_table.html.jinja"
18
18
 
@@ -343,15 +343,14 @@
343
343
  {% for station in detail.via_stations -%}
344
344
  <tr>
345
345
  <td>
346
-
347
346
  <div class="station-point{% if detail.arrived(loop.index0, train_date) %} arrived{% endif %}"></div>
348
347
  </td>
349
348
  <td>{{ station.station_name }}</td>
350
349
  <td>
351
- {% if loop.first %}-{% else %}{{ station.arrival_time}}{% endif %}
350
+ {% if loop.last %}-{% else %}{{ station.departure_time }}{% endif %}
352
351
  </td>
353
352
  <td>
354
- {% if loop.last %}-{% else %}{{ station.departure_time }}{% endif %}
353
+ {% if loop.first %}-{% else %}{{ station.arrival_time}}{% endif %}
355
354
  </td>
356
355
  <td>{% if loop.first %}始发站{% elif loop.last %}终点站{% else %}{{ station.stop_minutes }} 分{% endif %}</td>
357
356
  <td>{{ station.train_number }}</td>
@@ -585,4 +584,4 @@
585
584
  main();
586
585
  </script>
587
586
 
588
- </html>
587
+ </html>
@@ -16,7 +16,7 @@ dependencies = [
16
16
  ]
17
17
  requires-python = ">=3.9,<4.0"
18
18
  readme = "README.md"
19
- version = "0.2.2.dev1"
19
+ version = "0.2.3"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"