This repository has been archived on 2022-05-30. You can view files and clone it, but cannot push or open issues or pull requests.
2019-01-20 23:10:35 +08:00

45 lines
1.5 KiB
Python

class User:
ID: int = 0
name: str = ""
brand: str = ""
level: int = 0
type: int = 0
def __init__(self, json=None):
if json:
self.parse(json)
def parse(self, json):
if "Msg" in json:
if "user" in json["Msg"]:
self.ID = json["Msg"]['user']['user_id']
self.name = json["Msg"]['user']['name']
self.type = json["Msg"]['user']['user_type']
if "discipulus_info" in json["Msg"]:
self.level = json["Msg"]["discipulus_info"]["level"]
self.brand = json["Msg"]["discipulus_info"]["discipulus_group_title"]
elif "data" in json:
if "anchorInfo" in json["data"]:
self.ID = json["data"]['anchorInfo']['user_id']
self.name = json["data"]['anchorInfo']['name']
self.type = 0
if self.type is None:
self.type = 0
def __str__(self):
if self.level == 0:
if self.type == 1:
return "[房管]{}".format(self.name)
elif self.type == 2:
return "[主播]{}".format(self.name)
else:
return "{}".format(self.name)
else:
if self.type != 0:
return "[{}{}]{}".format(self.brand, self.level, self.name)
return "<{}{}>{}".format(self.brand,self.level,self.name)
def __unicode__(self):
return self.__str__()