Skip to content

Commit

Permalink
🐛 fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kexue-z committed Feb 18, 2024
1 parent 931d828 commit 2fce8ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions nonebot_plugin_heweather/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from typing import Optional

from nonebot import get_plugin_config
from pydantic import BaseModel, Field

from .model import HourlyType


class Config(BaseModel):
qweather_apikey: str = Field(default=None)
qweather_apitype: str = Field(default=None)
qweather_hourlytype: HourlyType = Field(default=HourlyType.current_12h)
qweather_forecase_days: int = Field(default=3)
debug: bool = Field(default=False)
qweather_apikey: Optional[str] = Field(default=None)
qweather_apitype: Optional[str] = Field(default=None)
qweather_hourlytype: Optional[HourlyType] = Field(default=HourlyType.current_12h)
qweather_forecase_days: Optional[int] = Field(default=3)
debug: Optional[bool] = Field(default=False)


plugin_config: Config = get_plugin_config(Config)
Expand Down
5 changes: 3 additions & 2 deletions nonebot_plugin_heweather/weather_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def __url__(self):

def _forecast_days(self):
self.forecast_days = QWEATHER_FORECASE_DAYS
if self.api_type == 0 and not (3 <= self.forecast_days <= 7):
raise ConfigError("api_type = 0 免费订阅 预报天数必须 3<= x <=7")
if self.forecast_days:
if self.api_type == 0 and not (3 <= self.forecast_days <= 7):
raise ConfigError("api_type = 0 免费订阅 预报天数必须 3<= x <=7")

def __init__(self, city_name: str, api_key: str, api_type: Union[int, str] = 0):
self.city_name = city_name
Expand Down

0 comments on commit 2fce8ee

Please sign in to comment.