X-Git-Url: https://git.ctpug.org.za/?p=bzrirker.git;a=blobdiff_plain;f=irkerhook.py;h=e9aabc8477726d850f9779cb0f6844333f62c995;hp=b18763a6dfbe19e4953e1a82375584f6b41f416a;hb=HEAD;hpb=3ad4340dea8ee06a11c02d89c5847c516cfc5862 diff --git a/irkerhook.py b/irkerhook.py index b18763a..e9aabc8 100644 --- a/irkerhook.py +++ b/irkerhook.py @@ -42,6 +42,9 @@ class IrkerSender(object): 'files': ' '.join(files), 'logmsg': self.revision.get_summary(), } + if len(fields['files']) > 250: + # Dangerously long looking list of files, so truncate it + fields['files'] = fields['files'][:250] fields.update(self.colours()) text = ('%(bold)s%(project)s:%(reset)s ' '%(green)s%(committer)s%(reset)s ' @@ -104,7 +107,7 @@ class IrkerSender(object): server = self.config.get('irker_server') if not server: server = 'localhost' - port = self.config.get('irker_port') + port = int(self.config.get('irker_port')) if not port: port = IRKER_PORT try: @@ -113,9 +116,10 @@ class IrkerSender(object): channels = self.config.get('irker_channels') if channels: channels = channels.split(',') - msg = unicode(self._format()) - # We rely on the server truncating, rather than trying to be - # too fancy here + # If we're too long, we might not get any notification, so + # we truncate the msg to max 450 chars, and hope that's + # going to be within the 510 irc limit + msg = unicode(self._format())[:450] message = json.dumps({"to": channels, "privmsg": msg}) if channels: # We assume tcp, since I'm lazy, so we just grab that bit