Parse and print when we send QUIT commands (line_handler, print_activity)

This commit is contained in:
jesopo 2019-02-15 19:58:51 +00:00
parent f6179c46ab
commit e51c653c1e
2 changed files with 24 additions and 9 deletions

View file

@ -290,17 +290,26 @@ class Module(ModuleManager.BaseModule):
# a user has disconnected!
@utils.hook("raw.received.quit")
@utils.hook("raw.send.quit")
def quit(self, event):
nickname = None
if event["direction"] == Direction.RECV:
nickname = event["prefix"].nickname
reason = event["args"].get(0)
if (not event["server"].is_own_nickname(event["prefix"].nickname) and
if event["direction"] == Direction.RECV:
nickname = event["prefix"].nickname
if (not event["server"].is_own_nickname(nickname) and
not event["prefix"].hostmask == "*"):
user = event["server"].get_user(event["prefix"].nickname)
user = event["server"].get_user(nickname)
event["server"].remove_user(user)
self._event(event, "quit", reason=reason, user=user,
self.events.on("received.quit").call(reason=reason, user=user,
server=event["server"])
else:
event["server"].disconnect()
else:
self.events.on("send.quit").call(reason=reason,
server=event["server"])
def _match_caps(self, capabilities):
return set(capabilities) & CAPABILITIES

View file

@ -89,10 +89,16 @@ class Module(ModuleManager.BaseModule):
self.print_line(event, "%s changed nickname to %s" % (
event["old_nickname"], event["new_nickname"]))
def _quit(self, event, nickname, reason):
self.print_line(event, "%s quit%s" % (nickname,
"" if not reason else " (%s)" % reason))
@utils.hook("received.quit")
def on_quit(self, event):
self.print_line(event, "%s quit%s" % (event["user"].nickname,
"" if not event["reason"] else " (%s)" % event["reason"]))
self._quit(event, event["user"].nickname, event["reason"])
@utils.hook("send.quit")
def send_quit(self, event):
self._quit(event, event["server"].nickname, event["reason"])
def _on_kick(self, event, nickname):
self.print_line(event, "%s kicked %s from %s%s" % (