From 8a8bd8a77e7a247747b9815c12ef82ed0a44d862 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 11 Nov 2019 12:49:45 +0000 Subject: [PATCH] colorize nicks on JOIN formatting --- modules/format_activity.py | 6 ++++-- src/IRCUser.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/format_activity.py b/modules/format_activity.py index 6ed6b8cc..1e7f540e 100644 --- a/modules/format_activity.py +++ b/modules/format_activity.py @@ -82,8 +82,10 @@ class Module(ModuleManager.BaseModule): event["user"].nickname) def _on_join(self, event, user): - line = "- %s joined %s" % (user.hostmask(), event["channel"].name) - minimal_line = "%s joined %s" % (user.nickname, event["channel"].name) + nickname = self._colorize(user.nickname) + hostmask = "%s!%s" % (nickname, user.userhost()) + line = "- %s joined %s" % (hostmask, event["channel"].name) + minimal_line = "%s joined %s" % (nickname, event["channel"].name) self._event("join", event["server"], line, event["channel"].name, channel=event["channel"], user=user, minimal=minimal_line) diff --git a/src/IRCUser.py b/src/IRCUser.py index 7e6d60ac..5195cfc0 100644 --- a/src/IRCUser.py +++ b/src/IRCUser.py @@ -36,6 +36,10 @@ class User(IRCObject.Object): if self.nickname and self.username and self.hostname: return "%s!%s@%s" % (self.nickname, self.username, self.hostname) return None + def userhost(self) -> typing.Optional[str]: + if self.username and self.hostname: + return "%s@%s" % (self.username, self.hostname) + return None def get_id(self)-> int: return (self.identified_account_id_override or