整理代码

This commit is contained in:
2019-02-04 16:16:41 +08:00
parent 0219d5d1aa
commit 362f5c51d3
11 changed files with 202 additions and 20 deletions

31
Struct/Chat.py Normal file
View File

@ -0,0 +1,31 @@
from .User import User
from .Lottery import Lottery
class Chat:
content: str =""
user: User=None
filterString:list = ["",]
isFiltered = False
def __init__(self, json=None, lottery:Lottery = None):
if json:
self.parse(json)
if lottery:
self.filterString.append(lottery.content)
def parse(self, json):
self.user = User(json)
if "extra" in json:
if "content" in json["extra"]:
self.content = json["extra"]['content']
if self.content in self.filterString:
self.isFiltered = True
def __str__(self):
return "{} : {}".format(self.user,self.content)
def __unicode__(self):
return self.__str__()