* riece-irc.el (riece-irc-open-server): Send USER command with
[riece] / lisp / riece-irc.el
index f44e199..faa4c56 100644 (file)
       (if (equal server-name "")
          (message "Connecting to IRC server...")
        (message "Connecting to %s..." server-name))
-      (setq process
-           (funcall function (riece-server-process-name server-name)
-                    (concat " *IRC*" server-name)
-                    host service))
+      (condition-case error
+         (setq process
+               (funcall function (riece-server-process-name server-name)
+                        (concat " *IRC*" server-name)
+                        host service))
+       (error
+        (if (equal server-name "")
+            (message "Connecting to IRC server...failed: %S" error)
+          (message "Connecting to %s...failed: %S" server-name error))
+        (signal (car error) (cdr error))))
       (if (equal server-name "")
          (message "Connecting to IRC server...done")
        (message "Connecting to %s...done" server-name))
                                       (format "PASS %s\r\n" password)))
        (riece-process-send-string process
                                   (format "USER %s * * :%s\r\n"
-                                          (user-real-login-name)
-                                          (or username
+                                          (if (and username
+                                                   (not (string-match
+                                                         "[^\0\r\n @]"
+                                                         username)))
+                                              username
+                                            (user-real-login-name))
+                                          (or realname
+                                              username
                                               "No information given")))
        (riece-process-send-string process (format "NICK %s\r\n" nickname))
        (with-current-buffer (process-buffer process)