* riece-menu.el (riece-menu-items): Add "Next Channel" and
[riece] / lisp / riece-300.el
index 034e9c0..9c528a2 100644 (file)
 
 (require 'riece-misc)
 
-(require 'riece-filter)                        ;riece-default-handle-message
-
 (eval-when-compile
-  (autoload 'riece-default-handle-numeric-reply "riece-filter"))
+  (autoload 'riece-default-handle-numeric-reply "riece-handle"))
 (defun riece-handle-default-300-message (prefix number name string)
   (riece-default-handle-numeric-reply
    riece-info-prefix prefix number name string))
 
 (defun riece-handle-302-message (prefix number name string)
   "RPL_USERHOST \":*1<reply> *( \" \" <reply> )\""
-  (let ((replies (split-string (substring string 1) " ")))
+  (let ((replies (split-string (if (eq (aref string 0) ?:)
+                                  (substring string 1)
+                                string)
+                              " ")))
     (while replies
       (if (string-match
           (concat "^\\(" riece-user-regexp
                (riece-format-identity
                 (riece-make-identity user riece-server-name)
                 t))
-             (split-string (substring string 1) " ")
+             (split-string (if (eq (aref string 0) ?:)
+                               (substring string 1)
+                             string)
+                           " ")
              "")))
     "\n")))
 
 (defun riece-handle-301-message (prefix number name string)
-  (if (string-match (concat "^\\(" riece-user-regexp "\\) :") string)
+  (if (string-match (concat "^\\(" riece-user-regexp "\\) :?") string)
       (let ((user (match-string 1 string))
            (message (substring string (match-end 0))))
        (riece-user-toggle-away user t)
 (defun riece-handle-311-message (prefix number name string)
   (if (string-match
        (concat "^\\(" riece-user-regexp
-              "\\) \\([^ ]+\\) \\([^ ]+\\) \\* :")
+              "\\) \\([^ ]+\\) \\([^ ]+\\) \\* :?")
        string)
       (let ((user (match-string 1 string))
            (name (substring string (match-end 0)))
 
 (defun riece-handle-312-message (prefix number name string)
   (if (string-match
-       (concat "^\\(" riece-user-regexp "\\) \\([^ ]+\\) :")
+       (concat "^\\(" riece-user-regexp "\\) \\([^ ]+\\) :?")
        string)
       (riece-insert-info
        (list riece-dialogue-buffer riece-others-buffer)
        (concat
        (riece-concat-server-name
         (format "on via server %s: %s"
-                riece-real-server-name
+                (match-string 2 string)
                 (substring string (match-end 0))))
        "\n"))))
 
 
 (defun riece-handle-317-message (prefix number name string)
   (if (string-match
-       (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) [^:]*:seconds")
+       (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) ")
        string)
       (let ((user (match-string 1 string))
            (idle (match-string 2 string)))
          "\n")))))
 
 (defun riece-handle-319-message (prefix number name string)
-  (if (string-match (concat "^\\(" riece-user-regexp "\\) :") string)
+  (if (string-match (concat "^\\(" riece-user-regexp "\\) :?") string)
       (let ((user (match-string 1 string))
            (channels
             (mapconcat
          "\n")))))
 
 (defun riece-handle-351-message (prefix number name string)
-  (if (string-match "\\([^ ]+\\.[^ ]+\\) \\([^ ]+\\) :" string)
+  (if (string-match "\\([^ ]+\\.[^ ]+\\) \\([^ ]+\\) :?" string)
       (riece-insert-info
        (list riece-dialogue-buffer riece-others-buffer)
        (concat
                 (substring string (match-end 0))))
        "\n"))))
 
+(defvar riece-353-users nil)
 (defun riece-handle-353-message (prefix number name string)
-  "RPL_NAMREPLY        \"<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]\"."
-  (if (string-match "^[=\*@] *\\([^ ]+\\) +:" string)
+  "RPL_NAMREPLY        \"[=\*@] <channel> :[[@|+]<nick> [[@|+]<nick> [...]]]\"."
+  (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" string)
       (let ((channel (match-string 1 string))
            (start 0)
-           user users)
+           user)
+       (make-local-variable 'riece-353-users)
        (setq string (substring string (match-end 0)))
        (while (string-match
                (concat "\\([@+]\\)?\\(" riece-user-regexp "\\) *")
                           (if (eq (aref string (match-beginning 1)) ?+)
                               (list (match-string 2 string) ?v)))
                       (list (match-string 2 string)))
-               users (cons user users)))
-       (riece-naming-assert-channel-users (nreverse users) channel)
+               riece-353-users (cons user riece-353-users)))
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
               (buffer (riece-channel-buffer channel-identity)))
            "\n"))))))
 
 (defun riece-handle-322-message (prefix number name string)
-  (if (string-match "^\\([^ ]+\\) \\([0-9]+\\) :" string)
+  (if (string-match "^\\([^ ]+\\) \\([0-9]+\\) :?" string)
       (let* ((channel (match-string 1 string))
             (visible (match-string 2 string))
             (topic (substring string (match-end 0))))
 (defun riece-handle-324-message (prefix number name string)
   (if (string-match "^\\([^ ]+\\) \\([^ ]+\\) " string)
       (let* ((channel (match-string 1 string))
-            (mode-string (substring string (match-beginning 2)))
-            (modes (string-to-list (match-string 2 string)))
-            (toggle (car modes)))
-       (setq modes (cdr modes))
-       (while modes
-         (riece-channel-toggle-mode channel (car modes) (eq toggle ?+))
-         (setq modes (cdr modes)))
-       (riece-emit-signal 'channel-modes-changed
-                          (riece-make-identity channel riece-server-name)
-                          modes (eq toggle ?+))
+            (mode-string (match-string 2 string)))
+       (riece-naming-assert-channel-modes channel
+                                          (riece-parse-modes mode-string))
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
               (buffer (riece-channel-buffer channel-identity)))
            "\n"))))))
 
 (defun riece-handle-set-topic (prefix number name string remove)
-  (if (string-match "^\\([^ ]+\\) :" string)
+  (if (string-match "^\\([^ ]+\\) :?" string)
       (let* ((channel (match-string 1 string))
             (message (substring string (match-end 0)))
             (channel-identity (riece-make-identity channel riece-server-name))
 (defun riece-handle-315-message (prefix number name string))
 (defun riece-handle-318-message (prefix number name string))
 (defun riece-handle-323-message (prefix number name string))
-(defun riece-handle-366-message (prefix number name string))
+
+(defun riece-handle-366-message (prefix number name string)
+  "RPL_ENDOFNAMES \"<channel> :End of NAMES list\""
+  (if (string-match "^\\([^ ]+\\) " string)
+      (let ((channel (match-string 1 string)))
+       (riece-naming-assert-channel-users (nreverse riece-353-users)
+                                          channel)))
+  (setq riece-353-users nil))
 
 (provide 'riece-300)