- added doomseeker support, fixed up mod_bridge, now shortens new commit links with bit.ly

Mon, 19 Jan 2015 16:42:36 -0500

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 19 Jan 2015 16:42:36 -0500
changeset 120
9880bb697149
parent 119
0f96e3157b7f
child 121
ac07779f788d

- added doomseeker support, fixed up mod_bridge, now shortens new commit links with bit.ly

hgpoll.py file | annotate | diff | comparison | revisions
irc.py file | annotate | diff | comparison | revisions
mod_bridge.py file | annotate | diff | comparison | revisions
rest.py file | annotate | diff | comparison | revisions
utility.py file | annotate | diff | comparison | revisions
--- a/hgpoll.py	Thu Jan 15 20:48:57 2015 +0200
+++ b/hgpoll.py	Mon Jan 19 16:42:36 2015 -0500
@@ -6,9 +6,12 @@
 import os
 from datetime import datetime
 from configfile import Config
+import utility
 g_needCommitsTxtRebuild = True
 
 def color_for_repo (repo_name):
+	repo_name = repo_name.lower()
+
 	if repo_name == 'zandronum':
 		color = 4
 	elif repo_name == 'zandronum-stable':
@@ -19,6 +22,8 @@
 		color = 3
 	elif repo_name == 'zfc9000':
 		color = 6
+	elif repo_name == 'doomseeker':
+		color = 5
 	else:
 		color = 0
 	return color
@@ -207,6 +212,7 @@
 	check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk')
 	check_repo_exists ('zandronum-everything', '')
 	check_repo_exists ('zfc9000', 'crimsondusk')
+	check_repo_exists ('doomseeker', 'Blzut3')
 	global repocheck_timeout
 	repocheck_timeout = (time.time()) + 15
 
@@ -245,12 +251,23 @@
 	if time.time() < repocheck_timeout:
 		return
 
-	for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable', 'zfc9000']:
+	for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable', 'zfc9000', 'doomseeker']:
 		poll_one_repo (n)
 
 	hgns = Config.get_node ('hg')
 	repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60
 
+def get_repo_owner (repo_name):
+	usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
+	repo_name = repo_name.lower()
+	if repo_name[:9] == 'zandronum':
+		repo_owner = 'Torr_Samaho' if (not usesandbox) else 'crimsondusk'
+	elif repo_name == 'zfc9000':
+		repo_owner = 'crimsondusk'
+	elif repo_name == 'doomseeker':
+		repo_owner = 'Blzut3'
+	return repo_owner
+
 def poll_one_repo (repo_name):
 	global repocheck_timeout
 	hgns = Config.get_node ('hg')
@@ -259,7 +276,7 @@
 		return
 
 	usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
-	repo_owner = 'Torr_Samaho' if (not usesandbox and repo_name != 'zfc9000') else 'crimsondusk'
+	repo_owner = get_repo_owner (repo_name)
 	zanrepo = hgapi.Repo (repo_name)
 	commit_data = []
 	delimeter = '@@@@@@@@@@'
@@ -301,9 +318,10 @@
 	if len (commit_data) == 0:
 		return
 
+	repo_name = repo_name.lower()
 	usestable = repo_name == 'zandronum-stable'
 	usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
-	repo_owner = 'Torr_Samaho' if (not usesandbox and repo_name != 'zfc9000') else 'crimsondusk'
+	repo_owner = get_repo_owner (repo_name)
 	repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
 	num_commits = 0
 	zanrepo = hgapi.Repo (repo_name)
@@ -382,7 +400,7 @@
 						irc_client.privmsg (channel.get_value ('name'),
 							"\003%d%s\003: new commit\0035 %s%s\003 by\0032 %s\003: %s"
 							% (color_for_repo (repo_name), repo_name, commit_node, commit_bookmarks,
-							committer, commit_url))
+							committer, utility.shorten_link (commit_url)))
 
 						for line in commit_message.split ('\n'):
 							irc_client.privmsg (channel.get_value ('name'), line)
--- a/irc.py	Thu Jan 15 20:48:57 2015 +0200
+++ b/irc.py	Mon Jan 19 16:42:36 2015 -0500
@@ -128,13 +128,13 @@
 					if words[1] == "001":
 						self.flags |= CLIF_CONNECTED
 
-						for channel in self.channels:
-							self.write ("JOIN %s %s" % (channel.get_value ('name'), channel.get_value ('password', default='')))
-
 						umode = self.cfg.get_value ('umode', '')
 
 						if umode != '':
 							self.write ('MODE %s %s' % (self.mynick, self.cfg.get_value ('umode', '')))
+
+						for channel in self.channels:
+							self.write ("JOIN %s %s" % (channel.get_value ('name'), channel.get_value ('password', default='')))
 					elif words[1] == "PRIVMSG":
 						self.handle_privmsg (line)
 					elif words[1] == 'QUIT':
--- a/mod_bridge.py	Thu Jan 15 20:48:57 2015 +0200
+++ b/mod_bridge.py	Mon Jan 19 16:42:36 2015 -0500
@@ -93,7 +93,8 @@
 			# Stuff some control characters into the name so that this doesn't cause people who
 			# are on both ends of the bridge to highlight themselves
 			# sender = sender[0:len(sender)/2] + (Irc.BoldChar * 2)
-			sender += '_'
+			# sender += '_'
+			sender = sender[:len(sender)/2] + '`' + sender[len(sender)/2:]
 
 			clientName, channelName = dest.split ('/')
 			Irc.get_client (clientName).privmsg (channelName,
--- a/rest.py	Thu Jan 15 20:48:57 2015 +0200
+++ b/rest.py	Mon Jan 19 16:42:36 2015 -0500
@@ -16,8 +16,8 @@
 g_portnumber = None
 g_throttle = []
 
-valid_repos = ['Torr_Samaho/zandronum', 'Torr_Samaho/zandronum-stable',
-	'crimsondusk/zandronum-sandbox', 'crimsondusk/zandronum-sandbox-stable', 'crimsondusk/zfc9000']
+valid_repos = ['torr_samaho/zandronum', 'torr_samaho/zandronum-stable',
+	'crimsondusk/zandronum-sandbox', 'crimsondusk/zandronum-sandbox-stable', 'crimsondusk/zfc9000', 'blzut3/doomseeker']
 
 def is_throttled (address):
 	i = 0
@@ -86,7 +86,7 @@
 		repodata = jsondata['repository']
 		repo_fullname = '%s/%s' % (repodata['owner'], repodata['name'])
 
-		if repo_fullname not in valid_repos:
+		if repo_fullname.lower() not in valid_repos:
 			raise ValueError ('unknown repository %s' % repo_fullname)
 
 		commit_data = []
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utility.py	Mon Jan 19 16:42:36 2015 -0500
@@ -0,0 +1,15 @@
+import bitly_api
+import irc as Irc
+from configfile import Config
+
+def shorten_link (link):
+	bitly_token = Config.get_node ('bitly').get_value ('access_token', '')
+
+	if bitly_token:
+		c = bitly_api.Connection (access_token = bitly_token)
+		try:
+			return c.shorten (link)['url']
+		except Exception as e:
+			Irc.broadcast ('Error while shortening link %s: %s' % (link, e))
+
+	return link

mercurial