Update __init__.py
This commit is contained in:
parent
4a5918bfa8
commit
0a4e5503af
1 changed files with 7 additions and 0 deletions
|
@ -41,6 +41,7 @@ class IRCSession: # Actual IRC session
|
||||||
self.context = ssl_module.create_default_context()
|
self.context = ssl_module.create_default_context()
|
||||||
self.wsocket = None
|
self.wsocket = None
|
||||||
self.server, self.port, self.nick, self.user, self.ssl, self.ssl_accept_invalid, self.realname = address,port,nick,user,ssl,ssl_igninvalid,realname
|
self.server, self.port, self.nick, self.user, self.ssl, self.ssl_accept_invalid, self.realname = address,port,nick,user,ssl,ssl_igninvalid,realname
|
||||||
|
self.msgcache_index=0
|
||||||
if ssl:
|
if ssl:
|
||||||
if ssl_igninvalid:
|
if ssl_igninvalid:
|
||||||
self.context = ssl_module._create_unverified_context()
|
self.context = ssl_module._create_unverified_context()
|
||||||
|
@ -113,6 +114,10 @@ class IRCSession: # Actual IRC session
|
||||||
threading.Thread(target=self._dump_message_cache, kwargs={"content": self.raw_text}).start()
|
threading.Thread(target=self._dump_message_cache, kwargs={"content": self.raw_text}).start()
|
||||||
def _dump_message_cache(self, content:str): # The thread of parsing all of the raw data, dumping all of it in the messages list.
|
def _dump_message_cache(self, content:str): # The thread of parsing all of the raw data, dumping all of it in the messages list.
|
||||||
self.messages = self.parse(content)
|
self.messages = self.parse(content)
|
||||||
|
if self.msgcache_index+1 < len(self.messages):
|
||||||
|
self.msgcache_index = len(self.messages)-1
|
||||||
|
def message(self, message:Message):
|
||||||
|
return message
|
||||||
def parse(self, content:str): # Attempt to parse raw data into a Message or SystemMessage object
|
def parse(self, content:str): # Attempt to parse raw data into a Message or SystemMessage object
|
||||||
cache = []
|
cache = []
|
||||||
for i in content.replace("\r\n", "\n").split("\n"):
|
for i in content.replace("\r\n", "\n").split("\n"):
|
||||||
|
@ -121,6 +126,8 @@ class IRCSession: # Actual IRC session
|
||||||
if len(spaced) > 4:
|
if len(spaced) > 4:
|
||||||
if spaced[1] == "NOTICE":
|
if spaced[1] == "NOTICE":
|
||||||
cache.append(SystemMessage(content=" ".join(spaced[3:])[1:],user=User(name=spaced[0][1:] if not "@" in spaced[0] else spaced[0][1:].split("!")[0], system=system_), typ="notice", mention=not system_))
|
cache.append(SystemMessage(content=" ".join(spaced[3:])[1:],user=User(name=spaced[0][1:] if not "@" in spaced[0] else spaced[0][1:].split("!")[0], system=system_), typ="notice", mention=not system_))
|
||||||
|
elif spaced[1] == "433":
|
||||||
|
cache.append(SystemMessage(content=" ".join(spaced[4:])[1:],user=User(name=spaced[0][1:], system=True), typ="error", mention=True))
|
||||||
if len(cache) == 1:
|
if len(cache) == 1:
|
||||||
return cache[0]
|
return cache[0]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue