From 156131f7ee2c6887049318652292f49d05cc7279 Mon Sep 17 00:00:00 2001 From: ueno Date: Wed, 6 Jun 2007 09:01:34 +0000 Subject: [PATCH] * riece-twitter.el (riece-twitter-set-credential): New command. (riece-twitter-update): New command. (riece-twitter-message-filter): Use it. --- lisp/ChangeLog | 6 ++++++ lisp/riece-twitter.el | 52 +++++++++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2e5b0f3..a4ca687 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2007-06-06 Daiki Ueno + + * riece-twitter.el (riece-twitter-set-credential): New command. + (riece-twitter-update): New command. + (riece-twitter-message-filter): Use it. + 2007-06-05 Daiki Ueno * riece-twitter.el (riece-twitter-message-filter): Send a "source" diff --git a/lisp/riece-twitter.el b/lisp/riece-twitter.el index 214d03f..6212ff0 100644 --- a/lisp/riece-twitter.el +++ b/lisp/riece-twitter.el @@ -38,22 +38,28 @@ :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))) - (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)) - (start-process +(if (fboundp 'clear-string) + (defalias 'riece-twitter-clear-string 'clear-string) + (defun riece-twitter-clear-string (string) + (fillarray string ?\x0))) + +(defun riece-twitter-set-credential (credential) + "Set your credential used to login to Twitter." + (interactive + (let ((username (read-string "Username: ")) + password) + (unwind-protect + (setq password (read-passwd "Password: ")) + (if password + (riece-twitter-clear-string password)) + (setq password nil)) + (list (concat username ":" password)))) + (setq riece-twitter-credential credential)) + +(defun riece-twitter-update (status) + "Update your status." + (interactive "sStatus: ") + (start-process "curl" nil "curl" "-H" "X-Twitter-Client: Riece" "-H" (concat "X-Twitter-Client-Version: " riece-version-number) @@ -62,10 +68,18 @@ "-d" "source=riece" "-d" (concat "status=" (riece-twitter-escape-string - (encode-coding-string (riece-message-text message) - 'utf-8))) + (encode-coding-string status 'utf-8))) "-s" - "http://twitter.com/statuses/update.json"))) + "http://twitter.com/statuses/update.json")) + +(defun riece-twitter-message-filter (message) + (if (and (riece-message-own-p message) + (eq 'action (riece-message-type message))) + (if riece-twitter-credential + (riece-twitter-update (riece-message-text message)) + (message "%s" + (substitute-command-keys + "\\[riece-twitter-set-credential] to set your credential")))) message) (defun riece-twitter-escape-string (string) -- 1.7.10.4