X-Git-Url: http://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-300.el;h=be0a7842d94290d58a3abd3236bd15505efc3b57;hp=018144cf15ad4f78a41b46aee0e41fd999884ec4;hb=d954ccb1c05c0f3d762f795110466b05fea9917c;hpb=2191bfae45338f2ec08ea9855b7ee756cee01690 diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 018144c..be0a784 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -25,6 +25,8 @@ ;;; Code: (require 'riece-misc) +(require 'riece-naming) +(require 'riece-signal) (eval-when-compile (autoload 'riece-default-handle-numeric-reply "riece-handle")) @@ -40,8 +42,7 @@ " "))) (while replies (if (string-match - (concat "^\\(" riece-user-regexp - "\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") + (concat "^\\([^ ]+\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") (car replies)) (let ((user (match-string 1 (car replies))) (operator (not (null (match-beginning 2)))) @@ -93,7 +94,7 @@ "\n"))) (defun riece-handle-301-message (prefix number name string) - (if (string-match (concat "^\\(" riece-user-regexp "\\) :?") string) + (if (string-match (concat "^\\([^ ]+\\) :?") string) (let ((user (match-string 1 string)) (message (substring string (match-end 0)))) (riece-user-toggle-away user t) @@ -127,8 +128,7 @@ (defun riece-handle-311-message (prefix number name string) (if (string-match - (concat "^\\(" riece-user-regexp - "\\) \\([^ ]+\\) \\([^ ]+\\) \\* :?") + (concat "^\\([^ ]+\\) \\([^ ]+\\) \\([^ ]+\\) \\* :?") string) (let ((user (match-string 1 string)) (name (substring string (match-end 0))) @@ -148,7 +148,7 @@ (defun riece-handle-312-message (prefix number name string) (if (string-match - (concat "^\\(" riece-user-regexp "\\) \\([^ ]+\\) :?") + (concat "^\\([^ ]+\\) \\([^ ]+\\) :?") string) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) @@ -160,7 +160,7 @@ "\n")))) (defun riece-handle-313-message (prefix number name string) - (if (string-match (concat "^" riece-user-regexp) string) + (if (string-match "^[^ ]+" string) (let ((user (match-string 0 string))) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) @@ -174,23 +174,35 @@ (defun riece-handle-317-message (prefix number name string) (if (string-match - (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) ") + (concat "^\\([^ ]+\\) \\([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 "^\\([^ ]+\\) :?") string) (let ((user (match-string 1 string)) (channels (mapconcat @@ -229,16 +241,20 @@ (substring string (match-end 0)))) "\n")))) -(defvar riece-353-string nil) +(defvar riece-353-message-alist nil) (defun riece-handle-353-message (prefix number name string) "RPL_NAMREPLY \"[=\*@] :[[@|+] [[@|+] [...]]]\"." + (make-local-variable 'riece-353-message-alist) (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" string) - (let ((channel (match-string 1 string)) - (start 0) - user) - (make-local-variable 'riece-353-string) - (setq riece-353-string (concat riece-353-string - (substring string (match-end 0))))))) + (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) @@ -410,12 +426,15 @@ (channel-identity (riece-make-identity channel riece-server-name)) (buffer (riece-channel-buffer channel-identity)) - (string (copy-sequence riece-353-string)) + (entry (riece-identity-assoc channel riece-353-message-alist t)) + (string (cdr entry)) (start 0) users) - (setq riece-353-string nil) + (if entry + (setq riece-353-message-alist + (delq entry riece-353-message-alist))) (while (string-match - (concat "\\([@+]\\)?\\(" riece-user-regexp "\\) *") + (concat "\\([@+]\\)?\\([^ ]+\\) *") string start) (put-text-property (match-beginning 2) (match-end 2) 'riece-identity