From: ueno Date: Wed, 18 Apr 2007 04:45:34 +0000 (+0000) Subject: * riece-twitter.el: New add-on. X-Git-Tag: riece-4_0_0~13 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10bd73d658e64718d18f56047c47683f3f55f38f;p=elisp%2Friece.git * riece-twitter.el: New add-on. * riece-addon-modules.el (riece-addon-modules): Add riece-twitter. * Makefile.am (EXTRA_DIST): Add riece-twitter.el. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 850dfca..62b83ad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2007-04-18 Daiki Ueno + * 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. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index c01a6be..c9fa8ca 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -19,7 +19,8 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \ 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 diff --git a/lisp/riece-addon-modules.el b/lisp/riece-addon-modules.el index 4bd4b3a..103a8fb 100644 --- a/lisp/riece-addon-modules.el +++ b/lisp/riece-addon-modules.el @@ -30,6 +30,7 @@ (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.") diff --git a/lisp/riece-twitter.el b/lisp/riece-twitter.el new file mode 100644 index 0000000..a581ddc --- /dev/null +++ b/lisp/riece-twitter.el @@ -0,0 +1,35 @@ +(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