X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-twitter.el;h=e40d21117f8f297a70be9169cf4648c395ea3f83;hb=50608da281ce1581759acab299b135f6892a88ca;hp=f650887d43a50037b74ac0c6f555895e271d5178;hpb=9ed0bcf0a4c7396967ef2d58133f45835fdd9ec6;p=elisp%2Friece.git diff --git a/lisp/riece-twitter.el b/lisp/riece-twitter.el index f650887..e40d211 100644 --- a/lisp/riece-twitter.el +++ b/lisp/riece-twitter.el @@ -1,22 +1,70 @@ +;;; riece-twitter.el --- post your status to Twitter +;; Copyright (C) 2007 Daiki Ueno + +;; Author: Daiki Ueno +;; Keywords: IRC, riece + +;; This file is part of Riece. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; NOTE: This is an add-on module for Riece. + +;;; Code: + (require 'riece-message) -(defvar riece-twitter-credential nil) +(defgroup riece-twitter nil + "Post your status to Twitter" + :group 'riece) + +(defcustom riece-twitter-credential nil + "Your credential used to login to Twitter." + :group 'riece-twitter + :type 'string) + +(defcustom riece-twitter-cache-credential t + "If non-nil, cache your credential on Twitter." + :group 'riece-twitter + :type 'boolean) (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")) + (let ((credential + (or riece-twitter-credential + (concat (read-string "Twitter username: ") ":" + (read-passwd "Twitter password: "))))) + (if (and riece-twitter-cache-credential + (not (eq credential riece-twitter-credential))) + (setq riece-twitter-credential credential)) + (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" 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)