类型提示
This commit is contained in:
parent
3096f742d5
commit
452e1da468
62
api.py
62
api.py
@ -34,16 +34,11 @@ COMMON_HEADERS = {
|
|||||||
|
|
||||||
|
|
||||||
class XiGuaLiveApi:
|
class XiGuaLiveApi:
|
||||||
isLive = False
|
lottery: Lottery or None
|
||||||
isValidRoom = False
|
isValidRoom: bool
|
||||||
_rawRoomInfo = {}
|
isLive: bool
|
||||||
name = ""
|
roomLiver: User or None
|
||||||
roomID = 0
|
roomID: int
|
||||||
roomLiver = None
|
|
||||||
roomPopularity = 0
|
|
||||||
_cursor = "0"
|
|
||||||
lottery = None
|
|
||||||
s = requests.session()
|
|
||||||
|
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
"""
|
"""
|
||||||
@ -58,6 +53,15 @@ class XiGuaLiveApi:
|
|||||||
self.name = name.name
|
self.name = name.name
|
||||||
else:
|
else:
|
||||||
self.name = str(name)
|
self.name = str(name)
|
||||||
|
self.isLive = False
|
||||||
|
self.isValidRoom = False
|
||||||
|
self._rawRoomInfo = {}
|
||||||
|
self.roomID = 0
|
||||||
|
self.roomLiver = None
|
||||||
|
self.roomPopularity = 0
|
||||||
|
self._cursor = "0"
|
||||||
|
self.lottery = None
|
||||||
|
self.s = requests.session()
|
||||||
self.s.headers.update(COMMON_HEADERS)
|
self.s.headers.update(COMMON_HEADERS)
|
||||||
self._updRoomAt = datetime.now()
|
self._updRoomAt = datetime.now()
|
||||||
self.updRoomInfo(True)
|
self.updRoomInfo(True)
|
||||||
@ -321,27 +325,25 @@ class XiGuaLiveApi:
|
|||||||
print(i)
|
print(i)
|
||||||
if "common" not in i and "method" not in i["common"]:
|
if "common" not in i and "method" not in i["common"]:
|
||||||
continue
|
continue
|
||||||
if i["common"]['method'] == "VideoLivePresentMessage":
|
if i["common"]['method'] == "VideoLivePresentEndTipMessage":
|
||||||
self.onPresent(Gift(i))
|
|
||||||
elif i["common"]['method'] == "VideoLivePresentEndTipMessage":
|
|
||||||
self.onPresentEnd(Gift(i))
|
self.onPresentEnd(Gift(i))
|
||||||
elif i["common"]['method'] == "VideoLiveRoomAdMessage":
|
# elif i["common"]['method'] == "VideoLiveRoomAdMessage":
|
||||||
self.onAd(i)
|
# self.onAd(i)
|
||||||
elif i["common"]['method'] == "VideoLiveChatMessage":
|
# elif i["common"]['method'] == "VideoLiveChatMessage":
|
||||||
self.onChat(Chat(i, self.lottery))
|
# self.onChat(Chat(i, self.lottery))
|
||||||
elif i["common"]['method'] == "VideoLiveMemberMessage":
|
# elif i["common"]['method'] == "VideoLiveMemberMessage":
|
||||||
self.onEnter(MemberMsg(i))
|
# self.onEnter(MemberMsg(i))
|
||||||
self._updateRoomPopularity(i)
|
# self._updateRoomPopularity(i)
|
||||||
elif i["common"]['method'] == "VideoLiveSocialMessage":
|
# elif i["common"]['method'] == "VideoLiveSocialMessage":
|
||||||
self.onSubscribe(User(i))
|
# self.onSubscribe(User(i))
|
||||||
elif i["common"]['method'] == "VideoLiveJoinDiscipulusMessage":
|
# elif i["common"]['method'] == "VideoLiveJoinDiscipulusMessage":
|
||||||
self.onJoin(User(i))
|
# self.onJoin(User(i))
|
||||||
elif i["common"]['method'] == "VideoLiveControlMessage":
|
# elif i["common"]['method'] == "VideoLiveControlMessage":
|
||||||
print("消息:", "主播离开一小会")
|
# print("消息:", "主播离开一小会")
|
||||||
# 这个消息代表主播下播了,直接更新房间信息
|
# # 这个消息代表主播下播了,直接更新房间信息
|
||||||
self.updRoomInfo(True)
|
# self.updRoomInfo(True)
|
||||||
elif i["common"]['method'] == "VideoLiveDiggMessage":
|
# elif i["common"]['method'] == "VideoLiveDiggMessage":
|
||||||
self.onLike(User(i))
|
# self.onLike(User(i))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if self.lottery is None or self.lottery.ID == 0:
|
if self.lottery is None or self.lottery.ID == 0:
|
||||||
|
Reference in New Issue
Block a user