Add some require's to suppress compile warning.
[riece] / lisp / riece-300.el
index dd33c6d..be0a784 100644 (file)
@@ -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)
 
 (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)))
 
 (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)
        "\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)
 
 (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
   (make-local-variable 'riece-353-message-alist)      
   (if (string-match "^[=\*@] *\\([^ ]+\\) +:?" string)
       (let* ((channel (match-string 1 string))
-            (entry (assoc channel riece-353-message-alist)))
+            (entry (riece-identity-assoc channel riece-353-message-alist t)))
        (if entry
            (setcdr entry
                    (concat (cdr entry)
             (channel-identity (riece-make-identity channel
                                                    riece-server-name))
             (buffer (riece-channel-buffer channel-identity))
-            (entry (assoc channel riece-353-message-alist))
+            (entry (riece-identity-assoc channel riece-353-message-alist t))
             (string (cdr entry))
             (start 0)
             users)
        (if entry
-           (setcdr entry nil))
+           (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