aboutsummaryrefslogtreecommitdiff
path: root/src/IRCServer.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-23 21:33:04 +0000
committerGravatar jesopo2019-02-23 21:33:04 +0000
commit8c94bcf6caf0ae88b3a67d0a73389a7e60810e1c (patch)
tree8d72b0760aef71da12403696e9acd387d288e4e0 /src/IRCServer.py
parent!raw needs to parse the line it's given in to an IRCParsedLine now (diff)
signature
Move utils.irc.IRCParsedLine to IRCLine.ParsedLine, improve truncation
mechanism, don't convert sent line from ParsedLine to text to ParsedLine for line_handler handling
Diffstat (limited to 'src/IRCServer.py')
-rw-r--r--src/IRCServer.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/IRCServer.py b/src/IRCServer.py
index 07116484..663f4703 100644
--- a/src/IRCServer.py
+++ b/src/IRCServer.py
@@ -29,7 +29,7 @@ class Server(IRCObject.Object):
self.agreed_capabilities = set([]) # type: typing.Set[str]
self.requested_capabilities = [] # type: typing.List[str]
self.server_capabilities = {} # type: typing.Dict[str, str]
- self.batches = {} # type: typing.Dict[str, utils.irc.IRCParsedLine]
+ self.batches = {} # type: typing.Dict[str, IRCLine.ParsedLine]
self.cap_started = False
self.users = {} # type: typing.Dict[str, IRCUser.User]
@@ -237,23 +237,24 @@ class Server(IRCObject.Object):
self.set_setting("last-read", utils.iso8601_format(now))
return lines
- def send(self, line_parsed: utils.irc.IRCParsedLine):
+ def send(self, line_parsed: IRCLine.ParsedLine):
line = line_parsed.format()
results = self.events.on("preprocess.send").call_unsafe(
server=self, line=line)
- for result in results:
- if result:
- line = result
- break
+ results = list(filter(None, results))
+ if results:
+ line = results[0]
+
line_stripped = line.split("\n", 1)[0].strip("\r")
- line_obj = IRCLine.Line(self, datetime.datetime.utcnow(), line_stripped)
+ line_obj = IRCLine.Line(datetime.datetime.utcnow(), self.hostmask(),
+ line_parsed)
self.socket.send(line_obj)
return line_obj
def _send(self):
lines = self.socket._send()
for line in lines:
- self.bot.log.debug("%s (raw send) | %s", [str(self), line])
+ self.bot.log.debug("%s (raw send) | %s", [str(self), line.format()])
self.events.on("raw.send").call_unsafe(server=self, line=line)
def send_user(self, username: str, realname: str) -> IRCLine.Line: