From: ueno Date: Tue, 29 May 2007 02:38:52 +0000 (+0000) Subject: (riece-twitter-credential): Define with defcustom. X-Git-Tag: riece-4_0_0~8 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b747430c3b729e5d42299f583f9df81ae856a0d4;p=elisp%2Friece.git (riece-twitter-credential): Define with defcustom. (riece-twitter-cache-credential): New user option. (riece-twitter-message-filter): Ask Twitter username and password. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a5a5ae9..822f291 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2007-05-29 Daiki Ueno + + * riece-twitter.el (riece-twitter-credential): Define with defcustom. + (riece-twitter-cache-credential): New user option. + (riece-twitter-message-filter): Ask Twitter username and password. + 2007-05-28 Daiki Ueno * riece-log.el (riece-log-display-message-function): Just call diff --git a/lisp/riece-twitter.el b/lisp/riece-twitter.el index f650887..c70dfe9 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 nil + "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)