Browse Source

Correction: privmsg and rawsend must be unicode aware.

Jadjay 8 years ago
parent
commit
c8bd6830ee
1 changed files with 7 additions and 7 deletions
  1. 7 7
      irclib.py

+ 7 - 7
irclib.py View File

763
     def privmsg(self, target, text):
763
     def privmsg(self, target, text):
764
         """Send a PRIVMSG command."""
764
         """Send a PRIVMSG command."""
765
         # Should limit len(text) here!
765
         # Should limit len(text) here!
766
-        self.send_raw("PRIVMSG %s :%s" % (target, text))
766
+        self.send_raw(u'PRIVMSG %s :%s' % (target, text))
767
 
767
 
768
     def privmsg_many(self, targets, text):
768
     def privmsg_many(self, targets, text):
769
         """Send a PRIVMSG command to multiple targets."""
769
         """Send a PRIVMSG command to multiple targets."""
770
         # Should limit len(text) here!
770
         # Should limit len(text) here!
771
-        self.send_raw("PRIVMSG %s :%s" % (",".join(targets), text))
771
+        self.send_raw(u'PRIVMSG %s :%s' % (','.join(targets), text))
772
 
772
 
773
     def quit(self, message=""):
773
     def quit(self, message=""):
774
         """Send a QUIT command."""
774
         """Send a QUIT command."""
782
         The string will be padded with appropriate CR LF.
782
         The string will be padded with appropriate CR LF.
783
         """
783
         """
784
         if self.socket is None:
784
         if self.socket is None:
785
-            raise ServerNotConnectedError, "Not connected."
785
+            raise ServerNotConnectedError, u'Not connected.'
786
         try:
786
         try:
787
             if self.ssl:
787
             if self.ssl:
788
-                self.ssl.write(string + "\r\n")
788
+                self.ssl.write(string + u'\r\n')
789
             else:
789
             else:
790
-                self.socket.send(string + "\r\n")
790
+                self.socket.send(string + u'\r\n')
791
             if DEBUG:
791
             if DEBUG:
792
-                print "TO SERVER:", string
792
+                print u'TO SERVER:', string
793
         except socket.error, x:
793
         except socket.error, x:
794
             # Ouch!
794
             # Ouch!
795
-            self.disconnect("Connection reset by peer.")
795
+            self.disconnect(u'Connection reset by peer.')
796
 
796
 
797
     def squit(self, server, comment=""):
797
     def squit(self, server, comment=""):
798
         """Send an SQUIT command."""
798
         """Send an SQUIT command."""