From 6acc94b7c506da285d911296c408a94195e6a794 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 29 Nov 2019 09:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=95=E6=92=AD=E5=BB=B6=E8=BF=9F=E6=8A=95?= =?UTF-8?q?=E7=A8=BF=EF=BC=8C=E6=B3=A8=E9=87=8A=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common.py | 9 +++------ api.py | 15 +++++++++++++++ liveDownloader.py | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) 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)