2007-04-18 Daiki Ueno <ueno@unixuser.org>
+ * riece-twitter.el: New add-on.
+ * riece-addon-modules.el (riece-addon-modules): Add riece-twitter.
+ * Makefile.am (EXTRA_DIST): Add riece-twitter.el.
+
* riece-ctcp.el (riece-ctcp-action-format-message): New function.
(riece-handle-ctcp-action-request): Use it.
(riece-command-ctcp-action): Use it.
riece-ctlseq.el riece-ignore.el riece-hangman.el riece-biff.el \
riece-kakasi.el riece-foolproof.el riece-yank.el riece-toolbar.el \
riece-eval.el riece-google.el riece-keepalive.el riece-eval-ruby.el \
- riece-shrink-buffer.el riece-xfaceb.el riece-epg.el url-riece.el \
+ riece-shrink-buffer.el riece-xfaceb.el riece-epg.el riece-twitter.el \
+ url-riece.el \
riece-command-previous-channel.xpm riece-command-next-channel.xpm \
riece-submit-bug-report.xpm \
server.rb aproxy.rb
(riece-shrink-buffer . "Free old IRC messages to save memory usage.")
(riece-skk-kakutei . "Remove SKK's preedit mark before sending messages.")
(riece-toolbar . "Display toolbar icons.")
+ (riece-twitter . "Send your status to Twitter.")
(riece-unread . "Mark channels where new messages arrived.")
(riece-url . "Collect URL in IRC buffers.")
(riece-xface . "Display X-Face in IRC buffers.")
--- /dev/null
+(defvar riece-twitter-credential nil)
+
+(defun riece-twitter-message-filter (message)
+ (if (and (riece-message-own-p message)
+ (eq 'action (riece-message-type message)))
+ (start-process
+ "curl" nil "curl"
+ "-H" "X-Twitter-Client: Riece"
+ "-H" (concat "X-Twitter-Client-Version: " riece-version-number)
+ "-H" "X-Twitter-Client-URL: http://riece.nongnu.org/twitter.xml"
+ "-u" riece-twitter-credential
+ "-d" (concat "status="
+ (riece-twitter-escape-string (encode-coding-string (riece-message-text message) 'utf-8)))
+ "-s"
+ "http://twitter.com/statuses/update.json"))
+ message)
+
+(defun riece-twitter-escape-string (string)
+ (let ((index 0))
+ (while (string-match "[^0-9A-Za-z\-\._~:/?@!\$'()*,]" string index)
+ (setq string (replace-match
+ (format "%%%02X" (aref string (match-beginning 0)))
+ t t string)
+ index (+ 3 (match-beginning 0))))
+ string))
+
+(defun riece-twitter-insinuate ()
+ (add-hook 'riece-message-filter-functions 'riece-twitter-message-filter))
+
+(defun riece-twitter-uninstall ()
+ (remove-hook 'riece-message-filter-functions 'riece-twitter-message-filter))
+
+(provide 'riece-twitter)
+
+;;; riece-twitter.el ends here