Skip to content

Instantly share code, notes, and snippets.

@nileshgr
Created August 18, 2012 18:32

Revisions

  1. nileshgr revised this gist Aug 18, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/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 = ''
  2. nileshgr created this gist Aug 18, 2012.
    34 changes: 34 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    #!/usr/bin/python2

    # Go to dev.twitter.com/apps and create a new app; put the information here.

    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()