Skip to content

Instantly share code, notes, and snippets.

@nileshgr
Created August 18, 2012 18:32
Show Gist options
  • Save nileshgr/3388917 to your computer and use it in GitHub Desktop.
Save nileshgr/3388917 to your computer and use it in GitHub Desktop.
Delete all twitter DMs using this python script
#!/usr/bin/python2
# Go to dev.twitter.com/apps and create a new app; put the information here.
# You need the tweepy library.
consumer_secret = ''
consumer_key = ''
access_token_key = ''
access_token_secret = ''
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
api = tweepy.API(auth)
def deleteDMs():
while True:
dlist = api.direct_messages()
if len(dlist) >= 1:
for d in dlist:
print "Destroying " + d.text + "\n"
d.destroy()
else:
break
while True:
dlist = api.sent_direct_messages()
if(dlist) >= 1:
for d in dlist:
print "Destroying " + d.text + "\n"
d.destroy()
else:
break
deleteDMs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment