- now in color!

Mon, 08 Dec 2014 16:12:51 -0500

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 08 Dec 2014 16:12:51 -0500
changeset 110
b2770c43b752
parent 109
87ad0c1b3405
child 111
44d9aea72947

- now in color!

hgpoll.py file | annotate | diff | comparison | revisions
mod_hgpoll.py file | annotate | diff | comparison | revisions
--- 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)
--- 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'):

mercurial