+\\(.*\\)")
(defconst mixi-community-category-regexp
- " | ¥«¥Æ¥´¥ê |
-\\([^<]+\\) | ")
+ "¥«¥Æ¥´¥ê |
+\\([^<]+\\) | ")
(defconst mixi-community-members-regexp
- "¥á¥ó¥Ð¡¼¿ô |
-\\([0-9]+\\)¿Í |
")
+ "¥á¥ó¥Ð¡¼¿ô |
+\\([0-9]+\\)¿Í | ")
(defconst mixi-community-open-level-regexp
- "»²²Ã¾ò·ï¤È ¸ø³«¥ì¥Ù¥ë |
-\\(.+\\) | ")
+ "»²²Ã¾ò·ï¤È ¸ø³«¥ì¥Ù¥ë |
+\\(.+\\) | ")
(defconst mixi-community-authority-regexp
- "¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â |
-\\(.+\\) | ")
+ "¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â |
+\\(.+\\) | ")
(defconst mixi-community-description-regexp
- "\\(.+\\) | ")
+ "\\(.+\\) | ")
-(defun mixi-community-realize (community)
+(defun mixi-realize-community (community)
"Realize a COMMUNITY."
;; FIXME: Check a expiration of cache?
- (unless (mixi-object-realize-p community)
+ (unless (mixi-object-realized-p community)
(with-mixi-retrieve (mixi-community-page community)
(if (string-match mixi-community-nodata-regexp buffer)
;; FIXME: Set all members?
(mixi-community-set-name community "¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
(if (string-match mixi-community-name-regexp buffer)
(mixi-community-set-name community (match-string 1 buffer))
- (signal 'error (list 'cannot-find-name community)))
+ (mixi-realization-error 'cannot-find-name community))
(if (string-match mixi-community-birthday-regexp buffer)
(mixi-community-set-birthday
community
(encode-time 0 0 0 (string-to-number (match-string 3 buffer))
(string-to-number (match-string 2 buffer))
(string-to-number (match-string 1 buffer))))
- (signal 'error (list 'cannot-find-birthday community)))
+ (mixi-realization-error 'cannot-find-birthday community))
(if (string-match mixi-community-owner-regexp buffer)
(if (string= (match-string 1 buffer) "home.pl")
(mixi-community-set-owner community (mixi-make-me))
(mixi-community-set-owner
community (mixi-make-friend (match-string 2 buffer)
(match-string 3 buffer))))
- (signal 'error (list 'cannot-find-owner community)))
+ (mixi-realization-error 'cannot-find-owner community))
(if (string-match mixi-community-category-regexp buffer)
(mixi-community-set-category community (match-string 1 buffer))
- (signal 'error (list 'cannot-find-category community)))
+ (mixi-realization-error 'cannot-find-category community))
(if (string-match mixi-community-members-regexp buffer)
(mixi-community-set-members
community (string-to-number (match-string 1 buffer)))
- (signal 'error (list 'cannot-find-members community)))
+ (mixi-realization-error 'cannot-find-members community))
(if (string-match mixi-community-open-level-regexp buffer)
(mixi-community-set-open-level community (match-string 1 buffer))
- (signal 'error (list 'cannot-find-open-level community)))
+ (mixi-realization-error 'cannot-find-open-level community))
(if (string-match mixi-community-authority-regexp buffer)
(mixi-community-set-authority community (match-string 1 buffer))
- (signal 'error (list 'cannot-find-authority community)))
+ (mixi-realization-error 'cannot-find-authority community))
(if (string-match mixi-community-description-regexp buffer)
(mixi-community-set-description community (match-string 1 buffer))
- (signal 'error (list 'cannot-find-description community)))))
+ (mixi-realization-error 'cannot-find-description community))))
(mixi-object-touch community)))
(defun mixi-community-id (community)
@@ -1293,56 +1458,56 @@ Increase this value when unexpected error frequently occurs."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
(unless (aref (cdr community) 2)
- (mixi-community-realize community))
+ (mixi-realize-community community))
(aref (cdr community) 2))
(defun mixi-community-birthday (community)
"Return the birthday of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 3))
(defun mixi-community-owner (community)
"Return the owner of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 4))
(defun mixi-community-category (community)
"Return the category of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 5))
(defun mixi-community-members (community)
"Return the members of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 6))
(defun mixi-community-open-level (community)
"Return the open-level of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 7))
(defun mixi-community-authority (community)
"Return the authority of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 8))
(defun mixi-community-description (community)
"Return the description of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (mixi-community-realize community)
+ (mixi-realize-community community)
(aref (cdr community) 9))
(defun mixi-community-set-name (community name)
@@ -1404,16 +1569,16 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-community-list-name-regexp
"\\(.+\\)([0-9]+) | ")
-(defun mixi-get-communities (&rest args)
+(defun mixi-get-communities (&rest friend-or-range)
"Get communities of FRIEND."
- (when (> (length args) 2)
+ (when (> (length friend-or-range) 2)
(signal 'wrong-number-of-arguments
- (list 'mixi-get-communities (length args))))
- (let ((friend (nth 0 args))
- (range (nth 1 args)))
+ (list 'mixi-get-communities (length friend-or-range))))
+ (let ((friend (nth 0 friend-or-range))
+ (range (nth 1 friend-or-range)))
(when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
- (setq friend (nth 1 args))
- (setq range (nth 0 args)))
+ (setq friend (nth 1 friend-or-range))
+ (setq range (nth 0 friend-or-range)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let ((ids (mixi-get-matched-items (mixi-community-list-page friend)
@@ -1432,7 +1597,7 @@ Increase this value when unexpected error frequently occurs."
(defmacro mixi-search-community-list-page (keyword)
`(concat "/search_community.pl?page=%d&&sort=date&type=com&submit=main"
- "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
+ "&keyword=" (mixi-url-encode-and-quote-percent-string ,keyword)
"&category_id=0"))
(defconst mixi-search-community-list-regexp
@@ -1485,17 +1650,17 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-topic-owner-regexp
" \\(.*?\\)\\(¤µ¤ó\\)?")
(defconst mixi-topic-content-regexp
- "\\( | \n\\)* \\(.+\\) | ")
+ "\\( | \n\\)* \\(.+\\) | ")
-(defun mixi-topic-realize (topic)
+(defun mixi-realize-topic (topic)
"Realize a TOPIC."
;; FIXME: Check a expiration of cache?
- (unless (mixi-object-realize-p topic)
+ (unless (mixi-object-realized-p topic)
(with-mixi-retrieve (mixi-topic-page topic)
(if (string-match mixi-topic-community-regexp buffer)
(mixi-community-set-name (mixi-topic-community topic)
(match-string 1 buffer))
- (signal 'error (list 'cannot-find-community topic)))
+ (mixi-realization-error 'cannot-find-community topic))
(if (string-match mixi-topic-time-regexp buffer)
(mixi-topic-set-time
topic (encode-time 0 (string-to-number (match-string 5 buffer))
@@ -1503,18 +1668,18 @@ Increase this value when unexpected error frequently occurs."
(string-to-number (match-string 3 buffer))
(string-to-number (match-string 2 buffer))
(string-to-number (match-string 1 buffer))))
- (signal 'error (list 'cannot-find-time topic)))
+ (mixi-realization-error 'cannot-find-time topic))
(if (string-match mixi-topic-title-regexp buffer)
(mixi-topic-set-title topic (match-string 1 buffer))
- (signal 'error (list 'cannot-find-title topic)))
+ (mixi-realization-error 'cannot-find-title topic))
(if (string-match mixi-topic-owner-regexp buffer)
(mixi-topic-set-owner topic
(mixi-make-friend (match-string 1 buffer)
(match-string 2 buffer)))
- (signal 'error (list 'cannot-find-owner topic)))
+ (mixi-realization-error 'cannot-find-owner topic))
(if (string-match mixi-topic-content-regexp buffer)
(mixi-topic-set-content topic (match-string 2 buffer))
- (signal 'error (list 'cannot-find-content topic))))
+ (mixi-realization-error 'cannot-find-content topic)))
(mixi-object-touch topic)))
(defun mixi-topic-community (topic)
@@ -1533,28 +1698,28 @@ Increase this value when unexpected error frequently occurs."
"Return the time of TOPIC."
(unless (mixi-topic-p topic)
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
- (mixi-topic-realize topic)
+ (mixi-realize-topic topic)
(aref (cdr topic) 3))
(defun mixi-topic-title (topic)
"Return the title of TOPIC."
(unless (mixi-topic-p topic)
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
- (mixi-topic-realize topic)
+ (mixi-realize-topic topic)
(aref (cdr topic) 4))
(defun mixi-topic-owner (topic)
"Return the owner of TOPIC."
(unless (mixi-topic-p topic)
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
- (mixi-topic-realize topic)
+ (mixi-realize-topic topic)
(aref (cdr topic) 5))
(defun mixi-topic-content (topic)
"Return the content of TOPIC."
(unless (mixi-topic-p topic)
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
- (mixi-topic-realize topic)
+ (mixi-realize-topic topic)
(aref (cdr topic) 6))
(defun mixi-topic-set-time (topic time)
@@ -1583,6 +1748,34 @@ Increase this value when unexpected error frequently occurs."
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
(aset (cdr topic) 6 content))
+(defmacro mixi-post-topic-page (community)
+ `(concat "/add_bbs.pl?id=" (mixi-community-id community)))
+
+;; FIXME: Support photos.
+(defun mixi-post-topic (community title content)
+ "Post a topic to COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (unless (stringp title)
+ (signal 'wrong-type-argument (list 'stringp title)))
+ (unless (stringp content)
+ (signal 'wrong-type-argument (list 'stringp content)))
+ (let ((fields `(("bbs_title" . ,title)
+ ("bbs_body" . ,content)
+ ("submit" . "main")))
+ post-key)
+ (with-mixi-post-form (mixi-post-topic-page community) fields
+ (if (string-match mixi-post-key-regexp buffer)
+ (setq post-key (match-string 1 buffer))
+ (mixi-post-error 'cannot-find-key community)))
+ (setq fields `(("post_key" . ,post-key)
+ ("bbs_title" . ,title)
+ ("bbs_body" . ,content)
+ ("submit" . "confirm")))
+ (with-mixi-post-form (mixi-post-topic-page community) fields
+ (unless (string-match mixi-post-succeed-regexp buffer)
+ (mixi-post-error 'cannot-find-succeed community)))))
+
;; Event object.
(defvar mixi-event-cache (make-hash-table :test 'equal))
(defun mixi-make-event (community id &optional time title owner date place
@@ -1613,78 +1806,87 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-event-community-regexp
" | \\[\\(.+\\)\\] ¥¤¥Ù¥ó¥È | ")
(defconst mixi-event-time-regexp
- "
-\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü
-\\([0-9]+\\):\\([0-9]+\\) | ")
+ "
+?\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü
+?\\([0-9]+\\):\\([0-9]+\\) | ")
(defconst mixi-event-title-regexp
- " \\([^<]+\\) | ")
+ " \\([^<]+\\) | ")
(defconst mixi-event-owner-regexp
- " \\(.*\\)")
+ " | \\(.*\\)")
+(defconst mixi-event-owner-seceded-regexp
+ " | \\((mixi Âà²ñºÑ)\\)")
(defconst mixi-event-date-regexp
- " | ³«ºÅÆü»þ |
-
+ " | ³«ºÅÆü»þ |
+
\\(.+\\)
| ")
(defconst mixi-event-place-regexp
- "³«ºÅ¾ì½ê |
-
+ " | ³«ºÅ¾ì½ê |
+
\\(.+\\)
| ")
(defconst mixi-event-detail-regexp
- "¾ÜºÙ |
- | ")
+ "¾ÜºÙ |
+ | ")
(defconst mixi-event-limit-regexp
- "Ê罸´ü¸Â |
- \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü | ")
+ "Ê罸´ü¸Â |
+? \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü | ")
(defconst mixi-event-members-regexp
- "»²²Ã¼Ô |
-
-
+ "»²²Ã¼Ô |
+
+
+?
+?
- \\(.+\\) | ")
-(defun mixi-event-realize (event)
+? \\(.+\\) | ")
+
+(defun mixi-realize-event (event)
"Realize a EVENT."
;; FIXME: Check a expiration of cache?
- (unless (mixi-object-realize-p event)
+ (unless (mixi-object-realized-p event)
(with-mixi-retrieve (mixi-event-page event)
(if (string-match mixi-event-community-regexp buffer)
(mixi-community-set-name (mixi-event-community event)
(match-string 1 buffer))
- (signal 'error (list 'cannot-find-title event)))
+ (mixi-realization-error 'cannot-find-community event))
(if (string-match mixi-event-time-regexp buffer)
(mixi-event-set-time
- event (encode-time 0 (string-to-number (match-string 5 buffer))
- (string-to-number (match-string 4 buffer))
- (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))
- (string-to-number (match-string 1 buffer))))
- (signal 'error (list 'cannot-find-time event)))
+ event (encode-time 0 (string-to-number (match-string 8 buffer))
+ (string-to-number (match-string 7 buffer))
+ (string-to-number (match-string 6 buffer))
+ (string-to-number (match-string 5 buffer))
+ (string-to-number (match-string 4 buffer))))
+ (mixi-realization-error 'cannot-find-time event))
(if (string-match mixi-event-title-regexp buffer)
- (mixi-event-set-title event (match-string 1 buffer))
- (signal 'error (list 'cannot-find-title event)))
+ (mixi-event-set-title event (match-string 2 buffer))
+ (mixi-realization-error 'cannot-find-title event))
(if (string-match mixi-event-owner-regexp buffer)
(mixi-event-set-owner event
- (mixi-make-friend (match-string 1 buffer)
- (match-string 2 buffer)))
- (signal 'error (list 'cannot-find-owner event)))
+ (mixi-make-friend (match-string 2 buffer)
+ (match-string 3 buffer)))
+ (if (string-match mixi-event-owner-seceded-regexp buffer)
+ (mixi-event-set-owner event
+ (mixi-make-friend nil
+ (match-string 2 buffer)))
+ (mixi-realization-error 'cannot-find-owner event)))
(if (string-match mixi-event-date-regexp buffer)
- (mixi-event-set-date event (match-string 1 buffer))
- (signal 'error (list 'cannot-find-date event)))
+ (mixi-event-set-date event (match-string 6 buffer))
+ (mixi-realization-error 'cannot-find-date event))
(if (string-match mixi-event-place-regexp buffer)
- (mixi-event-set-place event (match-string 1 buffer))
- (signal 'error (list 'cannot-find-place event)))
+ (mixi-event-set-place event (match-string 6 buffer))
+ (mixi-realization-error 'cannot-find-place event))
(if (string-match mixi-event-detail-regexp buffer)
- (mixi-event-set-detail event (match-string 1 buffer))
- (signal 'error (list 'cannot-find-detail event)))
+ (mixi-event-set-detail event (match-string 6 buffer))
+ (mixi-realization-error 'cannot-find-detail event))
(when (string-match mixi-event-limit-regexp buffer)
(mixi-event-set-limit
- event (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))
- (string-to-number (match-string 1 buffer)))))
+ event (encode-time 0 0 0 (string-to-number (match-string 8 buffer))
+ (string-to-number (match-string 7 buffer))
+ (string-to-number (match-string 6 buffer)))))
(if (string-match mixi-event-members-regexp buffer)
- (mixi-event-set-members event (match-string 1 buffer))
- (signal 'error (list 'cannot-find-members event))))
+ (mixi-event-set-members event (match-string 6 buffer))
+ (mixi-realization-error 'cannot-find-members event)))
(mixi-object-touch event)))
(defun mixi-event-community (event)
@@ -1703,56 +1905,56 @@ Increase this value when unexpected error frequently occurs."
"Return the time of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 3))
(defun mixi-event-title (event)
"Return the title of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 4))
(defun mixi-event-owner (event)
"Return the owner of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 5))
(defun mixi-event-date (event)
"Return the date of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 6))
(defun mixi-event-place (event)
"Return the place of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 7))
(defun mixi-event-detail (event)
"Return the detail of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 8))
(defun mixi-event-limit (event)
"Return the limit of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 9))
(defun mixi-event-members (event)
"Return the members of EVENT."
(unless (mixi-event-p event)
(signal 'wrong-type-argument (list 'mixi-event-p event)))
- (mixi-event-realize event)
+ (mixi-realize-event event)
(aref (cdr event) 10))
(defun mixi-event-set-time (event time)
@@ -1809,8 +2011,7 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-bbs-list '(mixi-topic mixi-event))
(defmacro mixi-bbs-p (object)
- `(when (memq (mixi-object-class ,object) mixi-bbs-list)
- t))
+ `(memq (mixi-object-class ,object) mixi-bbs-list))
(defun mixi-bbs-community (object)
"Return the community of OBJECT."
@@ -1870,7 +2071,7 @@ Increase this value when unexpected error frequently occurs."
(defmacro mixi-search-bbs-list-page (keyword)
`(concat "/search_topic.pl?page=%d&type=top&submit=search"
- "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
+ "&keyword=" (mixi-url-encode-and-quote-percent-string ,keyword)
"&community_id=0&category_id=0"))
(defconst mixi-search-bbs-list-regexp
@@ -1947,7 +2148,7 @@ Increase this value when unexpected error frequently occurs."
|
-
+
@@ -2008,9 +2209,12 @@ Increase this value when unexpected error frequently occurs."
[^<]+ :
\\(.*\\)
-
+\\(|
+ºï½ü
+
+\\|\\)
-\\(\\)
+
\\(.+\\) |
@@ -2066,12 +2270,55 @@ Increase this value when unexpected error frequently occurs."
(mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
items)))
+(defun mixi-post-diary-comment-page (diary)
+ (concat "/add_comment.pl?&diary_id=" (mixi-diary-id diary)))
+
+(defun mixi-post-topic-comment-page (topic)
+ (concat "/add_bbs_comment.pl?id=" (mixi-topic-id topic)
+ "&comm_id=" (mixi-community-id (mixi-topic-community topic))))
+
+(defun mixi-post-event-comment-page (event)
+ (concat "/add_event_comment.pl?id=" (mixi-event-id event)
+ "&comm_id=" (mixi-community-id (mixi-event-community event))))
+
+;; FIXME: Support photos.
+(defun mixi-post-comment (parent content)
+ "Post a comment to PARENT."
+ (unless (mixi-object-p parent)
+ (signal 'wrong-type-argument (list 'mixi-object-p parent)))
+ (unless (stringp content)
+ (signal 'wrong-type-argument (list 'stringp content)))
+ (let* ((name (mixi-object-name parent))
+ (page (intern (concat mixi-object-prefix "post-" name
+ "-comment-page")))
+ fields post-key)
+ (if (mixi-diary-p parent)
+ (setq fields
+ `(("owner_id" . ,(mixi-friend-id (mixi-diary-owner parent)))
+ ("comment_body" . ,content)))
+ (setq fields `(("comment" . ,content))))
+ (with-mixi-post-form (funcall page parent) fields
+ (if (string-match mixi-post-key-regexp buffer)
+ (setq post-key (match-string 1 buffer))
+ (mixi-post-error 'cannot-find-key parent)))
+ (if (mixi-diary-p parent)
+ (setq fields
+ `(("post_key" . ,post-key)
+ ("owner_id" . ,(mixi-friend-id (mixi-diary-owner parent)))
+ ("comment_body" . ,content)
+ ("submit" . "confirm")))
+ (setq fields `(("post_key" . ,post-key)
+ ("comment" . ,content)
+ ("submit" . "confirm"))))
+ (with-mixi-post-form (funcall page parent) fields
+ (unless (string-match mixi-post-succeed-regexp buffer)
+ (mixi-post-error 'cannot-find-succeed parent)))))
+
;; Message object.
(defconst mixi-message-box-list '(inbox outbox savebox thrash)) ; thrash?
(defmacro mixi-message-box-p (box)
- `(when (memq ,box mixi-message-box-list)
- t))
+ `(memq ,box mixi-message-box-list))
(defun mixi-message-box-name (box)
"Return the name of BOX."
@@ -2113,18 +2360,18 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-message-content-regexp
"\\(.+\\) | ")
-(defun mixi-message-realize (message)
+(defun mixi-realize-message (message)
"Realize a MESSAGE."
- (unless (mixi-object-realize-p message)
+ (unless (mixi-object-realized-p message)
(with-mixi-retrieve (mixi-message-page message)
(if (string-match mixi-message-owner-regexp buffer)
(mixi-message-set-owner message
(mixi-make-friend (match-string 2 buffer)
(match-string 3 buffer)))
- (signal 'error (list 'cannot-find-owner message)))
+ (mixi-realization-error 'cannot-find-owner message))
(if (string-match mixi-message-title-regexp buffer)
(mixi-message-set-title message (match-string 2 buffer))
- (signal 'error (list 'cannot-find-title message)))
+ (mixi-realization-error 'cannot-find-title message))
(if (string-match mixi-message-time-regexp buffer)
(mixi-message-set-time
message (encode-time 0 (string-to-number (match-string 6 buffer))
@@ -2132,10 +2379,10 @@ Increase this value when unexpected error frequently occurs."
(string-to-number (match-string 4 buffer))
(string-to-number (match-string 3 buffer))
(string-to-number (match-string 2 buffer))))
- (signal 'error (list 'cannot-find-time message)))
+ (mixi-realization-error 'cannot-find-time message))
(if (string-match mixi-message-content-regexp buffer)
(mixi-message-set-content message (match-string 1 buffer))
- (signal 'error (list 'cannot-find-content message))))
+ (mixi-realization-error 'cannot-find-content message)))
(mixi-object-touch message)))
(defun mixi-message-id (message)
@@ -2154,28 +2401,28 @@ Increase this value when unexpected error frequently occurs."
"Return the owner of MESSAGE."
(unless (mixi-message-p message)
(signal 'wrong-type-argument (list 'mixi-message-p message)))
- (mixi-message-realize message)
+ (mixi-realize-message message)
(aref (cdr message) 3))
(defun mixi-message-title (message)
"Return the title of MESSAGE."
(unless (mixi-message-p message)
(signal 'wrong-type-argument (list 'mixi-message-p message)))
- (mixi-message-realize message)
+ (mixi-realize-message message)
(aref (cdr message) 4))
(defun mixi-message-time (message)
"Return the date of MESSAGE."
(unless (mixi-message-p message)
(signal 'wrong-type-argument (list 'mixi-message-p message)))
- (mixi-message-realize message)
+ (mixi-realize-message message)
(aref (cdr message) 5))
(defun mixi-message-content (message)
"Return the content of MESSAGE."
(unless (mixi-message-p message)
(signal 'wrong-type-argument (list 'mixi-message-p message)))
- (mixi-message-realize message)
+ (mixi-realize-message message)
(aref (cdr message) 6))
(defun mixi-message-set-owner (message owner)
@@ -2209,17 +2456,17 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-message-list-regexp
"")
-(defun mixi-get-messages (&rest args)
- "Get messages."
- (when (> (length args) 2)
+(defun mixi-get-messages (&rest box-or-range)
+ "Get messages of BOX."
+ (when (> (length box-or-range) 2)
(signal 'wrong-number-of-arguments
- (list 'mixi-get-messages (length args))))
- (let ((box (nth 0 args))
- (range (nth 1 args)))
+ (list 'mixi-get-messages (length box-or-range))))
+ (let ((box (nth 0 box-or-range))
+ (range (nth 1 box-or-range)))
(when (or (not (mixi-message-box-p box))
(mixi-message-box-p range))
- (setq box (nth 1 args))
- (setq range (nth 0 args)))
+ (setq box (nth 1 box-or-range))
+ (setq range (nth 0 box-or-range)))
(let ((items (mixi-get-matched-items
(mixi-message-list-page
(when box (mixi-message-box-name box)))
@@ -2229,6 +2476,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
+ "")
+
+(defconst mixi-post-message-succeed-regexp
+ "Á÷¿®´°Î»¤·¤Þ¤·¤¿¡£")
+
+(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."
@@ -2300,16 +2581,16 @@ Increase this value when unexpected error frequently occurs."
|
")
-(defun mixi-get-introductions (&rest args)
- "Get introductions."
- (when (> (length args) 2)
+(defun mixi-get-introductions (&rest friend-or-range)
+ "Get introductions of FRIEND."
+ (when (> (length friend-or-range) 2)
(signal 'wrong-number-of-arguments
- (list 'mixi-get-introduction (length args))))
- (let ((friend (nth 0 args))
- (range (nth 1 args)))
+ (list 'mixi-get-introduction (length friend-or-range))))
+ (let ((friend (nth 0 friend-or-range))
+ (range (nth 1 friend-or-range)))
(when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
- (setq friend (nth 1 args))
- (setq range (nth 0 args)))
+ (setq friend (nth 1 friend-or-range))
+ (setq range (nth 0 friend-or-range)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let* ((regexp (if friend mixi-introduction-list-regexp
@@ -2324,6 +2605,207 @@ Increase this value when unexpected error frequently occurs."
(nth 2 item)))
items))))
+;; News object.
+(defvar mixi-news-cache (make-hash-table :test 'equal))
+(defun mixi-make-news (media-id id &optional media time title content)
+ "Return a news object."
+ (mixi-make-cache (list media-id id)
+ (cons 'mixi-news (vector nil media-id id media time title
+ content))
+ mixi-news-cache))
+
+(defconst mixi-news-url-regexp
+ "/view_news\\.pl\\?id=\\([0-9]+\\)&media_id=\\([0-9]+\\)")
+
+(defun mixi-make-news-from-url (url)
+ "Return a news object from URL."
+ (when (string-match mixi-news-url-regexp url)
+ (let ((id (match-string 1 url))
+ (media-id (match-string 2 url)))
+ (mixi-make-news media-id id))))
+
+(defmacro mixi-news-p (news)
+ `(eq (mixi-object-class ,news) 'mixi-news))
+
+(defmacro mixi-news-page (news)
+ `(concat "http://news.mixi.jp/view_news.pl?id=" (mixi-news-id ,news)
+ "&media_id=" (mixi-news-media-id ,news)))
+
+(defconst mixi-news-title-regexp
+ "\\(.+\\) | ")
+(defconst mixi-news-media-time-regexp
+ "(\\(.+\\) - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)) | ")
+(defconst mixi-news-content-regexp
+ "
+
+\\(.+\\)
+
+?
+
+\\( | \\| \\)")
+
+(defun mixi-realize-news (news)
+ "Realize a NEWS."
+ ;; FIXME: Check a expiration of cache?
+ (unless (mixi-object-realized-p news)
+ (with-mixi-retrieve (mixi-news-page news)
+ (if (string-match mixi-news-title-regexp buffer)
+ (mixi-news-set-title news (match-string 1 buffer))
+ (mixi-realization-error 'cannot-find-title news))
+ (if (string-match mixi-news-media-time-regexp buffer)
+ (progn
+ (mixi-news-set-media news (match-string 1 buffer))
+ (let ((year (nth 5 (decode-time (current-time))))
+ (month (nth 4 (decode-time (current-time))))
+ (month-of-item (string-to-number (match-string 2 buffer))))
+ (when (> month-of-item month)
+ (decf year))
+ (mixi-news-set-time
+ news (encode-time 0 (string-to-number (match-string 5 buffer))
+ (string-to-number (match-string 4 buffer))
+ (string-to-number (match-string 3 buffer))
+ month year))))
+ (mixi-realization-error 'cannot-find-media-time news))
+ (if (string-match mixi-news-content-regexp buffer)
+ (mixi-news-set-content news (match-string 1 buffer))
+ (mixi-realization-error 'cannot-find-content news)))
+ (mixi-object-touch news)))
+
+(defun mixi-news-media-id (news)
+ "Return the media-id of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aref (cdr news) 1))
+
+(defun mixi-news-id (news)
+ "Return the id of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aref (cdr news) 2))
+
+(defun mixi-news-media (news)
+ "Return the media of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (unless (aref (cdr news) 3)
+ (mixi-realize-news news))
+ (aref (cdr news) 3))
+
+(defun mixi-news-time (news)
+ "Return the time of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (unless (aref (cdr news) 4)
+ (mixi-realize-news news))
+ (aref (cdr news) 4))
+
+(defun mixi-news-title (news)
+ "Return the title of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (unless (aref (cdr news) 5)
+ (mixi-realize-news news))
+ (aref (cdr news) 5))
+
+(defun mixi-news-content (news)
+ "Return the content of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (mixi-realize-news news)
+ (aref (cdr news) 6))
+
+(defun mixi-news-set-media (news media)
+ "Set the media of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aset (cdr news) 3 media))
+
+(defun mixi-news-set-time (news time)
+ "Set the time of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aset (cdr news) 4 time))
+
+(defun mixi-news-set-title (news title)
+ "Set the title of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aset (cdr news) 5 title))
+
+(defun mixi-news-set-content (news content)
+ "Set the content of NEWS."
+ (unless (mixi-news-p news)
+ (signal 'wrong-type-argument (list 'mixi-news-p news)))
+ (aset (cdr news) 6 content))
+
+(defconst mixi-news-category-list '(domestic politics economy area abroad
+ sports entertainment IT))
+
+(defmacro mixi-news-category-p (category)
+ `(memq ,category mixi-news-category-list))
+
+(defun mixi-news-category-id (category)
+ "Return the id of CATEGORY."
+ (unless (mixi-news-category-p category)
+ (signal 'wrong-type-argument (list 'mixi-news-category-p category)))
+ (number-to-string
+ (1+ (- (length mixi-news-category-list)
+ (length (memq category mixi-news-category-list))))))
+
+(defconst mixi-news-sort-list '(newest pickup))
+
+(defmacro mixi-news-sort-p (sort)
+ `(memq ,sort mixi-news-sort-list))
+
+(defun mixi-news-sort-id (sort)
+ "Return the id of SORT."
+ (unless (mixi-news-sort-p sort)
+ (signal 'wrong-type-argument (list 'mixi-news-sort-p sort)))
+ (number-to-string
+ (- (length mixi-news-sort-list)
+ (length (memq sort mixi-news-sort-list)))))
+
+(defmacro mixi-news-list-page (category sort)
+ `(concat "http://news.mixi.jp/list_news_category.pl?page=%d"
+ "&sort=" (mixi-news-sort-id ,sort)
+ "&id=" (mixi-news-category-id ,category)
+ "&type=bn"))
+
+(defconst mixi-news-list-regexp
+ "
+¡¦ |
+\\(.+\\)
+\\(\\|\\)
+
+ |
+\\(.+\\) |
+\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) | ")
+
+(defun mixi-get-news (category sort &optional range)
+ "Get news of CATEGORY and SORT."
+ (unless (mixi-news-category-p category)
+ (signal 'wrong-type-argument (list 'mixi-news-category-p category)))
+ (unless (mixi-news-sort-p sort)
+ (signal 'wrong-type-argument (list 'mixi-news-sort-p sort)))
+ (let ((items (mixi-get-matched-items (mixi-news-list-page category sort)
+ mixi-news-list-regexp
+ range))
+ (year (nth 5 (decode-time (current-time))))
+ (month (nth 4 (decode-time (current-time)))))
+ (mapcar (lambda (item)
+ (let ((month-of-item (string-to-number (nth 6 item))))
+ (when (> month-of-item month)
+ (decf year))
+ (setq month month-of-item)
+ (mixi-make-news (nth 2 item) (nth 1 item) (nth 5 item)
+ (encode-time
+ 0 (string-to-number (nth 9 item))
+ (string-to-number (nth 8 item))
+ (string-to-number (nth 7 item))
+ month year)
+ (nth 3 item))))
+ items)))
+
(provide 'mixi)
;;; mixi.el ends here
| | |