Skip to content

Instantly share code, notes, and snippets.

@alehatsman
Created April 10, 2017 12:33
Show Gist options
  • Save alehatsman/c9b88c9c8d24b499990d52590e7230b3 to your computer and use it in GitHub Desktop.
Save alehatsman/c9b88c9c8d24b499990d52590e7230b3 to your computer and use it in GitHub Desktop.
Remove all tweets from twitter. Requires to create app in twitter developer.
(ns tweet-wipe.core
(:use [twitter.oauth]
[twitter.callbacks]
[twitter.callbacks.handlers]
[twitter.api.restful])
(:import [twitter.callbacks.protocols SyncSingleCallback])
(:gen-class))
(def number-of-tweets 200)
(def my-creds (make-oauth-creds "app-consumer-key"
"app-consumer-secret"
"user-access-token"
"user-access-token-secret"))
(defn get-user
[name]
(->
(users-lookup :oauth-creds my-creds
:params {:screen_name name})
(:body)
(first)))
(defn get-tweet-count
[name]
(:statuses_count (get-user name)))
(defn get-tweets
[name]
(:body (statuses-user-timeline :oauth-creds my-creds
:params {:screen_name name
:count number-of-tweets})))
(defn get-tweet-ids
[name]
(map #(:id_str %) (get-tweets name)))
(defn destroy-status
[id]
(statuses-destroy-id :oauth-creds my-creds
:params {:id id}))
(defn destroy-statuses
[ids]
(doseq [id ids] (destroy-status id)))
(defn wipe-tweets-portion
[name]
(->
(get-tweet-ids name)
(destroy-statuses)))
(defn wipe-tweets
[name]
(println "wipe-tweets")
(let [tweet-count (get-tweet-count name)]
(if (> tweet-count 0)
(do
(wipe-tweets-portion name)
(recur name)))))
(defn -main
[& args]
(wipe-tweets "screen name"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment