diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-04-27 21:52:48 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-04-27 21:55:52 +0300 |
commit | f77b81fb4b8da3e014959ef72cc20d3c64479a4e (patch) | |
tree | 0709ef6720252f44ae1f78fc0a7ff96da2e3ff12 | |
parent | b83a3d8f35937c128fa3c6076ca04721e313822e (diff) | |
download | supybot_github-f77b81fb4b8da3e014959ef72cc20d3c64479a4e.tar.gz supybot_github-f77b81fb4b8da3e014959ef72cc20d3c64479a4e.tar.bz2 supybot_github-f77b81fb4b8da3e014959ef72cc20d3c64479a4e.zip |
Minor refactoring
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | local/handler/GithubHandler.py | 5 | ||||
-rw-r--r-- | local/utility.py | 4 | ||||
-rw-r--r-- | plugin.py | 6 |
4 files changed, 17 insertions, 4 deletions
@@ -34,3 +34,9 @@ nosetests.xml .mr.developer.cfg .project .pydevproject + +# Supybot test files +conf +logs +test-conf +test-logs diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index db0d3d5..c5510c8 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -9,6 +9,7 @@ import threading import BaseHTTPServer from time import strftime +import supybot.log as log import supybot.conf as conf import supybot.utils as utils import supybot.world as world @@ -40,7 +41,6 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): s.end_headers() s.wfile.write('<!DOCTYPE html><html><head><title>Hello</title></head>') s.wfile.write("<body><p>Thanks, you're awesome.</p>") - s.wfile.write('</body></html>\n') s.wfile.write(s.path.split('/')) @@ -106,3 +106,6 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): #msgs.append( ircmsgs.privmsg("#main", "%s" % ()) ) for msg in msgs: irc.queueMsg(msg) + + def log_message(self, format, *args): + log.info(format % args) diff --git a/local/utility.py b/local/utility.py index 4fba906..7c66d9e 100644 --- a/local/utility.py +++ b/local/utility.py @@ -61,3 +61,7 @@ def getShortURL(longurl): response = urllib2.urlopen(req) url = response.info().getheader('Location') return ircutils.mircColor(url, "purple") + +# Possible colours: +# white, black, (light/dark) blue, (light) green, red, brown, purple, +# orange, yellow, teal, pink, light/dark gray/grey @@ -55,9 +55,9 @@ class Github(callbacks.Plugin): port = Utility.configValue('port') pass - def ServerStart(self, httpd, port): + def ServerStart(self, httpd): try: - log.info('Server Starts - %s:%s' % ('', port)) + log.info('Server Starts - %s:%s' % ('', self.port)) httpd.serve_forever() except: return @@ -67,7 +67,7 @@ class Github(callbacks.Plugin): self.__parent.__init__(irc) server_class = BaseHTTPServer.HTTPServer self.httpd = server_class(('', self.port), RequestHandler.GithubHandler) - t = threading.Thread(target=self.ServerStart, args=(self.httpd, self.port)) + t = threading.Thread(target=self.ServerStart, args=(self.httpd,)) t.daemon = False t.start() |