* mixi.el (mixi-post-message-page): New macro.
authorbg66 <bg66>
Wed, 27 Dec 2006 09:31:25 +0000 (09:31 +0000)
committerbg66 <bg66>
Wed, 27 Dec 2006 09:31:25 +0000 (09:31 +0000)
(mixi-post-message-key-regexp): New constant.
(mixi-post-message-succeed-regexp): Ditto.
(mixi-post-message): New function.

ChangeLog
mixi.el

index 0af3916..41eaa79 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2006-12-27  OHASHI Akira  <bg66@koka-in.org>
 
+       * mixi.el (mixi-post-message-page): New macro.
+       (mixi-post-message-key-regexp): New constant.
+       (mixi-post-message-succeed-regexp): Ditto.
+       (mixi-post-message): New function.
+
+2006-12-27  OHASHI Akira  <bg66@koka-in.org>
+
        * mixi.el (mixi-post-diary-id-regexp): Abolish.
        (mixi-post-diary-title-regexp): Ditto.
        (mixi-post-diary-body-regexp): Ditto.
diff --git a/mixi.el b/mixi.el
index 81ac4a7..587def2 100644 (file)
--- a/mixi.el
+++ b/mixi.el
@@ -47,6 +47,7 @@
 ;;  * mixi-post-diary
 ;;  * mixi-post-topic
 ;;  * mixi-post-comment
+;;  * mixi-post-message
 ;; 
 ;; Utilities:
 ;;
@@ -2414,6 +2415,40 @@ Increase this value when unexpected error frequently occurs."
                (mixi-make-message (nth 0 item) (nth 1 item)))
              items))))
 
+(defmacro mixi-post-message-page (friend)
+  `(concat "/send_message.pl?id=" (mixi-friend-id friend)))
+
+(defconst mixi-post-message-key-regexp
+  "<input name=post_key type=hidden value=\\([a-z0-9]+\\)>")
+
+(defconst mixi-post-message-succeed-regexp
+  "<b>Á÷¿®´°Î»</b>¤·¤Þ¤·¤¿¡£")
+
+(defun mixi-post-message (friend title content)
+  "Post a message to FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (unless (stringp title)
+    (signal 'wrong-type-argument (list 'stringp title)))
+  (unless (stringp content)
+    (signal 'wrong-type-argument (list 'stringp content)))
+  (let ((fields `(("subject" . ,title)
+                 ("body" . ,content)
+                 ("submit" . "main")))
+       post-key)
+    (with-mixi-post-form (mixi-post-message-page friend) fields
+      (if (string-match mixi-post-message-key-regexp buffer)
+         (setq post-key (match-string 1 buffer))
+       (mixi-post-error 'cannot-find-key friend)))
+    (setq fields `(("post_key" . ,post-key)
+                  ("subject" . ,title)
+                  ("body" . ,content)
+                  ("yes" . "¡¡Á÷¡¡¿®¡¡")
+                  ("submit" . "confirm")))
+    (with-mixi-post-form (mixi-post-message-page friend) fields
+      (unless (string-match mixi-post-message-succeed-regexp buffer)
+       (mixi-post-error 'cannot-find-succeed friend)))))
+
 ;; Introduction object.
 (defun mixi-make-introduction (parent owner content)
   "Return a introduction object."