nonebot-plugin-cnrail 0.2.1__tar.gz → 0.2.2.dev1__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.1
3
+ Version: 0.2.2.dev1
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>
@@ -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.1"
9
+ __version__ = "0.2.2.dev1"
10
10
  __plugin_meta__ = PluginMetadata(
11
11
  name="CNRail",
12
12
  description="查询 12306 列车时刻表",
@@ -1,6 +1,6 @@
1
1
  from datetime import datetime, timedelta
2
2
  from typing import List, Optional, Union
3
-
3
+ from nonebot.log import logger
4
4
  import pytz
5
5
  from pydantic import BaseModel, Field
6
6
 
@@ -90,26 +90,23 @@ class TrainDetailData(BaseModel):
90
90
  routing: TrainDetailRouing
91
91
 
92
92
  def arrived(self, station_index: int, train_date: str) -> bool: # 有待修改
93
- # logger.debug(f"index: {station_index}, date: {train_date}")
94
- # station = self.via_stations[station_index]
95
- # arrive_time_str = (
96
- # station.arrival_time
97
- # if station.arrival_time is not None
98
- # else station.departure_time
99
- # )
100
- # arrive_datetime = (
101
- # datetime.fromisoformat(
102
- # f"{train_date}T{arrive_time_str}",
103
- # )
104
- # + timedelta(days=station.day_index)
105
- # ).replace(tzinfo=TZ_SHANGHAI)
106
- # if (arrive_datetime.month + 12 * (arrive_datetime.year - datetime.today().year)) > 3:
107
- # arrive_datetime = arrive_datetime.replace(year=arrive_datetime.year - 1)
108
- # logger.debug(
109
- # f"arrive: {arrive_time_str}, arrive_datetime: {arrive_datetime}, now: {datetime.now(TZ_SHANGHAI)}, bool: {datetime.now(TZ_SHANGHAI) >= arrive_datetime}",
110
- # )
111
- # return datetime.now(TZ_SHANGHAI) >= arrive_datetime
112
- return False
93
+ logger.debug(f"index: {station_index}, date: {train_date}")
94
+ station = self.via_stations[station_index]
95
+ arrive_time_str = (
96
+ station.arrival_time
97
+ if station.arrival_time is not None
98
+ else station.departure_time
99
+ )
100
+ arrive_datetime = (
101
+ datetime.fromisoformat(
102
+ f"{train_date}T{arrive_time_str}",
103
+ )
104
+ + timedelta(days=station.day_index)
105
+ ).replace(tzinfo=TZ_SHANGHAI)
106
+ logger.debug(
107
+ f"arrive: {arrive_time_str}, arrive_datetime: {arrive_datetime}, now: {datetime.now(TZ_SHANGHAI)}, bool: {datetime.now(TZ_SHANGHAI) >= arrive_datetime}",
108
+ )
109
+ return datetime.now(TZ_SHANGHAI) >= arrive_datetime
113
110
 
114
111
 
115
112
  class TrainSNData(BaseModel):
@@ -16,7 +16,7 @@ dependencies = [
16
16
  ]
17
17
  requires-python = ">=3.9,<4.0"
18
18
  readme = "README.md"
19
- version = "0.2.1"
19
+ version = "0.2.2.dev1"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"