# HG changeset patch # User Teemu Piippo # Date 1418073171 18000 # Node ID b2770c43b7525d1d4cf8b8ac71a85a000119eea5 # Parent 87ad0c1b34052faa9ae38a80139c21cf2bbde86a - now in color! diff -r 87ad0c1b3405 -r b2770c43b752 hgpoll.py --- a/hgpoll.py Mon Dec 08 15:37:03 2014 -0500 +++ b/hgpoll.py Mon Dec 08 16:12:51 2014 -0500 @@ -8,6 +8,19 @@ from configfile import Config g_needCommitsTxtRebuild = True +def color_for_repo (repo_name): + if repo_name == 'zandronum': + color = 4 + elif repo_name == 'zandronum-stable': + color = 2 + elif repo_name == 'zandronum-sandbox': + color = 7 + elif repo_name == 'zandronum-sandbox-stable': + color = 3 + else: + color = 0 + return color + def make_commits_txt(): global g_needCommitsTxtRebuild @@ -169,7 +182,7 @@ for channel in irc_client.channels: if channel.get_value ('btannounce', default=True): irc_client.privmsg (channel.get_value ('name'), - "%s: commit %s FIXES issue %d" % (repo_name, commit_node, ticket_id)) + "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002" % (color_for_repo (repo_name), repo_name, commit_node, ticket_id)) irc_client.privmsg (channel.get_value ('name'), "Read all about it here: " + Bt.get_ticket_url (ticket_id)) @@ -287,7 +300,7 @@ repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) num_commits = 0 zanrepo = hgapi.Repo (repo_name) - Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) + print '%d new commits on %s' % (len (commit_data), repo_name) # Drop commits that we already have i = 0 @@ -354,8 +367,8 @@ for channel in irc_client.channels: if not usesandbox or channel.get_value ('btprivate', False): irc_client.privmsg (channel.get_value ('name'), - "%s: new commit %s by %s: %s" - % (repo_name, commit_node, committer, commit_url)) + "\003%d%s\003: new commit\0035 %s\003 by\0032 %s\003: %s" + % (color_for_repo (repo_name), repo_name, commit_node, committer, commit_url)) for line in commit_message.split ('\n'): irc_client.privmsg (channel.get_value ('name'), line) diff -r 87ad0c1b3405 -r b2770c43b752 mod_hgpoll.py --- a/mod_hgpoll.py Mon Dec 08 15:37:03 2014 -0500 +++ b/mod_hgpoll.py Mon Dec 08 16:12:51 2014 -0500 @@ -115,7 +115,14 @@ if username != '': author = username - + + # Try prettify the diffstat + rex = re.compile (r'^([0-9]+): \+([0-9]+)/-([0-9]+)$') + match = rex.match (diffstat) + + if match: + diffstat = "%s\003:\0033 +%s\003/\0034-%s\003" % (match.group (1), match.group (2), match.group (3)) + if delta.days < 4: if delta.days == 0: if delta.seconds < 60: @@ -131,7 +138,7 @@ else: datestring = 'on %s' % (str (date)) - bot.privmsg (replyto, 'changeset %s (%s %s): committed by %s %s (%s)' % \ + bot.privmsg (replyto, 'changeset\0035 %s (%s %s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ (node, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat)) for line in message.split ('\n'):