From: Eric S. Raymond Date: Mon, 1 Oct 2012 01:54:12 +0000 (-0400) Subject: Color highlighting (not enabled by default). X-Git-Tag: 1.3~19 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0092be218e729546db054edd5dccabe2b01d5c67;p=irker.git Color highlighting (not enabled by default). --- diff --git a/NEWS b/NEWS index f964eca..15b7f82 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ 1.3 @ Support for an irker.conf file to set irkerhook variables under Subversion. + Color highlighting of notification fields can be enabled. irkerhook.py now has its own manual page. Added channelmax variable for rate-limiting diff --git a/irkerhook.py b/irkerhook.py index 35b4fe8..781670f 100755 --- a/irkerhook.py +++ b/irkerhook.py @@ -59,7 +59,25 @@ class GenericExtractor: self.server = None self.channels = None self.maxchannels = 0 + self.template = None + self.urlprefix = None self.host = socket.getfqdn() + # Per-commit data begins + self.author = None + self.files = None + self.logmsg = None + self.rev = None + self.color = False + self.bold = self.green = self.blue = "" + self.yellow = self.brown = self.reset = "" + def activate_color(self) + "IRC color codes." + self.bold = '\x02' + self.green = '\x033' + self.blue = '\x032' + self.yellow = '\x037' + self.brown = '\x035' + self.reset = '\x0F' def load_preferences(self, conf): "Load preferences from a file in the repository root." if not os.path.exists(conf): @@ -90,7 +108,7 @@ class GenericExtractor: setattr(self, fld, val) def do_overrides(self): "Make command-line overrides possible." - booleans = ["tcp"] + booleans = ["tcp", "color"] numerics = ["maxchannels"] for tok in self.arguments: for key in self.__dict__: @@ -112,7 +130,7 @@ class GenericExtractor: self.repo = self.project.lower() if not self.channels: self.channels = default_channels % self.__dict__ - if self.urlprefix.lower() == "None": + if self.urlprefix.lower() == "none": self.url = "" else: self.urlprefix = urlprefixmap.get(self.urlprefix, self.urlprefix) @@ -122,6 +140,8 @@ class GenericExtractor: self.url = open(urllib.urlretrieve(self.tinyifier + prefix + self.commit)[0]).read() except: self.url = prefix + self.commit + if self.color: + self.activate.colors() class GitExtractor(GenericExtractor): "Metadata extraction for the git version control system." @@ -133,7 +153,8 @@ class GitExtractor(GenericExtractor): self.server = do("git config --get irker.server") self.channels = do("git config --get irker.channels") self.tcp = do("git config --bool --get irker.tcp") - self.template = '%(project)s: %(author)s %(repo)s:%(branch)s * %(rev)s / %(files)s: %(logmsg)s %(url)s' + self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s' + self.color = do("git config --bool --get irker.color") self.urlprefix = do("git config --get irker.urlprefix") or "gitweb" # This one is git-specific self.revformat = do("git config --get irker.revformat") @@ -198,7 +219,7 @@ class SvnExtractor(GenericExtractor): self.files = self.svnlook("dirs-changed").strip().replace("\n", " ") self.logmsg = self.svnlook("log") self.rev = "r%s" % self.commit - self.template = '%(project)s: %(author)s %(repo)s * %(rev)s / %(files)s: %(logmsg)s %(url)s' + self.template = '%(bold)s%(project)s%(reset)s: %(green)s%(author)s%(reset)s %(repo)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s' self.urlprefix = "viewcvs" self.load_preferences(os.path.join(self.repository, "irker.conf")) self.do_overrides() diff --git a/irkerhook.xml b/irkerhook.xml index a4d0019..0a0a321 100644 --- a/irkerhook.xml +++ b/irkerhook.xml @@ -115,6 +115,17 @@ will take up less space in the notification line. +color + +If "true", highlight notification fields with IRC colors. +Defaults to "false". Note: if you turn this on and notifications stop +appearing on your channel, you need to turn off IRC's color filter +on that channel. To do this you will need op privileges; issue +the command "/mode #irker -c". You may need to first issue +the command "/msg chanserv set #irker MLOCK +nt-slk". + + + maxchannels Interpreted as an integer. If not zero, limits the number of