diff --git a/Common.py b/Common.py index 1653c66..204058e 100644 --- a/Common.py +++ b/Common.py @@ -40,7 +40,7 @@ config = { doCleanTime = datetime.now() loginTime = datetime.now() _clean_flag = None -delay = 30 +delay = datetime.now() b = Bilibili() network = [{ @@ -73,7 +73,7 @@ def reloadConfig(): def resetDelay(): global delay - delay = config['dly'] + delay = datetime.now() + timedelta(minutes=int(config['dly'])) def doDelay(): @@ -81,10 +81,7 @@ def doDelay(): if isBroadcasting or isEncode or isUpload: resetDelay() return False - if delay < 0: - return False - delay -= 1 - return delay < 0 + return getTimeDelta(datetime.now(), delay) < 0 def updateNetwork(): diff --git a/api.py b/api.py index 5d41f42..c6b4afe 100644 --- a/api.py +++ b/api.py @@ -114,12 +114,25 @@ class XiGuaLiveApi: print("消息 :", user, "关注了主播") def onJoin(self, user: User): + """ + 加入粉丝团消息 + :param user: + """ print("欢迎", user, "加入了粉丝团") def onMessage(self, msg: str): + """ + 系统消息 + :param msg: + """ print("消息 :", msg) def onLike(self, user: User): + """ + 点击喜欢的消息 + On Like + :param user: + """ print("用户", user, "点了喜欢") def onLeave(self, json: any): @@ -211,8 +224,10 @@ class XiGuaLiveApi: self.isLive = d["room"]["status"] == 2 self.roomTitle = d["room"]["title"] self.roomPopularity = d["room"]["user_count"] + # 处理抽奖事件 l = Lottery(d) if l.isActive: + # 因为现在每个房间只能同时开启一个抽奖,所以放一个就行了 self.lottery = l return True diff --git a/liveDownloader.py b/liveDownloader.py index 4d3a831..2f689bb 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -127,7 +127,7 @@ def run(): Common.appendError(e.__str__()) time.sleep(5) continue - time.sleep(5) + time.sleep(1) else: try: Common.api.updRoomInfo() @@ -144,4 +144,4 @@ def run(): Common.forceStartUploadThread = False if Common.doDelay(): Common.uploadQueue.put(True) - time.sleep(15) + time.sleep(5)