summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/addon/IRCInterface.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-13 23:47:36 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-13 23:47:36 +0100
commitbdfa8104065831bf0eb2f6a022552e8de725ed47 (patch)
tree4a43864e1bb257c7737a765d62899244b825a859 /pyload/plugins/addon/IRCInterface.py
parent[themes] Tiny code cosmetics (diff)
parent[Plugin] Some fixes by rlindner81 (diff)
downloadpyload-bdfa8104065831bf0eb2f6a022552e8de725ed47.tar.xz
Merge branch 'stable' into 0.4.10
Conflicts: module/plugins/accounts/MegaRapidCz.py module/plugins/accounts/ShareRapidCom.py module/plugins/crypter/HotfileComFolder.py module/plugins/crypter/HotfileFolderCom.py module/plugins/hoster/Keep2shareCC.py module/plugins/hoster/Keep2shareCc.py module/plugins/hoster/MegaCoNz.py module/plugins/hoster/MegaNz.py module/plugins/hoster/MegaRapidCz.py module/plugins/hoster/ShareRapidCom.py module/plugins/internal/CaptchaService.py pyload/api/__init__.py pyload/manager/AccountManager.py pyload/manager/PluginManager.py pyload/manager/thread/PluginThread.py pyload/network/HTTPRequest.py pyload/network/XDCCRequest.py pyload/plugins/Plugin.py pyload/plugins/account/BillionuploadsCom.py pyload/plugins/account/CramitIn.py pyload/plugins/account/EasybytezCom.py pyload/plugins/account/FastshareCz.py pyload/plugins/account/File4safeCom.py pyload/plugins/account/FileParadoxIn.py pyload/plugins/account/FileomCom.py pyload/plugins/account/FilerNet.py pyload/plugins/account/FilerioCom.py pyload/plugins/account/FourSharedCom.py pyload/plugins/account/Ftp.py pyload/plugins/account/Http.py pyload/plugins/account/HugefilesNet.py pyload/plugins/account/HundredEightyUploadCom.py pyload/plugins/account/LomafileCom.py pyload/plugins/account/MovReelCom.py pyload/plugins/account/MultishareCz.py pyload/plugins/account/MyfastfileCom.py pyload/plugins/account/NosuploadCom.py pyload/plugins/account/NovafileCom.py pyload/plugins/account/QuickshareCz.py pyload/plugins/account/RarefileNet.py pyload/plugins/account/RyushareCom.py pyload/plugins/account/SecureUploadEu.py pyload/plugins/account/SendmywayCom.py pyload/plugins/account/ShareRapidCom.py pyload/plugins/account/StahnuTo.py pyload/plugins/account/StreamcloudEu.py pyload/plugins/account/TusfilesNet.py pyload/plugins/account/UploadingCom.py pyload/plugins/account/UptoboxCom.py pyload/plugins/account/VidPlayNet.py pyload/plugins/addon/Checksum.py pyload/plugins/addon/ClickAndLoad.py pyload/plugins/addon/DeleteFinished.py pyload/plugins/addon/DownloadScheduler.py pyload/plugins/addon/ExternalScripts.py pyload/plugins/addon/ExtractArchive.py pyload/plugins/addon/HotFolder.py pyload/plugins/addon/IRCInterface.py pyload/plugins/addon/MergeFiles.py pyload/plugins/addon/MultiHome.py pyload/plugins/addon/RestartFailed.py pyload/plugins/addon/UnSkipOnFail.py pyload/plugins/addon/WindowsPhoneToastNotify.py pyload/plugins/addon/XMPPInterface.py pyload/plugins/base/Container.py pyload/plugins/base/Crypter.py pyload/plugins/base/Hook.py pyload/plugins/base/OCR.py pyload/plugins/container/RSDF.py pyload/plugins/crypter/DuploadOrgFolder.py pyload/plugins/crypter/EasybytezComFolder.py pyload/plugins/crypter/FiredriveComFolder.py pyload/plugins/crypter/HotfileFolderCom.py pyload/plugins/crypter/LinkSaveIn.py pyload/plugins/crypter/MultiuploadCom.py pyload/plugins/crypter/ShareRapidComFolder.py pyload/plugins/crypter/TusfilesNetFolder.py pyload/plugins/crypter/UploadableChFolder.py pyload/plugins/crypter/UploadedToFolder.py pyload/plugins/hook/Captcha9kw.py pyload/plugins/hook/MyfastfileCom.py pyload/plugins/hoster/BillionuploadsCom.py pyload/plugins/hoster/CramitIn.py pyload/plugins/hoster/EasybytezCom.py pyload/plugins/hoster/File4safeCom.py pyload/plugins/hoster/FileParadoxIn.py pyload/plugins/hoster/FilefactoryCom.py pyload/plugins/hoster/FileomCom.py pyload/plugins/hoster/FilerioCom.py pyload/plugins/hoster/FileshareInUa.py pyload/plugins/hoster/FiredriveCom.py pyload/plugins/hoster/Ftp.py pyload/plugins/hoster/HugefilesNet.py pyload/plugins/hoster/HundredEightyUploadCom.py pyload/plugins/hoster/Keep2shareCC.py pyload/plugins/hoster/LoadTo.py pyload/plugins/hoster/LomafileCom.py pyload/plugins/hoster/MegaNz.py pyload/plugins/hoster/MegacrypterCom.py pyload/plugins/hoster/MovReelCom.py pyload/plugins/hoster/MyvideoDe.py pyload/plugins/hoster/NosuploadCom.py pyload/plugins/hoster/NovafileCom.py pyload/plugins/hoster/PandaPlaNet.py pyload/plugins/hoster/PremiumTo.py pyload/plugins/hoster/RarefileNet.py pyload/plugins/hoster/RyushareCom.py pyload/plugins/hoster/SecureUploadEu.py pyload/plugins/hoster/SendmywayCom.py pyload/plugins/hoster/ShareRapidCom.py pyload/plugins/hoster/SockshareCom.py pyload/plugins/hoster/StreamcloudEu.py pyload/plugins/hoster/TurbobitNet.py pyload/plugins/hoster/TusfilesNet.py pyload/plugins/hoster/UptoboxCom.py pyload/plugins/hoster/VidPlayNet.py pyload/plugins/hoster/WebshareCz.py pyload/plugins/internal/DeadCrypter.py pyload/plugins/internal/DeadHoster.py pyload/plugins/internal/MultiHoster.py pyload/plugins/internal/SimpleCrypter.py pyload/plugins/internal/SimpleHoster.py pyload/plugins/internal/UpdateManager.py pyload/plugins/internal/XFSPAccount.py pyload/plugins/internal/XFSPHoster.py pyload/utils/__init__.py pyload/utils/packagetools.py pyload/webui/app/cnl.py
Diffstat (limited to 'pyload/plugins/addon/IRCInterface.py')
-rw-r--r--pyload/plugins/addon/IRCInterface.py82
1 files changed, 55 insertions, 27 deletions
diff --git a/pyload/plugins/addon/IRCInterface.py b/pyload/plugins/addon/IRCInterface.py
index 9f77bfc7e..041c8b07b 100644
--- a/pyload/plugins/addon/IRCInterface.py
+++ b/pyload/plugins/addon/IRCInterface.py
@@ -2,6 +2,7 @@
import re
import socket
+import ssl
import time
from pycurl import FORM_FILE
@@ -17,15 +18,15 @@ from pyload.utils import formatSize
class IRCInterface(Thread, Addon):
- __name__ = "IRCInterface"
- __type__ = "addon"
- __version__ = "0.11"
+ __name__ = "IRCInterface"
+ __type__ = "addon"
+ __version__ = "0.12"
- __config__ = [("activated", "bool", "Activated", False),
- ("host", "str", "IRC-Server Address", "Enter your server here!"),
+ __config__ = [("host", "str", "IRC-Server Address", "Enter your server here!"),
("port", "int", "IRC-Server Port", 6667),
("ident", "str", "Clients ident", "pyload-irc"),
("realname", "str", "Realname", "pyload-irc"),
+ ("ssl", "bool", "Use SSL", False),
("nick", "str", "Nickname the Client will take", "pyLoad-IRC"),
("owner", "str", "Nickname the Client will accept commands from", "Enter your nick here!"),
("info_file", "bool", "Inform about every file finished", False),
@@ -33,15 +34,15 @@ class IRCInterface(Thread, Addon):
("captcha", "bool", "Send captcha requests", True)]
__description__ = """Connect to irc and let owner perform different tasks"""
- __authors__ = [("Jeix", "Jeix@hasnomail.com")]
+ __license__ = "GPLv3"
+ __authors__ = [("Jeix", "Jeix@hasnomail.com")]
def __init__(self, core, manager):
Thread.__init__(self)
Addon.__init__(self, core, manager)
self.setDaemon(True)
- # self.sm = core.server_methods
- self.api = core.api # todo, only use api
+
def coreReady(self):
self.abort = False
@@ -50,6 +51,7 @@ class IRCInterface(Thread, Addon):
self.start()
+
def packageFinished(self, pypack):
try:
if self.getConfig("info_pack"):
@@ -57,6 +59,7 @@ class IRCInterface(Thread, Addon):
except:
pass
+
def downloadFinished(self, pyfile):
try:
if self.getConfig("info_file"):
@@ -65,6 +68,7 @@ class IRCInterface(Thread, Addon):
except:
pass
+
def newCaptchaTask(self, task):
if self.getConfig("captcha") and task.isTextual():
task.handler.append(self)
@@ -77,11 +81,16 @@ class IRCInterface(Thread, Addon):
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()
host = self.getConfig("host")
self.sock.connect((host, self.getConfig("port")))
+
+ if self.getConfig("ssl"):
+ self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support certificate
+
nick = self.getConfig("nick")
self.sock.send("NICK %s\r\n" % nick)
self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick))
@@ -98,6 +107,7 @@ class IRCInterface(Thread, Addon):
print_exc()
self.sock.close()
+
def main_loop(self):
readbuffer = ""
while True:
@@ -136,6 +146,7 @@ class IRCInterface(Thread, Addon):
self.handle_events(msg)
+
def handle_events(self, msg):
if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split():
return
@@ -148,15 +159,15 @@ class IRCInterface(Thread, Addon):
# HANDLE CTCP ANTI FLOOD/BOT PROTECTION
if msg['text'] == "\x01VERSION\x01":
- self.logDebug("Sending CTCP VERSION.")
+ self.logDebug("Sending CTCP VERSION")
self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface"))
return
elif msg['text'] == "\x01TIME\x01":
- self.logDebug("Sending CTCP TIME.")
+ self.logDebug("Sending CTCP TIME")
self.sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time()))
return
elif msg['text'] == "\x01LAG\x01":
- self.logDebug("Received CTCP LAG.") # don't know how to answer
+ self.logDebug("Received CTCP LAG") #: don't know how to answer
return
trigger = "pass"
@@ -176,7 +187,8 @@ class IRCInterface(Thread, Addon):
for line in res:
self.response(line, msg['origin'])
except Exception, e:
- self.logError(repr(e))
+ self.logError(e)
+
def response(self, msg, origin=""):
if origin == "":
@@ -185,13 +197,15 @@ class IRCInterface(Thread, Addon):
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()
+ downloads = self.core.api.statusDownloads()
if not downloads:
return ["INFO: There are no active downloads currently."]
@@ -215,8 +229,9 @@ class IRCInterface(Thread, Addon):
))
return lines
+
def event_queue(self, args):
- ps = self.api.getQueueData()
+ ps = self.core.api.getQueueData()
if not ps:
return ["INFO: There are no packages in queue."]
@@ -227,8 +242,9 @@ class IRCInterface(Thread, Addon):
return lines
+
def event_collector(self, args):
- ps = self.api.getCollectorData()
+ ps = self.core.api.getCollectorData()
if not ps:
return ["INFO: No packages in collector!"]
@@ -238,19 +254,21 @@ class IRCInterface(Thread, Addon):
return lines
+
def event_info(self, args):
if not args:
return ["ERROR: Use info like this: info <id>"]
info = None
try:
- info = self.api.getFileData(int(args[0]))
+ info = self.core.api.getFileData(int(args[0]))
except FileDoesNotExists:
return ["ERROR: Link doesn't exists."]
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>"]
@@ -258,7 +276,7 @@ class IRCInterface(Thread, Addon):
lines = []
pack = None
try:
- pack = self.api.getPackageData(int(args[0]))
+ pack = self.core.api.getPackageData(int(args[0]))
except PackageDoesNotExists:
return ["ERROR: Package doesn't exists."]
@@ -282,6 +300,7 @@ class IRCInterface(Thread, Addon):
return lines
+
def event_more(self, args):
if not self.more:
return ["No more information to display."]
@@ -292,14 +311,17 @@ class IRCInterface(Thread, Addon):
return lines
+
def event_start(self, args):
- self.api.unpauseServer()
+ self.core.api.unpauseServer()
return ["INFO: Starting downloads."]
+
def event_stop(self, args):
- self.api.pauseServer()
+ self.core.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". ',
@@ -312,7 +334,7 @@ class IRCInterface(Thread, Addon):
count_failed = 0
try:
id = int(pack)
- pack = self.api.getPackageData(id)
+ pack = self.core.api.getPackageData(id)
if not pack:
return ["ERROR: Package doesn't exists."]
@@ -322,48 +344,52 @@ class IRCInterface(Thread, Addon):
except:
# create new package
- id = self.api.addPackage(pack, links, 1)
+ id = self.core.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)"]
if args[0] == "-p":
- ret = self.api.deletePackages(map(int, args[1:]))
+ ret = self.core.api.deletePackages(map(int, args[1:]))
return ["INFO: Deleted %d packages!" % len(args[1:])]
elif args[0] == "-l":
- ret = self.api.delLinks(map(int, args[1:]))
+ ret = self.core.api.delLinks(map(int, args[1:]))
return ["INFO: Deleted %d links!" % len(args[1:])]
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>"]
id = int(args[0])
try:
- info = self.api.getPackageInfo(id)
+ info = self.core.api.getPackageInfo(id)
except PackageDoesNotExists:
return ["ERROR: Package #%d does not exist." % id]
- self.api.pushToQueue(id)
+ self.core.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>."]
id = int(args[0])
- if not self.api.getPackageData(id):
+ if not self.core.api.getPackageData(id):
return ["ERROR: Package #%d does not exist." % id]
- self.api.pullFromQueue(id)
+ self.core.api.pullFromQueue(id)
return ["INFO: Pulled package #%d from queue to collector." % id]
+
def event_c(self, args):
""" captcha answer """
if not args:
@@ -376,6 +402,7 @@ class IRCInterface(Thread, Addon):
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)",
@@ -399,5 +426,6 @@ class IRCError(Exception):
def __init__(self, value):
self.value = value
+
def __str__(self):
return repr(self.value)