TWT233 / khl.py

Python SDK for kaiheila.cn API
MIT License
243 stars 40 forks source link

TimeZone Error Problem #180

Closed toddtail closed 1 year ago

toddtail commented 1 year ago

Describe the bug When running the Minimal example in the README, timezone unkown error problem caused.

To Reproduce null

Expected behavior maybe the Bot class can add a timezone parameter or auto change timezone from beijing to shanghai.

Logs/Screenshots

Traceback (most recent call last):
  File "/home/user/Projects/Python/kook_chat/main.py", line 4, in <module>
    bot = Bot(token='1/MTQyMjM=/vJhMqBfaUly2XFiYCphTlQ==')
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/khl/bot/bot.py", line 74, in __init__
    self.task = TaskManager()
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/khl/task/manager.py", line 19, in __init__
    self._scheduler = AsyncIOScheduler()
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 87, in __init__
    self.configure(gconfig, **options)
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 131, in configure
    self._configure(config)
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/apscheduler/schedulers/asyncio.py", line 54, in _configure
    super(AsyncIOScheduler, self)._configure(config)
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 701, in _configure
    self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/tzlocal/unix.py", line 203, in get_localzone
    _cache_tz = _get_localzone()
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/tzlocal/unix.py", line 180, in _get_localzone
    tz = pds.timezone(tzname)
  File "/home/user/app/anaconda3/envs/kook/lib/python3.9/site-packages/pytz_deprecation_shim/_impl.py", line 41, in timezone
    raise get_exception(UnknownTimeZoneError, key)
pytz_deprecation_shim._exceptions._make_pytz_derived_errors.<locals>.UnknownTimeZoneError: 'Asia/Beijing'

Environment

Additional context null

toddtail commented 1 year ago

simply use command below can make problem solved timedatectl set-timezone Asia/Shanghai

TWT233 commented 1 year ago

thx for the resolution, may I repost this to wiki?

toddtail commented 1 year ago

thx for the resolution, may I repost this to wiki?

Sure.