summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/IRCInterface.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/IRCInterface.py')
-rw-r--r--module/plugins/hooks/IRCInterface.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index d648db7cf..59977b8af 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -44,6 +44,7 @@ class IRCInterface(Thread, Hook):
# self.sm = core.server_methods
self.api = core.api # todo, only use api
+
def coreReady(self):
self.abort = False
self.more = []
@@ -51,6 +52,7 @@ class IRCInterface(Thread, Hook):
self.start()
+
def packageFinished(self, pypack):
try:
if self.getConfig("info_pack"):
@@ -58,6 +60,7 @@ class IRCInterface(Thread, Hook):
except:
pass
+
def downloadFinished(self, pyfile):
try:
if self.getConfig("info_file"):
@@ -66,6 +69,7 @@ class IRCInterface(Thread, Hook):
except:
pass
+
def newCaptchaTask(self, task):
if self.getConfig("captcha") and task.isTextual():
task.handler.append(self)
@@ -78,6 +82,7 @@ class IRCInterface(Thread, Hook):
self.response(_("New Captcha Request: %s") % url)
self.response(_("Answer with 'c %s text on the captcha'") % task.id)
+
def run(self):
# connect to IRC etc.
self.sock = socket.socket()
@@ -99,6 +104,7 @@ class IRCInterface(Thread, Hook):
print_exc()
self.sock.close()
+
def main_loop(self):
readbuffer = ""
while True:
@@ -137,6 +143,7 @@ class IRCInterface(Thread, Hook):
self.handle_events(msg)
+
def handle_events(self, msg):
if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split():
return
@@ -179,6 +186,7 @@ class IRCInterface(Thread, Hook):
except Exception, e:
self.logError(repr(e))
+
def response(self, msg, origin=""):
if origin == "":
for t in self.getConfig("owner").split():
@@ -186,11 +194,13 @@ class IRCInterface(Thread, Hook):
else:
self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg))
+
#### Events
def event_pass(self, args):
return []
+
def event_status(self, args):
downloads = self.api.statusDownloads()
if not downloads:
@@ -216,6 +226,7 @@ class IRCInterface(Thread, Hook):
))
return lines
+
def event_queue(self, args):
ps = self.api.getQueueData()
@@ -228,6 +239,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_collector(self, args):
ps = self.api.getCollectorData()
if not ps:
@@ -239,6 +251,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_info(self, args):
if not args:
return ["ERROR: Use info like this: info <id>"]
@@ -252,6 +265,7 @@ class IRCInterface(Thread, Hook):
return ['LINK #%s: %s (%s) [%s][%s]' % (info.fid, info.name, info.format_size, info.statusmsg, info.plugin)]
+
def event_packinfo(self, args):
if not args:
return ["ERROR: Use packinfo like this: packinfo <id>"]
@@ -283,6 +297,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_more(self, args):
if not self.more:
return ["No more information to display."]
@@ -293,14 +308,17 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_start(self, args):
self.api.unpauseServer()
return ["INFO: Starting downloads."]
+
def event_stop(self, args):
self.api.pauseServer()
return ["INFO: No new downloads will be started."]
+
def event_add(self, args):
if len(args) < 2:
return ['ERROR: Add links like this: "add <packagename|id> links". ',
@@ -326,6 +344,7 @@ class IRCInterface(Thread, Hook):
id = self.api.addPackage(pack, links, 1)
return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))]
+
def event_del(self, args):
if len(args) < 2:
return ["ERROR: Use del command like this: del -p|-l <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"]
@@ -341,6 +360,7 @@ class IRCInterface(Thread, Hook):
else:
return ["ERROR: Use del command like this: del <-p|-l> <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"]
+
def event_push(self, args):
if not args:
return ["ERROR: Push package to queue like this: push <package id>"]
@@ -354,6 +374,7 @@ class IRCInterface(Thread, Hook):
self.api.pushToQueue(id)
return ["INFO: Pushed package #%d to queue." % id]
+
def event_pull(self, args):
if not args:
return ["ERROR: Pull package from queue like this: pull <package id>."]
@@ -365,6 +386,7 @@ class IRCInterface(Thread, Hook):
self.api.pullFromQueue(id)
return ["INFO: Pulled package #%d from queue to collector." % id]
+
def event_c(self, args):
""" captcha answer """
if not args:
@@ -377,6 +399,7 @@ class IRCInterface(Thread, Hook):
task.setResult(" ".join(args[1:]))
return ["INFO: Result %s saved." % " ".join(args[1:])]
+
def event_help(self, args):
lines = ["The following commands are available:",
"add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)",
@@ -400,5 +423,6 @@ class IRCError(Exception):
def __init__(self, value):
self.value = value
+
def __str__(self):
return repr(self.value)