Created
July 17, 2014 17:36
-
-
Save cvmat/e4ffa615910bc27c4ed2 to your computer and use it in GitHub Desktop.
mute/unmute for twittering-mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 6635d63ea4fa twittering-mode.el | |
--- a/twittering-mode.el Mon Apr 21 02:05:19 2014 +0900 | |
+++ b/twittering-mode.el Fri Jul 18 02:32:01 2014 +0900 | |
@@ -5586,6 +5586,18 @@ | |
Valid key symbols in ARGS-ALIST: | |
username -- the username who the message is sent to. | |
status -- the sent message. | |
+mute -- Mute a user. | |
+ Valid key symbols in ARGS-ALIST: | |
+ user-id -- the user-id that will be muted. | |
+ username -- the username who will be muted. | |
+ This command requires either of the above key. If both are given, `user-id' | |
+ will be used in REST API. | |
+unmute -- Un-mute a user. | |
+ Valid key symbols in ARGS-ALIST: | |
+ user-id -- the user-id that will be un-muted. | |
+ username -- the username who will be un-muted. | |
+ This command requires either of the above key. If both are given, `user-id' | |
+ will be used in REST API. | |
block -- Block a user. | |
Valid key symbols in ARGS-ALIST: | |
user-id -- the user-id that will be blocked. | |
@@ -6245,6 +6257,20 @@ | |
(format-str "json")) | |
(twittering-http-post account-info-alist host method http-parameters | |
format-str additional-info))) | |
+ ((memq command '(mute unmute)) | |
+ ;; Mute a user. | |
+ (let* ((user-id (cdr (assq 'user-id args-alist))) | |
+ (username (cdr (assq 'username args-alist))) | |
+ (host "api.twitter.com") | |
+ (method | |
+ (cdr (assq command '((mute . "1.1/mutes/users/create") | |
+ (unmute . "1.1/mutes/users/destroy"))))) | |
+ (http-parameters (if user-id | |
+ `(("user_id" . ,user-id)) | |
+ `(("screen_name" . ,username)))) | |
+ (format-str "json")) | |
+ (twittering-http-post account-info-alist host method http-parameters | |
+ format-str additional-info))) | |
((eq command 'block) | |
;; Block a user. | |
(let* ((user-id (cdr (assq 'user-id args-alist))) | |
@@ -8539,6 +8565,8 @@ | |
(format-time-string "%a %b %d %H:%M:%S %z %Y" | |
(cdr (assq 'created-at ,status-sym))))) | |
("d" . (cdr (assq 'user-description ,status-sym))) | |
+ ("F" . (when (cdr (assq 'favorited ,status-sym)) | |
+ "[favorited]")) | |
("f" . | |
(twittering-make-string-with-source-property | |
(cdr (assq 'source ,status-sym)) ,status-sym)) | |
@@ -11449,6 +11477,42 @@ | |
(interactive) | |
(twittering-favorite t)) | |
+(defun twittering-mute (&optional remove) | |
+ (interactive "P") | |
+ (let* ((method (if remove 'unmute 'mute)) | |
+ (mes (if remove "unmute" "mute")) | |
+ (id (twittering-get-id-at)) | |
+ (status (when id (twittering-find-status id))) | |
+ (username | |
+ (cond | |
+ ((assq 'retweeted-id status) | |
+ (let* ((retweeting-username | |
+ (cdr (assq 'retweeting-user-screen-name status))) | |
+ (retweeted-username | |
+ (cdr (assq 'retweeted-user-screen-name status))) | |
+ (default (if remove | |
+ retweeting-username | |
+ retweeted-username)) | |
+ (prompt (format "Who do you %s? (default:%s): " | |
+ mes default)) | |
+ (candidates (list retweeted-username retweeting-username))) | |
+ (twittering-completing-read prompt candidates nil t | |
+ nil nil default))) | |
+ (status | |
+ (cdr (assq 'user-screen-name status))) | |
+ (t | |
+ (twittering-read-username-with-completion | |
+ (format "Who do you %s? " mes) "" 'twittering-user-history))))) | |
+ (if (string= "" username) | |
+ (message "No user selected") | |
+ (if (y-or-n-p (format "%s %s? " (capitalize mes) username)) | |
+ (twittering-call-api method `((username . ,username))) | |
+ (message "Request canceled"))))) | |
+ | |
+(defun twittering-unmute () | |
+ (interactive) | |
+ (twittering-mute t)) | |
+ | |
(defun twittering-block () | |
"Block a user who posted the tweet at the current position." | |
(interactive) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment