home · contact · privacy
Fix crash on server connect error.
[plomlombot-irc.git] / plomlombot.py
index 0012baffd9a94ced7e54a09073fa606466bc8064..80def0db6990eba4dd76fd180529e648cf8c3883 100755 (executable)
@@ -74,8 +74,8 @@ class Log:
         identity = ""
         separator = " > "
         if sent:
         identity = ""
         separator = " > "
         if sent:
-            separator = " "
-            line = Line(line)
+            separator = " "
+            line = Line("< " + line)
             line.sender = self.nickname
             identity = self.username + "@localhost"
         else:
             line.sender = self.nickname
             identity = self.username + "@localhost"
         else:
@@ -118,7 +118,10 @@ class IO:
         self.line_buffer = []
         self.rune_buffer = ""
         self.last_pong = time.time()
         self.line_buffer = []
         self.rune_buffer = ""
         self.last_pong = time.time()
-        self.servername = self.recv_line(send_ping=False).split(" ")[0][1:]
+        line = self.recv_line(send_ping=False)
+        if not line or len(line) < 1:
+            raise ExceptionForRestart
+        self.servername = line.split(" ")[0][1:]
 
     def _pingtest(self, send_ping=True):
         if self.last_pong + self.timeout < time.time():
 
     def _pingtest(self, send_ping=True):
         if self.last_pong + self.timeout < time.time():
@@ -488,7 +491,7 @@ class Session:
                         notice("maximum number of urls to parse per message "
                                "reached")
                         break
                         notice("maximum number of urls to parse per message "
                                "reached")
                         break
-            if "!" == msg[0]:
+            if "!" == msg[0] and len(msg) > 1:
                 tokens = msg[1:].split()
                 argument = str.join(" ", tokens[1:])
                 handle_command(tokens[0], argument, notice, target, self)
                 tokens = msg[1:].split()
                 argument = str.join(" ", tokens[1:])
                 handle_command(tokens[0], argument, notice, target, self)