X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-300.el;h=52f7eba4c933c075a9e39a76be3682ecd7d31a4a;hp=5f1383e197fbed54da9df99aa7237a8b7cffdcae;hb=78ac843e1969cc20beb6ad959d207e5ec7cea499;hpb=520905ec721b2dc580d32d4a062bf3c45224e6b1 diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 5f1383e..52f7eba 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -34,7 +34,10 @@ (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 @@ -82,12 +85,15 @@ (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) @@ -122,7 +128,7 @@ (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))) @@ -142,7 +148,7 @@ (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) @@ -168,23 +174,35 @@ (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))) + (let* ((user (match-string 1 string)) + (seconds (string-to-number (match-string 2 string))) + (units (list (cons (/ seconds 60 60 24) "days") + (cons (mod (/ seconds 60 60) 24) "hours") + (cons (mod (/ seconds 60) 60) "minutes") + (cons (mod seconds 60) "seconds")))) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is %s seconds idle" + (format "%s is %s idle" (riece-format-identity (riece-make-identity user riece-server-name) t) - idle)) + (mapconcat #'identity + (delq nil + (mapcar + (lambda (unit) + (if (/= (car unit) 0) + (format "%d %s" + (car unit) (cdr unit)))) + units)) + ", "))) "\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 @@ -212,7 +230,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 @@ -223,47 +241,23 @@ (substring string (match-end 0)))) "\n")))) +(defvar riece-353-message-alist nil) (defun riece-handle-353-message (prefix number name string) - "RPL_NAMREPLY \" :[[@|+] [[@|+] [...]]]\"." - (if (string-match "^[=\*@] *\\([^ ]+\\) +:" string) - (let ((channel (match-string 1 string)) - (start 0) - user users) - (setq string (substring string (match-end 0))) - (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) - user (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 (cons user users))) - (riece-naming-assert-channel-users (nreverse users) 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")))))) + "RPL_NAMREPLY \"[=\*@] :[[@|+] [[@|+] [...]]]\"." + (make-local-variable 'riece-353-message-alist) + (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" string) + (let* ((channel (match-string 1 string)) + (entry (riece-identity-assoc channel riece-353-message-alist t))) + (if entry + (setcdr entry + (concat (cdr entry) + (substring string (match-end 0)))) + (setq riece-353-message-alist + (cons (cons channel (substring string (match-end 0))) + riece-353-message-alist)))))) (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)))) @@ -307,7 +301,7 @@ "\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)) @@ -424,7 +418,54 @@ (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)) + (entry (riece-identity-assoc channel riece-353-message-alist t)) + (string (cdr entry)) + (start 0) + users) + (if entry + (setq riece-353-message-alist + (delq entry riece-353-message-alist))) + (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)