# web/ping.py # # """ return pong """ __copyright__ = 'this file is in the public domain' from gozerplugs.webserver.server import httpd def handle_ping(event): """ return pong """ return ['pong', ] if httpd: httpd.addhandler('/ping', handle_ping)
# web/ping.py # # """ return pong """ __copyright__ = 'this file is in the public domain' from gozerplugs.webserver.server import httpd def handle_ping(event): """ return pong """ return [ 'pong', ] if httpd: httpd.addhandler('/ping', handle_ping)
# web/infoitems.py # # """ show all infoitems """ __copyright__ = 'this file is in the public domain' from gozerbot.config import config from gozerbot.database.db import db from gozerplugs.webserver.server import httpd def handle_infoitemsdb(event): """ show database pickle items """ dbresult = db.execute(""" SELECT item, description FROM infoitems """) if not dbresult: return ['no infoitems', ] resultdict = {} result = [] for i in dbresult: if not resultdict.has_key(i[0]): resultdict[i[0]] = [i[1], ] else: resultdict[i[0]].append(i[1]) for i, j in resultdict.iteritems(): result.append("%s ==> %s" % (i, ' .. '.join(j))) return result if httpd: httpd.addhandler('/infoitems', handle_infoitemsdb)
""" dispatch web request """ input = unquote_plus(event.path) bot = fleet.getfirstbot() ievent = Ircevent() try: what = input.split('?', 1)[1] except IndexError: return ["dispatch what ?", ] if what.startswith("command="): what = what[8:] ievent.txt = what ievent.nick = 'web' ievent.userhost = 'web@web' ievent.channel = 'web' q = Queue.Queue() ievent.queues.append(q) ievent.speed = 3 ievent.bot = bot result = [] if plugins.woulddispatch(bot, ievent): start_new_thread(plugins.trydispatch, (bot, ievent)) else: return ["can't dispatch %s" % what, ] result = waitforqueue(q, 60) if not result: return ["can't dispatch %s" % what, ] return result if httpd: httpd.addhandler('/dispatch', handle_dispatch)
# web/quotes.py # # """ show all quotes """ __copyright__ = 'this file is in the public domain' from gozerbot.config import config from gozerbot.database.db import db from gozerplugs.webserver.server import httpd def handle_quotesdb(event): """ show all database quotes """ result = [] dbresult = db.execute(""" SELECT indx, quote FROM quotes """) if not dbresult: return ['no quotes', ] for i in dbresult: result.append("[%s] %s" % (i[0], i[1])) return result if httpd: httpd.addhandler('/quotes', handle_quotesdb)
return [ "dispatch what ?", ] if what.startswith("command="): what = what[8:] ievent.txt = what ievent.nick = 'web' ievent.userhost = 'web@web' ievent.channel = 'web' q = Queue.Queue() ievent.queues.append(q) ievent.speed = 3 ievent.bot = bot result = [] if plugins.woulddispatch(bot, ievent): start_new_thread(plugins.trydispatch, (bot, ievent)) else: return [ "can't dispatch %s" % what, ] result = waitforqueue(q, 60) if not result: return [ "can't dispatch %s" % what, ] return result if httpd: httpd.addhandler('/dispatch', handle_dispatch)
try: what = input.split('?', 1)[1] except IndexError: return ["dispatch what ?", ] if what.startswith("command="): what = what[8:] ievent.txt = what ievent.nick = 'web' ievent.userhost = 'web@web' ievent.channel = 'web' q = Queue.Queue() ievent.queues.append(q) ievent.speed = 3 ievent.bot = bot result = [] if plugins.woulddispatch(bot, ievent): start_new_thread(plugins.trydispatch, (bot, ievent)) else: return ["can't dispatch %s" % ievent.txt, ] result = waitforqueue(q, 3) rlog(10, 'json', str(result)) try: res = dumps(result) except Exception, ex: handle_exception() res = [] return res if httpd: httpd.addhandler('/json', handle_json)
__copyright__ = 'this file is in the public domain' from gozerbot.config import config from gozerbot.database.db import db from gozerplugs.webserver.server import httpd def handle_infoitemsdb(event): """ show database pickle items """ dbresult = db.execute(""" SELECT item, description FROM infoitems """) if not dbresult: return [ 'no infoitems', ] resultdict = {} result = [] for i in dbresult: if not resultdict.has_key(i[0]): resultdict[i[0]] = [ i[1], ] else: resultdict[i[0]].append(i[1]) for i, j in resultdict.iteritems(): result.append("%s ==> %s" % (i, ' .. '.join(j))) return result if httpd: httpd.addhandler('/infoitems', handle_infoitemsdb)
# web/karma.py # # """ show all karma items """ __copyright__ = 'this file is in the public domain' from gozerbot.config import config from gozerbot.database.db import db from gozerplugs.webserver.server import httpd def handle_karmadb(event): """ show all database karma items """ result = [] dbresult = db.execute(""" SELECT item, value FROM karma ORDER BY \ value DESC""") if not dbresult: return ['no karma items', ] for i in dbresult: result.append("%s = %s" % (i[0], i[1])) return result if httpd: httpd.addhandler('/karma', handle_karmadb)
# web/karma.py # # """ show all karma items """ __copyright__ = 'this file is in the public domain' from gozerbot.config import config from gozerbot.database.db import db from gozerplugs.webserver.server import httpd def handle_karmadb(event): """ show all database karma items """ result = [] dbresult = db.execute(""" SELECT item, value FROM karma ORDER BY \ value DESC""") if not dbresult: return [ 'no karma items', ] for i in dbresult: result.append("%s = %s" % (i[0], i[1])) return result if httpd: httpd.addhandler('/karma', handle_karmadb)