From a4445d2c8064d8099c09a54f08ad57f755f15a5f Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Sun, 27 Apr 2014 23:31:24 +0300 Subject: Add testing command --- plugin.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index 75adadd..6985213 100644 --- a/plugin.py +++ b/plugin.py @@ -28,6 +28,7 @@ import re import json import time +import Queue import urllib import urlparse import threading @@ -44,8 +45,12 @@ import supybot.ircutils as ircutils import supybot.registry as registry import supybot.callbacks as callbacks -RequestHandler = utils.python.universalImport('handler.GithubHandler', 'local.handler.GithubHandler') -Utility = utils.python.universalImport('local.utility') +#RequestHandler = utils.python.universalImport('handler.GithubHandler', 'local.handler.GithubHandler') +#Utility = utils.python.universalImport('local.utility') + +import local.globals as globals +import local.handler.GithubHandler as RequestHandler +import local.utility as Utility class Github(callbacks.Plugin): """Add the help for \"@plugin help Github\" here @@ -53,6 +58,7 @@ class Github(callbacks.Plugin): threaded = True port = Utility.configValue('port') + messages = [] pass def ServerStart(self, httpd): @@ -74,6 +80,7 @@ class Github(callbacks.Plugin): def __call__(self, irc, msg): self.__parent.__call__(irc, msg) + def die(self): self.httpd.server_close() self.httpd.shutdown() @@ -81,6 +88,33 @@ class Github(callbacks.Plugin): reload(RequestHandler) reload(Utility) + def get(self, irc, msg, args, order, type, garbage): + """[] [] [] + Returns the requested message generated by the request handler. + Examples: get first message, get 2nd last response + """ + _digits = re.compile('\d') + + orders = { 'first': 1, + 'second': 2, + 'third': 3, + 'fourth': 4 + } + + if _digits.search(order): + requestedNum = int(re.sub("[^0-9]", "", order)) + else: + requestedNum = orders[order] if order in orders else 1 + + if order == 'last' or type == 'last': + requestedNum = len(globals.messageList) - requestedNum + 1 + + print globals.messageList + irc.reply(globals.messageList[requestedNum-1]) + + # Debug function + get = wrap(get, ['lowered', optional('lowered'), optional('text')]) if world.testing else False + Class = Github -- cgit v1.2.3