X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-300.el;h=018144cf15ad4f78a41b46aee0e41fd999884ec4;hp=890da75c6131afc1b8d31c918b3984edd1a900cd;hb=2191bfae45338f2ec08ea9855b7ee756cee01690;hpb=45899e9bcd6a953d26544c9f8785a796ab7c3247 diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 890da75..018144c 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -25,49 +25,54 @@ ;;; Code: (require 'riece-misc) -(require 'riece-commands) - -(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 *( \" \" )\"" - (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 "\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") (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-emit-signal 'user-away-changed + (riece-make-identity user riece-server-name) + away) (riece-user-toggle-operator user operator) + (riece-emit-signal 'user-operator-changed + (riece-make-identity user riece-server-name) + 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) - (force-mode-line-update t))) + (setq replies (cdr replies))))) (defun riece-handle-303-message (prefix number name string) (riece-insert-info @@ -80,15 +85,21 @@ (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) + (riece-emit-signal 'user-away-changed + (riece-make-identity user riece-server-name) + t) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat @@ -98,24 +109,26 @@ (riece-make-identity user riece-server-name) t) message)) - "\n")))) - (riece-update-status-indicators) - (force-mode-line-update t)) + "\n"))))) (defun riece-handle-305-message (prefix number name string) (riece-user-toggle-away riece-real-nickname nil) - (riece-update-status-indicators) - (force-mode-line-update t)) + (riece-emit-signal 'user-away-changed + (riece-make-identity riece-real-nickname + riece-server-name) + nil)) (defun riece-handle-306-message (prefix number name string) (riece-user-toggle-away riece-real-nickname t) - (riece-update-status-indicators) - (force-mode-line-update t)) + (riece-emit-signal 'user-away-changed + (riece-make-identity riece-real-nickname + riece-server-name) + 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))) @@ -135,14 +148,14 @@ (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")))) @@ -161,7 +174,7 @@ (defun riece-handle-317-message (prefix number name string) (if (string-match - (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) :") + (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) ") string) (let ((user (match-string 1 string)) (idle (match-string 2 string))) @@ -177,7 +190,7 @@ "\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 @@ -205,7 +218,7 @@ "\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 @@ -216,39 +229,26 @@ (substring string (match-end 0)))) "\n")))) +(defvar riece-353-string nil) (defun riece-handle-353-message (prefix number name string) - "RPL_NAMREPLY \" :[[@|+] [[@|+] [...]]]\"." - (if (string-match "^[=\*@] *\\([^ ]+\\) +:" string) + "RPL_NAMREPLY \"[=\*@] :[[@|+] [[@|+] [...]]]\"." + (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" string) (let ((channel (match-string 1 string)) - users) - (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))) - (riece-redisplay-buffers)))) + (start 0) + user) + (make-local-variable 'riece-353-string) + (setq riece-353-string (concat riece-353-string + (substring string (match-end 0))))))) (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)))) (riece-channel-set-topic (riece-get-channel channel) topic) (let* ((channel-identity (riece-make-identity channel riece-server-name)) - (buffer (riece-channel-buffer-name channel-identity))) + (buffer (riece-channel-buffer channel-identity))) (riece-insert-info buffer (concat visible " users, topic: " topic "\n")) (riece-insert-info @@ -265,16 +265,12 @@ (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))) + (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-name channel-identity))) + (buffer (riece-channel-buffer channel-identity))) (riece-insert-info buffer (concat "Mode: " mode-string "\n")) (riece-insert-info (if (and riece-channel-buffer-mode @@ -286,32 +282,33 @@ (format "Mode for %s: %s" (riece-format-identity channel-identity t) mode-string)) - "\n"))) - (riece-update-channel-indicator) - (force-mode-line-update t)))) + "\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)) - (buffer (riece-channel-buffer-name channel-identity))) + (buffer (riece-channel-buffer channel-identity))) (if remove (riece-channel-set-topic (riece-get-channel channel) nil) (riece-channel-set-topic (riece-get-channel channel) message) - (riece-insert-info buffer (concat "Topic: " message "\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 "Topic for %s: %s" - (riece-format-identity channel-identity t) - message)) - "\n")) - (riece-update-channel-indicator))))) + (riece-insert-info buffer (concat "Topic: " message "\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 "Topic for %s: %s" + (riece-format-identity channel-identity t) + message)) + "\n"))) + (riece-emit-signal 'channel-topic-changed + channel-identity + (unless remove + message))))) (defun riece-handle-331-message (prefix number name string) (riece-handle-set-topic prefix number name string t)) @@ -324,7 +321,7 @@ (let* ((channel (match-string 1 string)) (user (substring string (match-end 0))) (channel-identity (riece-make-identity channel riece-server-name)) - (buffer (riece-channel-buffer-name channel-identity))) + (buffer (riece-channel-buffer channel-identity))) (riece-insert-info buffer (concat "Inviting " user "\n")) (riece-insert-info (if (and riece-channel-buffer-mode @@ -349,9 +346,9 @@ (flag (match-string 8 string)) (hops (match-string 9 string)) (name (substring string (match-end 0))) - (buffer (riece-channel-buffer-name - (riece-make-identity channel riece-server-name))) - (info (format "%10s = %s (%s) [%s, %s, %s hops, on %s]" + (buffer (riece-channel-buffer (riece-make-identity + channel riece-server-name))) + (info (format "%10s = %s (%s)" (concat (if (memq flag '(?@ ?+)) (char-to-string flag) @@ -361,19 +358,30 @@ 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-emit-signal 'user-away-changed + (riece-make-identity user riece-server-name) + away) (riece-user-toggle-operator user operator) - (riece-insert-info buffer (concat info "\n")) + (riece-emit-signal 'user-operator-changed + (riece-make-identity user riece-server-name) + operator) + (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))) @@ -381,19 +389,64 @@ riece-dialogue-buffer) (concat (riece-concat-server-name - (concat - (riece-format-identity - (riece-make-identity channel riece-server-name) - t) - " " - info)) - "\n")) - (riece-redisplay-buffers)))) + (riece-concat-user-status + status + (concat + (riece-format-identity + (riece-make-identity channel riece-server-name) + t) + " " + info))) + "\n"))))) (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 \" :End of NAMES list\"" + (if (string-match "^\\([^ ]+\\) " string) + (let* ((channel (match-string 1 string)) + (channel-identity (riece-make-identity channel + riece-server-name)) + (buffer (riece-channel-buffer channel-identity)) + (string (copy-sequence riece-353-string)) + (start 0) + users) + (setq riece-353-string nil) + (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) + users (cons (if (match-beginning 1) + (if (eq (aref string (match-beginning 1)) ?@) + (list (match-string 2 string) ?o) + (if (eq (aref string (match-beginning 1)) ?+) + (list (match-string 2 string) ?v))) + (list (match-string 2 string))) + users))) + (setq users (nreverse users)) + (riece-naming-assert-channel-users users channel) + (riece-insert-info + buffer + (concat (format "%d users: " (length 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 + (concat (format "%d users on %s: " + (length users) + (riece-format-identity channel-identity t)) + string)) + "\n"))))) (provide 'riece-300)