Code Monkey home page Code Monkey logo

tweet-delete's Introduction

pytest Maintainability Test Coverage PyPI version

tweet-delete ๐Ÿฆœ๐Ÿ”ซ

tweet-delete is a small Python tool for automatically deleting your tweets (and favourites) after some specified amount of time. It is intended to be used to create self-destructing tweets. tweet-delete runs continuously, and will check your timeline every hour to see if there are any new tweets which need to be deleted. You may also specify a minimum engagement metric, which allows you to delete only the tweets that are junk ๐Ÿ—‘.

Self-destructing tweets are the hippest, trendiest, coolest thing on Twitter right now. Want to be cool and hip? You need tweet-delete. By creating artificial scarcity you can ten ex (10x) or one-hundred ex (100x) your personal brand. ๐Ÿ˜Ž

In spite of the low technical barrier to entry for using this Twitter bot (or any similar ones), it does require following some instructions, and the Twitter dev account approval process is long and arduous. In other words, you will easily be in the top 0.1% of technically skilled Twitter users. You will be super extra hip and cool, and in the upper echelons of thought leadership, simply by using this tool. Wear your badge of honour loud and proud. Perhaps write "These tweets self destruct." in your bio?

Quickstart

NOTE: This tool will delete your tweets. Please do not use this tool if you don't want your tweets to be deleted.

1. Set up Twitter Dev account

To get started, you'll need to go to https://developer.twitter.com/en/apps and set up a Twitter developer account, and create an "App".

Once you're approved (after several days or weeks of waiting), move on to the next step.

2. Generate API access tokens

Follow the instructions here to generate your API access tokens. Save these somewhere, as you'll be needing them later.

3. Find a place to run the codes

You'll need a computer somehere, perhaps somewhere up in the clouds, to run the codes. For your convenience, this repo includes a Helm chart to run this tool on Kubernetes, which is extremely AI these days (if you hadn't heard).

4. Install

This is a standard Python package, which can be installed using pip:

$ pip install tweet-delete
...

Alternatively, you can simply use the pre-built Docker image if you prefer.

5. Run

Run the script by passing it the API keys you generated above. It will run continuously, and tweet all tweets that are older than --delete-older-than days starting on Jan 1, 2019. If you want to also remove favourites, add the --remove_favorites flag.

$ tweet-delete \
    --consumer_key=<consumer_key> \
    --consumer_secret=<consumer_secret> \
    --access_token_key=<access_token_key> \
    --access_token_secret=<access_token_secret> \
    --delete_older_than="7 days" \
    --delete_everything_after=2019-01-01 \
    --minimum_engagement=1
...

Now the script will run forever, and delete all of your tweets older than 7 days as long as it's running. Congratulations! ๐ŸŽ‰๐ŸŽŠ๐Ÿฅณ

Performance

The script features an asynchronous, event-driven core, base on the excellent gevent library. tweet-delete should have no difficulty achieving a tweet deletes per second (TDPS) throughput well in excess of 1,000 TDPS. However, practically speaking, you will likely hit the Twitter API rate limits long before hitting the script's limits.

Deployment with Helm

There's a Helm chart included for your convenience. To use the chart, copy helm/tweet-delete/values.yaml somewhere, and install the chart:

Now install the chart:

$ cp helm/tweet-delete/values.yaml myvalues
$ helm upgrade --install tweet-delete helm/tweet-delete -f myvalues.yaml
Release "tweet-delete" has been upgraded. Happy Helming!
LAST DEPLOYED: Wed Mar 13 15:08:31 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Deployment
NAME          READY  UP-TO-DATE  AVAILABLE  AGE
tweet-delete  0/1    1           0          46s

==> v1/Pod(related)
NAME                           READY  STATUS             RESTARTS  AGE
tweet-delete-79bdbd995b-2mrmj  0/1    ContainerCreating  0         0s

Sweeeeeet ๐Ÿ˜Ž

How can I recover deleted tweets?

You can't! They're gone!

If your account is public, it's possible that your tweets have been archived somewhere. The internet is a semi-free and open place, so it's relatively easy to archive anything you find on it. For example, you may want to try recovering your old tweets from https://snapbird.org/.

Limitations

Twitter does not let you retrieve more than 3,200 tweets from their public API, thus you cannot delete more than 3,200.

tweet-delete's People

Contributors

brndnmtthws avatar dependabot-preview[bot] avatar dependabot[bot] avatar tdurieux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tweet-delete's Issues

TypeError: '<=' not supported between instances of 'NoneType' and 'int'

Hi. I'm using your docker image, and the container stops within a few seconds. The most recent lines in the log are as follows:

File "/app/tweet_delete/main.py", line 17, in validate_duration,
if seconds <= 0:,
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

tweet-deleter don't work with new API limits

tweet-deleter don't work with Twitter API v2 limits. I get the following message: You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product.

Can we do something to avoid this limitation or there's no way to mass delete tweets anymore?

