录播延迟投稿,注释补全

This commit is contained in:
Jerry Yan 2019-11-29 09:23:11 +08:00
parent f96dd9448b
commit 6acc94b7c5
3 changed files with 20 additions and 8 deletions

View File

@ -40,7 +40,7 @@ config = {
doCleanTime = datetime.now() doCleanTime = datetime.now()
loginTime = datetime.now() loginTime = datetime.now()
_clean_flag = None _clean_flag = None
delay = 30 delay = datetime.now()
b = Bilibili() b = Bilibili()
network = [{ network = [{
@ -73,7 +73,7 @@ def reloadConfig():
def resetDelay(): def resetDelay():
global delay global delay
delay = config['dly'] delay = datetime.now() + timedelta(minutes=int(config['dly']))
def doDelay(): def doDelay():
@ -81,10 +81,7 @@ def doDelay():
if isBroadcasting or isEncode or isUpload: if isBroadcasting or isEncode or isUpload:
resetDelay() resetDelay()
return False return False
if delay < 0: return getTimeDelta(datetime.now(), delay) < 0
return False
delay -= 1
return delay < 0
def updateNetwork(): def updateNetwork():

15
api.py
View File

@ -114,12 +114,25 @@ class XiGuaLiveApi:
print("消息 :", user, "关注了主播") print("消息 :", user, "关注了主播")
def onJoin(self, user: User): def onJoin(self, user: User):
"""
加入粉丝团消息
:param user:
"""
print("欢迎", user, "加入了粉丝团") print("欢迎", user, "加入了粉丝团")
def onMessage(self, msg: str): def onMessage(self, msg: str):
"""
系统消息
:param msg:
"""
print("消息 :", msg) print("消息 :", msg)
def onLike(self, user: User): def onLike(self, user: User):
"""
点击喜欢的消息
On Like
:param user:
"""
print("用户", user, "点了喜欢") print("用户", user, "点了喜欢")
def onLeave(self, json: any): def onLeave(self, json: any):
@ -211,8 +224,10 @@ class XiGuaLiveApi:
self.isLive = d["room"]["status"] == 2 self.isLive = d["room"]["status"] == 2
self.roomTitle = d["room"]["title"] self.roomTitle = d["room"]["title"]
self.roomPopularity = d["room"]["user_count"] self.roomPopularity = d["room"]["user_count"]
# 处理抽奖事件
l = Lottery(d) l = Lottery(d)
if l.isActive: if l.isActive:
# 因为现在每个房间只能同时开启一个抽奖,所以放一个就行了
self.lottery = l self.lottery = l
return True return True

View File

@ -127,7 +127,7 @@ def run():
Common.appendError(e.__str__()) Common.appendError(e.__str__())
time.sleep(5) time.sleep(5)
continue continue
time.sleep(5) time.sleep(1)
else: else:
try: try:
Common.api.updRoomInfo() Common.api.updRoomInfo()
@ -144,4 +144,4 @@ def run():
Common.forceStartUploadThread = False Common.forceStartUploadThread = False
if Common.doDelay(): if Common.doDelay():
Common.uploadQueue.put(True) Common.uploadQueue.put(True)
time.sleep(15) time.sleep(5)