diff options
author | EUcancER <root@euer.krebsco.de> | 2011-11-21 15:28:41 +0100 |
---|---|---|
committer | EUcancER <root@euer.krebsco.de> | 2011-11-21 15:28:41 +0100 |
commit | baeab27dffc49fea7336ffe9f24695fc5bf63474 (patch) | |
tree | 6310d75c69e9e11e9ea2a2e803bc882ec14b033c | |
parent | d5c9e86506c4a62d75f958a1c82e943b1b33ad81 (diff) |
//punani: irc support
currently nonfunctional
-rwxr-xr-x | punani/index.py | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/punani/index.py b/punani/index.py index 4e6a64a4..a34c444a 100755 --- a/punani/index.py +++ b/punani/index.py @@ -6,15 +6,37 @@ import json urls = ( '/', 'Index', '/dump','Dump', - '/reload','Reload', +# '/reload','Reload', '/(.+)/(.+)', 'ArchFinder', ) -PDB_FILE="tightnani_db" +PDB_FILE="db/punani" +PORT="9111" +CHANNEL="#retiolum" f = open(PDB_FILE) -pdb= json.load(f) +pdb = json.load(f) f.close() +bot = False + +try: + from threading import Thread + from ircbot import SingleServerIRCBot + class QuickBot(SingleServerIRCBot): + def on_welcome(self,conn,event): conn.join(CHANNEL) + def announce(self,msg): self.connection.privmsg(CHANNEL,"superballs") + #def on_pubmsg(self,conn,e): conn.privmsg(CHANNEL,"superaidsballs") + + bot = QuickBot([("supernode",6667)],"punani","punani") + try: + t = Thread(target=bot.start) + t.setDaemon(1) + t.start() + except (KeyboardInterrupt, SystemExit): + print("Got Interrupt!") + sys.exit() +except Exception,e: + print("Cannot connect to IRC %s" %str(e)) class Index: def GET(self): @@ -35,15 +57,19 @@ class Dump: return json.dumps(pdb,sort_keys=True,indent=4) class ArchFinder: - def GET(self,packer,package): - if not packer or not package: web.BadRequest() + def GET(self,request_packer,package): + if not request_packer or not package: web.BadRequest() else: - packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers + packer = pdb['packer-symlinks'].get(request_packer,request_packer) #try to resolve similar packers super_packer = pdb['super-packer'].get(packer,'') ret = pdb.get(package,{}).get(packer,False) ret = ret if ret else pdb.get(package,{}).get(super_packer,False) - if not ret: + if not ret: + try: + bot.announce("%s asked for %s for the packer %s but i failed to find it. Please help me!" %(web.ctx.ip, packer, package)) + except Exception,e: + print ("Got Exception %s: %s" % (str(Exception),(e))) web.NotFound() return "not found. i'm so sorry :(" else: return ret @@ -52,7 +78,7 @@ class ArchFinder: if __name__ == "__main__": import sys - sys.argv.append("9111") + sys.argv.append(PORT) app = web.application(urls,globals()) app.internalerror = web.debugerror app.run() |