make distinction to/from in whispers

This commit is contained in:
əlemi 2021-12-16 16:32:07 +01:00
parent 4968acf5ba
commit 1df81a9219

View file

@ -23,11 +23,13 @@ class ChatEvent:
text : str text : str
type : MessageType type : MessageType
user : str user : str
target : str
message : str message : str
def __init__(self, text:str): def __init__(self, text:str):
self.text = REMOVE_COLOR_FORMATS.sub("", parse_chat(text)) self.text = REMOVE_COLOR_FORMATS.sub("", parse_chat(text))
self.user = "" self.user = ""
self.target = ""
self.message= "" self.message= ""
self.type = MessageType.SYSTEM self.type = MessageType.SYSTEM
self._parse() self._parse()
@ -43,7 +45,8 @@ class ChatEvent:
match = WHISPER_MATCHER.search(self.text) match = WHISPER_MATCHER.search(self.text)
if match: if match:
self.type = MessageType.WHISPER self.type = MessageType.WHISPER
self.user = match["touser"] or match["fromuser"] or match["from9b"] self.user = match["fromuser"] or match["from9b"]
self.target = match["touser"]
self.message = match["txt"] self.message = match["txt"]
return return