From e78ccdd1d4741d9806ec20f1266ea79916d638fd Mon Sep 17 00:00:00 2001
From: Jeix <devnull@localhost>
Date: Fri, 9 Jul 2010 11:50:46 +0200
Subject: Crypt

---
 module/network/XdccRequest.py        | 49 +++++++++++++++++++++++-------------
 module/plugins/crypter/CryptItCom.py |  9 ++++++-
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/module/network/XdccRequest.py b/module/network/XdccRequest.py
index bf9965eba..a7b3d0e7e 100644
--- a/module/network/XdccRequest.py
+++ b/module/network/XdccRequest.py
@@ -138,7 +138,7 @@ class XdccRequest:
                 raise AbortDownload
         
             if self.dl_time + self.timeout*60 < time.time():
-                raise XDCCError("timout, bot did not answer")
+                raise XDCCError("timeout, bot did not answer")
                 
             #time.sleep(5) # cool down <- was a bullshit idea
             
@@ -161,24 +161,37 @@ class XdccRequest:
                 if first[0] == "ERROR":
                     raise IRCError(line)
                     
-            msg = line.split(None, 3)
-            if len(msg) != 4:
-                continue
+                msg = line.split(None, 3)
+                if len(msg) != 4:
+                    continue
+                    
+                msg = { \
+                    "origin":msg[0][1:], \
+                    "action":msg[1], \
+                    "target":msg[2], \
+                    "text"  :msg[3][1:] \
+                }
                 
-            msg = { \
-                "origin":msg[0][1:], \
-                "action":msg[1], \
-                "target":msg[2], \
-                "text"  :msg[3][1:] \
-            }
-            if not (bot == msg["origin"][0:len(bot)] 
-                and nick == msg["target"][0:len(nick)] 
-                and "PRIVMSG" == msg["action"]):
-                continue
-        
-            m = re.match('\x01DCC SEND (.*?) (.*?) (.*?) (.*?)\x01', msg["text"])
-            if m != None:
-                break
+
+                if nick == msg["target"][0:len(nick)]\
+                    and "PRIVMSG" == msg["action"]:
+                    if msg["text"] == "\x01VERSION\x01":
+                        if self.debug: print "Sending CTCP VERSION."
+                        sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface"))
+                    elif msg["text"] == "\x01TIME\x01":
+                        if self.debug: print "Sending CTCP TIME."
+                        sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time()))
+                    elif msg["text"] == "\x01LAG\x01":
+                        pass # don't know how to answer
+                
+                if not (bot == msg["origin"][0:len(bot)] 
+                    and nick == msg["target"][0:len(nick)] 
+                    and "PRIVMSG" == msg["action"]):
+                    continue
+            
+                m = re.match('\x01DCC SEND (.*?) (.*?) (.*?) (.*?)\x01', msg["text"])
+                if m != None:
+                    break
                 
         # kill IRC socket
         sock.send("QUIT :byebye\r\n")
diff --git a/module/plugins/crypter/CryptItCom.py b/module/plugins/crypter/CryptItCom.py
index fab7625b8..cc9af8dd6 100644
--- a/module/plugins/crypter/CryptItCom.py
+++ b/module/plugins/crypter/CryptItCom.py
@@ -2,6 +2,7 @@
 
 import tempfile
 import re
+from os import remove
 import os.path
 
 from time import time
@@ -22,7 +23,10 @@ class CryptItCom(Crypter):
         self.parent = parent
     
     def file_exists(self):
-        return True
+        html = self.load(self.parent.url)
+        if r'<div class="folder">Was ist Crypt-It</div>' in html):
+            return False
+        return True        
     
     def proceed(self, url, location):
         repl_pattern = r"/(s|e|d|c)/"
@@ -31,6 +35,9 @@ class CryptItCom(Crypter):
         # download ccf
         file_name = os.path.join(tempfile.gettempdir(), "pyload_tmp_%d.ccf"%time())
         file_name = self.req.download(url, file_name)
+        if file_name == "redir.ccf":
+            remove(file_name)
+            raise Exception, _("File not found")
 
         # and it to package
         self.links = [file_name]
-- 
cgit v1.2.3