X-Git-Url: http://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-300.el;h=ad43b24e92e945936ec83ca8817a949a107d170a;hp=21ca8964ef3139d4ba9029991ffff61de0d72fcf;hb=777d22f37f8371dc8dc8108dd7920c934c19f687;hpb=ce31ecd481aadab99d158271dc360dc4d33d8af8 diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 21ca896..ad43b24 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -19,28 +19,31 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Code: (require 'riece-misc) - -(require 'riece-filter) ;riece-default-handle-message +(require 'riece-naming) +(require 'riece-signal) +(require 'riece-display) (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 - "\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") + (concat "^\\([^ ]+\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") (car replies)) (let ((user (match-string 1 (car replies))) (operator (not (null (match-beginning 2)))) @@ -65,7 +68,7 @@ (riece-concat-server-name (riece-concat-user-status status - (format "%s is (%s)" + (format (riece-mcat "%s is (%s)") (riece-format-identity (riece-make-identity user riece-server-name) t) @@ -78,18 +81,21 @@ (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (concat "Online: " + (concat (riece-mcat "Online: ") (mapconcat (lambda (user) (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 "^\\([^ ]+\\) :?") string) (let ((user (match-string 1 string)) (message (substring string (match-end 0)))) (riece-user-toggle-away user t) @@ -100,7 +106,7 @@ (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is away: %s" + (format (riece-mcat "%s is away: %s") (riece-format-identity (riece-make-identity user riece-server-name) t) @@ -123,8 +129,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))) @@ -134,7 +139,7 @@ (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is %s (%s)" + (format (riece-mcat "%s is %s (%s)") (riece-format-identity (riece-make-identity user riece-server-name) t) @@ -144,49 +149,62 @@ (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) (concat (riece-concat-server-name - (format "on via server %s: %s" - riece-real-server-name + (format (riece-mcat "on via server %s: %s") + (match-string 2 string) (substring string (match-end 0)))) "\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) (concat (riece-concat-server-name - (concat (riece-format-identity + (format "%s is an IRC operator" + (riece-format-identity (riece-make-identity user riece-server-name) - t) - " is an IRC operator")) + t))) "\n"))))) (defun riece-handle-317-message (prefix number name string) (if (string-match - (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) [^:]*:seconds") + (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) (riece-mcat "days")) + (cons (mod (/ seconds 60 60) 24) + (riece-mcat "hours")) + (cons (mod (/ seconds 60) 60) (riece-mcat "minutes")) + (cons (mod seconds 60) (riece-mcat "seconds"))))) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is %s seconds idle" + (format (riece-mcat "%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 @@ -214,77 +232,57 @@ "\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 (riece-concat-server-name - (format "%s is running on %s: %s" + (format (riece-mcat "%s is running on %s: %s") (match-string 1 string) (match-string 2 string) (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")))))) - -(defun riece-handle-322-message (prefix number name string) - (if (string-match "^\\([^ ]+\\) \\([0-9]+\\) :" string) + "RPL_NAMREPLY \"[=\*@] :[[@|+] [[@|+] [...]]]\"." + (make-local-variable 'riece-353-message-alist) + (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" 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 channel-identity))) - (riece-insert-info buffer (concat visible " users, topic: " - topic "\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 "%s: %s users, topic: %s" - (riece-format-identity channel-identity t) visible topic)) - "\n")))))) + (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 + (concat (substring string (match-end 0)) " ")) + riece-353-message-alist)))))) + +(defun riece-handle-322-message (prefix number name decoded) + (let* ((parameters (riece-split-parameters (riece-decoded-string decoded))) + (channel (car parameters)) + (visible (nth 1 parameters)) + (channel-identity (riece-make-identity channel riece-server-name)) + (buffer (riece-channel-buffer channel-identity)) + topic) + (setq parameters (riece-split-parameters + (riece-decoded-string-for-identity decoded + channel-identity)) + topic (nth 2 parameters)) + (riece-channel-set-topic (riece-get-channel channel) topic) + (riece-insert-info buffer (format (riece-mcat "%s users, topic: %s\n") + visible topic)) + (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 (riece-mcat "%s: %s users, topic: %s") + (riece-format-identity channel-identity t) visible topic)) + "\n")))) (defun riece-handle-324-message (prefix number name string) (if (string-match "^\\([^ ]+\\) \\([^ ]+\\) " string) @@ -295,7 +293,8 @@ (let* ((channel-identity (riece-make-identity channel riece-server-name)) (buffer (riece-channel-buffer channel-identity))) - (riece-insert-info buffer (concat "Mode: " mode-string "\n")) + (riece-insert-info buffer (concat (riece-mcat "Mode: ") mode-string + "\n")) (riece-insert-info (if (and riece-channel-buffer-mode (not (eq buffer riece-channel-buffer))) @@ -303,36 +302,37 @@ riece-dialogue-buffer) (concat (riece-concat-server-name - (format "Mode for %s: %s" + (format (riece-mcat "Mode for %s: %s") (riece-format-identity channel-identity t) mode-string)) "\n")))))) -(defun riece-handle-set-topic (prefix number name string remove) - (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 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-emit-signal 'channel-topic-changed - channel-identity - (unless remove - message))))) +(defun riece-handle-set-topic (prefix number name decoded remove) + (let* ((parameters (riece-split-parameters (riece-decoded-string decoded))) + (channel (car parameters)) + topic + (channel-identity (riece-make-identity channel riece-server-name)) + (buffer (riece-channel-buffer channel-identity))) + (if remove + (riece-channel-set-topic (riece-get-channel channel) nil) + (setq parameters (riece-split-parameters + (riece-decoded-string-for-identity decoded + channel-identity)) + topic (nth 1 parameters)) + (riece-channel-set-topic (riece-get-channel channel) topic) + (riece-insert-info buffer (concat (riece-mcat "Topic: ") topic "\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 (riece-mcat "Topic for %s: %s") + (riece-format-identity channel-identity t) + topic)) + "\n"))) + (riece-emit-signal 'channel-topic-changed channel-identity topic))) (defun riece-handle-331-message (prefix number name string) (riece-handle-set-topic prefix number name string t)) @@ -342,11 +342,11 @@ (defun riece-handle-341-message (prefix number name string) (if (string-match "^\\([^ ]+\\) " string) - (let* ((channel (match-string 1 string)) - (user (substring string (match-end 0))) + (let* ((channel (substring string (match-end 0))) + (user (match-string 1 string)) (channel-identity (riece-make-identity channel riece-server-name)) (buffer (riece-channel-buffer channel-identity))) - (riece-insert-info buffer (concat "Inviting " user "\n")) + (riece-insert-info buffer (format (riece-mcat "Inviting %s\n") user)) (riece-insert-info (if (and riece-channel-buffer-mode (not (eq buffer riece-channel-buffer))) @@ -354,7 +354,7 @@ riece-dialogue-buffer) (concat (riece-concat-server-name - (format "Inviting %s to %s" user + (format (riece-mcat "Inviting %s to %s") user (riece-format-identity channel-identity t))) "\n"))))) @@ -426,7 +426,55 @@ (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 "\\([@+]\\)?\\([^ ]+\\) +") + 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 (riece-mcat "%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 (riece-mcat "%d users on %s: ") + (length users) + (riece-format-identity channel-identity t)) + string)) + "\n"))))) (provide 'riece-300)