[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debian Games Parties!



Christoph Egger schrieb:
> Moin!
> 
> 	Sounds like some fun to do and possibly useful for the project as well.
> If I can make it I'll help there.
> 
> Paul Wise schrieb:
>> On Sun, Apr 12, 2009 at 4:53 PM, Bas Wijnen wrote:
>>> - It would probably be nice to combine the page with an IRC bot for
>>>  notifications.  However, I have no experience with IRC bots at all, so
>>>  that will not work unless someone will implement it.
>> Definitely, and maybe for claims too.
> 
> 	I have no experience there, too, but I'm quite willing&interested in
> figuring it out ;) if we can make up an way for the CGI and the bot to
> communicate.
> 

	I'm actually having some code working (the bot is sitting in
#debian-games-party) listening to my local copy of Bas' cgi script.
Basically the bot is listening on TCP Port 2222 for simple, newline
terminated strings and relaying them to IRC.

	Authentication for this bot would be provided by only allowing
alioth.debian.org to connect to the bot's Port (iptables). For this to
work I made the changes in the diff file to the webscript (Filtering
only changed data + Putting the data over TCP).

	Actually the bot does hardly care about the way the data is submitted
so if there's an better Idea than TCP it's no problem to implement. I
would run my script for the party on christoph-egger.org.

	I'll do some cleanup of the botscript tomorrow and then place it
somewhere on alioth for Consumption.

Regards

	Christoph

-- 
/"\  ASCII Ribbon : GPG-Key ID: 0x0372275D
\ /    Campaign   :
 X   against HTML : Working for Debian
/ \   in eMails   : http://www.debian.org/

http://www.christoph-egger.org/
--- orig	2009-04-12 21:00:48.000000000 +0200
+++ DebianGamesParty.cgi	2009-04-12 20:59:22.000000000 +0200
@@ -3,6 +3,7 @@
 import pickle
 import re
 import cgi
+import telnetlib
 #import lockfile
 # enable debugging
 import cgitb
@@ -64,6 +65,7 @@
 
 def handle_requests (db):
 	form = cgi.FieldStorage (keep_blank_values=1)
+	ircbot = telnetlib.Telnet('localhost', 2222)
 	submit = None
 	for i in form:
 		if i.startswith ('state_'):
@@ -71,15 +73,24 @@
 			state = int (form[i].value)
 			if state > 2:
 				raise ValueError, "invalid state"
-			db[package]["state"] = state
+			if db[package]["state"] != state:
+				db[package]["state"] = state
+				statename = ('screenshot needed', 'screenshot ready', 'screenshot in archive')
+				ircbot.write('State of %s changed to "%s"\n' % (db[package]["name"], statename[state]))
 		elif i.startswith ('comment_'):
 			package = find_package (db, i[8:])
-			db[package]["comment"] = form[i].value
+			if db[package]["comment"] != form[i].value:
+				ircbot.write('Comment "%s" added for package %s\n' % (form[i].value, db[package]["name"]))
+				db[package]["comment"] = form[i].value
 		elif i.startswith ('claim_comment_'):
 			p, n = i[14:].split ('_', 1)
 			package = find_package (db, p)
 			nick = find_nick (db, package, n)
-			db[package]["claims"][nick]["comment"] = form[i].value
+			if db[package]["claims"][nick]["comment"] != form[i].value:
+				db[package]["claims"][nick]["comment"] = form[i].value
+				ircbot.write('Package %s claimed by %s with comment "%s"\n' % (db[package]["name"], 
+											       db[package]["claims"][nick]["nick"],
+											       form[i].value))
 		elif i.startswith ('new_nick_'):
 			pass
 		elif i.startswith ('new_comment_'):
@@ -106,12 +117,14 @@
 		else:
 			comment = form["new_comment_" + db[package]["name"]].value
 		db[package]["claims"] += [{"nick":nick,"comment":comment}]
+		ircbot.write('Claim for %s added by %s with comment "%s"\n' % (db[package]["name"],nick,comment))
 		return
 	assert submit.startswith ('del_')
 	p, n = submit[4:].split ('_', 1)
 	package = find_package (db, p)
 	nick = find_nick (db, package, n)
 	del db[package]["claims"][nick]
+	ircbot.write('%s removed his claim on %s\n' % (n,p))
 
 def makestate (name, num):
 	statename = ('screenshot needed', 'screenshot ready', 'screenshot in archive')

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: