Remove print
calls from IRCBot.py, move received data logging to IRCServer
This commit is contained in:
parent
92f255e9be
commit
9a311c88b6
2 changed files with 7 additions and 8 deletions
|
@ -211,21 +211,18 @@ class Bot(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for piece in data:
|
for piece in data:
|
||||||
if irc:
|
|
||||||
self.log.debug("%s (raw) | %s",
|
|
||||||
[str(sock), piece])
|
|
||||||
sock.parse_data(piece)
|
sock.parse_data(piece)
|
||||||
elif event & select.EPOLLOUT:
|
elif event & select.EPOLLOUT:
|
||||||
sock._send()
|
sock._send()
|
||||||
if sock.fileno() in self.servers:
|
if sock.fileno() in self.servers:
|
||||||
self.register_read(sock)
|
self.register_read(sock)
|
||||||
elif event & select.EPULLHUP:
|
elif event & select.EPULLHUP:
|
||||||
print("hangup")
|
self.log.info("Recieved EPOLLHUP for %s", [str(sock)])
|
||||||
sock.disconnect()
|
sock.disconnect()
|
||||||
|
|
||||||
for server in list(self.servers.values()):
|
for server in list(self.servers.values()):
|
||||||
if server.read_timed_out():
|
if server.read_timed_out():
|
||||||
print("pingout from %s" % str(server))
|
self.log.info("Pinged out from %s", [str(server)])
|
||||||
server.disconnect()
|
server.disconnect()
|
||||||
elif server.ping_due() and not server.ping_sent:
|
elif server.ping_due() and not server.ping_sent:
|
||||||
server.send_ping()
|
server.send_ping()
|
||||||
|
|
|
@ -223,6 +223,8 @@ class Server(IRCObject.Object):
|
||||||
def parse_data(self, line: str):
|
def parse_data(self, line: str):
|
||||||
if not line:
|
if not line:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.bot.log.debug("%s (raw recv) | %s", [str(self), line])
|
||||||
self.events.on("raw.received").call_unsafe(server=self, line=line)
|
self.events.on("raw.received").call_unsafe(server=self, line=line)
|
||||||
self.check_users()
|
self.check_users()
|
||||||
def check_users(self):
|
def check_users(self):
|
||||||
|
@ -285,16 +287,16 @@ class Server(IRCObject.Object):
|
||||||
def read_timed_out(self) -> bool:
|
def read_timed_out(self) -> bool:
|
||||||
return self.until_read_timeout == 0
|
return self.until_read_timeout == 0
|
||||||
|
|
||||||
def send(self, data: str):
|
def send(self, line: str):
|
||||||
returned = self.events.on("preprocess.send").call_unsafe_for_result(
|
returned = self.events.on("preprocess.send").call_unsafe_for_result(
|
||||||
server=self, line=data)
|
server=self, line=data)
|
||||||
line = returned or data
|
line = returned or line
|
||||||
|
|
||||||
encoded = line.split("\n")[0].strip("\r").encode("utf8")
|
encoded = line.split("\n")[0].strip("\r").encode("utf8")
|
||||||
if len(encoded) > 450:
|
if len(encoded) > 450:
|
||||||
encoded = encoded[:450]
|
encoded = encoded[:450]
|
||||||
self.buffered_lines.append(encoded + b"\r\n")
|
self.buffered_lines.append(encoded + b"\r\n")
|
||||||
self.bot.log.debug(">%s | %s", [str(self), encoded.decode("utf8")])
|
self.bot.log.debug("%s (raw send) | %s", [str(self), line])
|
||||||
|
|
||||||
def _send(self):
|
def _send(self):
|
||||||
if not len(self.write_buffer):
|
if not len(self.write_buffer):
|
||||||
|
|
Loading…
Reference in a new issue