Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix timezone bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZegWe committed Dec 22, 2021
1 parent 384eabc commit 9fa691b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion plugins/dota2announcement.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pytz import timezone
import pytz
import requests
import re
from model.command import Command
Expand Down Expand Up @@ -61,7 +63,8 @@ def __init__(self, group_id: int, sender: GroupSender):
super().__init__(group_id, sender)
self._announcement = get_announcements(1)[0]
self.scheduler = BackgroundScheduler()
self.scheduler.add_job(self.update, "interval", seconds=60)
self.scheduler.add_job(
self.update, "interval", seconds=60, timezone=pytz.timezone('Asia/Shanghai'))
self.scheduler.start()
self.commands.append(
Command(["查看公告"], [int], "index: 查看指定序号的公告", self.show_announcement))
Expand Down
5 changes: 4 additions & 1 deletion plugins/dota2watcher/watcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from datetime import tzinfo
import time
import pytz
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
from apscheduler.schedulers.background import BackgroundScheduler
Expand Down Expand Up @@ -35,7 +37,8 @@ def __init__(self, group_id: int, sender: GroupSender):
self.running = True
# self.pool.submit(self.update)
self.scheduler = BackgroundScheduler()
self.scheduler.add_job(self.update_once, 'interval', seconds=300)
self.scheduler.add_job(
self.update_once, 'interval', seconds=300, timezone=pytz.timezone('Asia/Shanghai'))
self.scheduler.start()
self.commands.append(
Command(['查看监视'], [], ': 查看监视列表', self.show_watch))
Expand Down

0 comments on commit 9fa691b

Please sign in to comment.