Fix the last change.
[riece] / lisp / riece-300.el
index a44fa17..cb22cf8 100644 (file)
                   "\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)")
           (car replies))
          (let ((user (match-string 1 (car replies)))
+               (operator (not (null (match-beginning 2))))
                (away (eq (match-string 3 (car replies)) ?-))
                (user-at-host (match-string 4 (car replies)))
-               (operator (not (null (match-beginning 2)))))
+               status)
+           (if away
+               (setq status (cons "away" status)))
+           (if operator
+               (setq status (cons "operator" status)))
            (riece-user-toggle-away user away)
            (riece-user-toggle-operator user operator)
            (riece-insert-info
             (list riece-dialogue-buffer riece-others-buffer)
             (concat
              (riece-concat-server-name
-              (format "%s is (%s) [%s, %s]"
-                      (riece-format-identity
-                       (riece-make-identity user riece-server-name)
-                       t)
-                      (riece-strip-user-at-host user-at-host)
-                      (if operator
-                          "operator"
-                        "not operator")
-                      (if away
-                          "away"
-                        "not away")))
+              (riece-concat-user-status
+               status
+               (format "%s is (%s)"
+                       (riece-format-identity
+                        (riece-make-identity user riece-server-name)
+                        t)
+                       (riece-strip-user-at-host user-at-host))))
              "\n"))))
       (setq replies (cdr replies)))
   (riece-update-status-indicators)
   "RPL_NAMREPLY        \"<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]\"."
   (if (string-match "^[=\*@] *\\([^ ]+\\) +:" string)
       (let ((channel (match-string 1 string))
-           users)
+           (start 0))
        (setq string (substring string (match-end 0)))
-       (if (string-match " *$" string)
-           (setq string (substring string 0 (match-beginning 0))))
-       (setq users (split-string string))
-       (while users
-         (if (eq (aref (car users) 0) ?@)
-             (progn
-               (riece-naming-assert-join (substring (car users) 1) channel)
-               (riece-channel-toggle-operator
-                channel (substring (car users) 1) t))
-           (if (eq (aref (car users) 0) ?+)
-               (progn
-                 (riece-naming-assert-join (substring (car users) 1) channel)
-                 (riece-channel-toggle-speaker
-                  channel (substring (car users) 1) t))
-             (riece-naming-assert-join (car users) channel)))
-         (setq users (cdr users)))
+       (while (string-match
+               (concat "\\([@+]\\)?\\(" riece-user-regexp "\\) *")
+               string start)
+         (put-text-property (match-beginning 2) (match-end 2)
+                            'riece-identity
+                            (riece-make-identity (match-string 2 string)
+                                                 riece-server-name)
+                            string)
+         (setq start (match-end 0))
+         (if (match-beginning 1)
+             (if (eq (aref string (match-beginning 1)) ?@)
+                 (progn
+                   (riece-naming-assert-join
+                    (match-string 2 string) channel)
+                   (riece-channel-toggle-operator
+                    channel (match-string 2 string) t))
+               (if (eq (aref string (match-beginning 1)) ?+)
+                   (progn
+                     (riece-naming-assert-join
+                      (match-string 2 string) channel)
+                     (riece-channel-toggle-speaker
+                      channel (match-string 2 string) t))))
+           (riece-naming-assert-join (match-string 2 string) channel)))
+       (let* ((channel-identity (riece-make-identity channel
+                                                     riece-server-name))
+              (buffer (riece-channel-buffer channel-identity)))
+         (riece-insert-info buffer (concat "Users: " string "\n"))
+         (riece-insert-info
+          (if (and riece-channel-buffer-mode
+                   (not (eq buffer riece-channel-buffer)))
+              (list riece-dialogue-buffer riece-others-buffer)
+            riece-dialogue-buffer)
+          (concat
+           (riece-concat-server-name
+            (format "Users on %s: %s"
+                    (riece-format-identity channel-identity t) string))
+           "\n")))
        (riece-redisplay-buffers))))
 
 (defun riece-handle-322-message (prefix number name string)
             (name (substring string (match-end 0)))
             (buffer (riece-channel-buffer (riece-make-identity
                                            channel riece-server-name)))
-            (info (format "%10s = %s (%s) [%s, %s, %s hops, on %s]"
+            (info (format "%10s = %s (%s)"
                           (concat
                            (if (memq flag '(?@ ?+))
                                (char-to-string flag)
                             t))
                           name
                           (riece-strip-user-at-host
-                           (concat user "@" host))
-                          (if operator
-                              "operator"
-                            "not operator")
-                          (if away
-                              "away"
-                            "not away")
-                          hops
-                          server)))
+                           (concat user "@" host))))
+            status)
+       (if operator
+           (setq status (cons "operator" status)))
+       (if away
+           (setq status (cons "away" status)))
+       (unless (equal hops "0")
+         (setq status (cons (concat "on " server)
+                            (cons (concat hops " hops")
+                                  status))))
+       (if status
+           (setq status (nreverse status)))
        (riece-naming-assert-join nick channel)
        (riece-user-toggle-away user away)
        (riece-user-toggle-operator user operator)
-       (riece-insert-info buffer (concat info "\n"))
+       (riece-insert-info buffer (concat (riece-concat-user-status
+                                          status info)
+                                         "\n"))
        (riece-insert-info
         (if (and riece-channel-buffer-mode
                  (not (eq buffer riece-channel-buffer)))
           riece-dialogue-buffer)
         (concat
          (riece-concat-server-name
-          (concat
-           (riece-format-identity
-            (riece-make-identity channel riece-server-name)
-            t)
-           " "
-           info))
+          (riece-concat-user-status
+           status
+           (concat
+            (riece-format-identity
+             (riece-make-identity channel riece-server-name)
+             t)
+            " "
+            info)))
          "\n"))
        (riece-redisplay-buffers))))