๐Ÿฆโก starting tweet-delete                                                    โก๐Ÿฆ
๐Ÿ”‘ validating credentials                                                     ๐Ÿ”‘
Traceback (most recent call last):
  File "/Users/jleroy/.pyvenv/tweet-delete/bin/tweet-delete", line 8, in <module>
    sys.exit(cli())
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/tweet_delete/main.py", line 95, in cli
    creds = deleter.validate_creds()
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/tweet_delete/deleter.py", line 47, in validate_creds
    return self.api.VerifyCredentials()
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4699, in VerifyCredentials
    resp = self._RequestUrl(url, 'GET', data)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4962, in _RequestUrl
    limit = self.CheckRateLimit(url)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4809, in CheckRateLimit
    self.InitializeRateLimit()
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4792, in InitializeRateLimit
    data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4908, in _ParseAndCheckTwitter
    self._CheckForTwitterError(data)
  File "/Users/jleroy/.pyvenv/tweet-delete/lib/python3.9/site-packages/twitter/api.py", line 4928, in _CheckForTwitterError
    raise TwitterError(data['errors'])
twitter.error.TwitterError: [{'message': 'You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product', 'code': 453}]

<tweet_delete.deleter.Deleter object at ...> failed with AttributeError

Just started getting this error today trying to delete favorites...

...
checking for favorites
favorite ID=1303891849011228672 will be deleted at 2020-09-11 03:03:36
favorite ID=1303770200366440448 will be deleted at 2020-09-10 19:00:13
favorite ID=1301654288892981248 will be deleted at 2020-09-04 22:52:20
favorite ID=1282000033764843520 will be deleted at 2020-07-12 17:13:21
favorite ID=1281704059855081479 will be deleted at 2020-07-11 21:37:15
favorite ID=1275637486744752128 will be deleted at 2020-06-25 03:50:51
favorite ID=1265681708361437184 will be deleted at 2020-05-28 16:30:09
favorite ID=1263934819580420098 will be deleted at 2020-05-23 20:48:38
favorite ID=1221226536151539718 will be deleted at 2020-01-27 00:21:10
favorite ID=1192542848916369410 will be deleted at 2019-11-08 20:42:26
favorite ID=1175444645335248897 will be deleted at 2019-09-22 16:20:16
favorite ID=1150970266098515969 will be deleted at 2019-07-17 03:27:50
favorite ID=1143641126458548225 will be deleted at 2019-06-26 22:04:27
favorite ID=1095049568264310784 will be deleted at 2019-02-12 19:58:56
favorite ID=1089489112955011072 will be deleted at 2019-01-28 11:43:40
deleting favorite with ID=1303891849011228672
deleting favorite with ID=1303770200366440448
deleting favorite with ID=1301654288892981248
deleting favorite with ID=1282000033764843520
deleting favorite with ID=1281704059855081479
deleting favorite with ID=1275637486744752128
deleting favorite with ID=1265681708361437184
deleting favorite with ID=1263934819580420098
deleting favorite with ID=1221226536151539718
deleting favorite with ID=1192542848916369410
deleting favorite with ID=1175444645335248897
deleting favorite with ID=1150970266098515969
deleting favorite with ID=1143641126458548225
deleting favorite with ID=1095049568264310784
deleting favorite with ID=1089489112955011072
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d428260: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1303891849011228672, ScreenName=anjewla9)> failed with AttributeError

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d428480: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1301654288892981248, ScreenName=edjgeek,)> failed with AttributeError

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d4287b0: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1275637486744752128, ScreenName=chuckwoo)> failed with AttributeError

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d428d00: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1175444645335248897, ScreenName=chuckwoo)> failed with AttributeError

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d455150: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1095049568264310784, ScreenName=Geronimo)> failed with AttributeError

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/mark/Library/Python/3.8/lib/python/site-packages/tweet_delete/deleter.py", line 314, in delete_favourite
    if fav.id in self.favourites_scheduled_for_deletion:
  File "/usr/local/lib/python3.8/site-packages/twitter/models.py", line 26, in __eq__
    return other and self.AsDict() == other.AsDict()
AttributeError: 'int' object has no attribute 'AsDict'
2020-09-11T13:44:12Z <Greenlet at 0x10d428bf0: <bound method Deleter.delete_favourite of <tweet_delete.deleter.Deleter object at 0x10ad6ddf0>>(Status(ID=1192542848916369410, ScreenName=chuckwoo)> failed with AttributeError

Error: Read-only application cannot POST

Hi, I tried to run this application from windows CMD, and passes the verification point, then says "off we go" and shows the following error. Also, the application asked me for elevated API access.
twitter.error.TwitterError: Read-only application cannot POST.

ValueError: min() arg is an empty sequence

Getting this error using both the pip-installed library and the Docker image:

๐Ÿ‘‰ tweets older than 7 days will be deleted                                   ๐Ÿ‘ˆ
๐Ÿ‘‰ only tweets created after 2006-03-21 00:00:00 will be deleted              ๐Ÿ‘ˆ
๐Ÿฆ… off we go                                                                  ๐Ÿฆ…
checking for tweets, starting from last_max_id=None
โœ… done checking for tweets, tweets_read=0 max_id=0
Traceback (most recent call last):
  File "/usr/local/bin/tweet-delete", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/tweet_delete/main.py", line 67, in cli
    deleter.run()
  File "/usr/local/lib/python3.8/site-packages/tweet_delete/deleter.py", line 194, in run
    max_id = self.check_for_tweets()
  File "/usr/local/lib/python3.8/site-packages/tweet_delete/deleter.py", line 189, in check_for_tweets
    Deleter.print_stats_for('favourites', favourite_counts)
  File "/usr/local/lib/python3.8/site-packages/tweet_delete/deleter.py", line 128, in print_stats_for
    name.ljust(16), len(values), min(values), max(values),
ValueError: min() arg is an empty sequence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.