{"id":14110181,"url":"https://github.com/edas/TweetDeletion","last_synced_at":"2025-08-01T09:33:13.567Z","repository":{"id":148440374,"uuid":"94814515","full_name":"edas/TweetDeletion","owner":"edas","description":"Remove old tweets","archived":false,"fork":false,"pushed_at":"2020-01-06T17:45:42.000Z","size":35,"stargazers_count":51,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-14T10:15:51.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-19T19:44:14.000Z","updated_at":"2023-11-07T13:06:23.000Z","dependencies_parsed_at":"2023-05-20T05:31:21.061Z","dependency_job_id":null,"html_url":"https://github.com/edas/TweetDeletion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edas%2FTweetDeletion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edas%2FTweetDeletion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edas%2FTweetDeletion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edas%2FTweetDeletion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edas","download_url":"https://codeload.github.com/edas/TweetDeletion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228360659,"owners_count":17907952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-14T10:02:42.298Z","updated_at":"2024-12-05T19:31:37.405Z","avatar_url":"https://github.com/edas.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# TweetDeletion\n\nThis code allows you to delete your tweets both and Twitter and Mastodon depending on various criterias. \n\nI use it to delete most tweets after 10 days, with additionnal complexe rules (keep tweets I favorited, keep private messages, keep tweet with high interactions, …)\n\nContributions are more than welcomed. Feel free to use and adapt. Ask questions if you have any. Please do contact me to let me know how your are using it.\n\n## Installation\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Credentials\n\nTwitter: Create a script that uses TweetDeletion. You will need a Twitter Development account and to create an application on the [App Deshboard](https://apps.twitter.com/). You should have a consumer_key and a consumer_secret for the app, and an access_token and an access_token_secret per authorized account. If you already have an ap registered and try to authorize other accounts, `Twitter.authorize_request` and `Twitter.get_token` will help you manage that.\n\nMastodon: First register your app to have a client_id and client_secret, then use them to get a bearer_token per authorized account with your email and password. You will find some code on `Mastodon.register_and_get_token` to help you.\n\n## Usage\n\nCreate a script then execute it with `bundle exec your_script.rb`.\n\nExemple of scripts are below:\n\n```ruby\nrequire \"tweet_deletion\"\n\naccounts = [\n  { \n    network: \"twitter\",\n    consumer_key: \"xxx\",\n    consumer_secret: \"xxx\",\n    access_token: \"xxx\",\n    access_token_secret: \"xxx\"\n  },\n  {\n    network: \"mastodon\",\n    instance: \"your instance url\", \n    bearer_token: \"xxx\"  \n  }\n]\n\nTweetDeletion.with( accounts ) do \n\n  for_favorites do\n    keep_if by(:me) \n    keep_if earlier_than( 10.days.ago )\n    keep_if rt_by(:me)\n  end \n\n  for_tweets(include_rts: true) do\n    keep_if earlier_than( 10.days.ago )\n    delete_if rt_of(:me) if is_rt\n    keep_if fav_by(:me)\n    keep_if has_kept_reply\n    keep_if has_kept_quote\n    keep_if is_direct_message\n    unless is_rt\n      keep_if rt_by_more_than( 50 )\n      keep_if fav_by_more_than( 50 )\n    end\n  end\n\nend\n```\n\nOr with emojis as visual feedback (optional):\n\n```ruby\nrequire \"tweet_deletion\"\n\naccounts = [\n  { \n    network: \"twitter\",\n    consumer_key: \"xxx\",\n    consumer_secret: \"xxx\",\n    access_token: \"xxx\",\n    access_token_secret: \"xxx\"\n  },\n  {\n    network: \"mastodon\",\n    instance: \"your instance url\",\n    bearer_token: \"xxx\"  \n  }\n]\n\nTweetDeletion.with( accounts ) do \n\n  for_favorites do\n    keep_if by(:me), tag:\" 🗣 \"\n    keep_if earlier_than( 12.days.ago ), tag:\" 📅 \"\n    keep_if rt_by(:me), tag:\" 💬 \"\n    else_delete tag:\" 🗑 \"\n  end \n\n  for_tweets(include_rts: true) do\n    keep_if earlier_than( 10.days.ago ), tag:\" 📅 \"\n    delete_if (is_rt and rt_of(:me)), tag:\" 🗑 \"\n    keep_if fav_by(:me), tag: \" ❤ ️\"\n    keep_if has_kept_reply, tag:\" 💬 \"\n    keep_if has_kept_quote, tag:\" 💬 \"\n    keep_if is_direct_message, tag: \" 📩 \"\n    unless is_rt\n      keep_if rt_by_more_than( 15 ), tag: \" 💯 \"\n      keep_if fav_by_more_than( 15 ), tag: \" 💯 \"\n    end\n    else_delete tag:\" 🗑 \"\n  end\n\nend\n```\n\n### Tweets from archive\n\nDownload your Twitter Archive and unzip it to pass the folder's path to a specific set of rules into your script:\n\n```ruby\nfor_archive(\"./archive/\") do\n  keep_if earlier_than( 10.days.ago ), tag:\" 📅 \"\n  delete_if (is_rt and rt_of(:me)), tag:\" 🗑 \"\n  keep_if fav_by(:me), tag: \" ❤ ️\"\n  keep_if has_kept_reply, tag:\" 💬 \"\n  keep_if has_kept_quote, tag:\" 💬 \"\n  unless is_rt\n    keep_if rt_by_more_than( 15 ), tag: \" 💯 \"\n    keep_if fav_by_more_than( 15 ), tag: \" 💯 \"\n  end\n  else_delete tag:\" 🗑 \"\nend\n```\n\n\n## Actions and conditions\nThen execute you script:\n\nInside the `for_*` blocks, you can use actions and conditions\n\n### Actions\n\nThe first action to match will be used.\n\n- `else_keep` keep your tweet\n- `else_delete` delete your tweet\n- `keep_if` keep your tweet if the parameter evaluates to `true`\n- `delete_if` delete your tweet if the parameter evaluates to `true`\n- `keep_unless` keep your tweet unless the parameter evaluates to `true`\n- `delete_unless` delete your tweet unless the parameter evaluates to `true`\n\nThe optionnal `tag` named argument will display the corresponding tag in the console when the action is applied.\n\n### Helpers\n\n- `me` will return the current account name (without the leading \"@\")\n- `tweet` will return an instance of `Status` with your tweet\n- `mastodon` and `twitter` will return the current `Mastodon` or `Twitter` client instance \n\n### Conditions\n\n- `by(user)` will match if the tweet is written by the given user \n- `earlier_than(date)` will match if the tweet has been written after the given date\n- `older_than(date)`  will match if the tweet has been written before the given date\n- `rt_by(:me)` will match if you retweeted the tweet\n- `fav_by(:me)` will match if you favorited the tweet\n- `is_rt` will match if the tweet is a retweet\n- `links_to(url)` will match if the link (as a string) is present in the tweet (regexp are also allowed)\n- `contains(match)` will match if the tweet contains the given string (regexp are also allowed)\n- `rt_of(who)` will match if the original tweet was written by the given user\n- `on_mastodon` and `on_twitter` will match is the current account is on the corresponding plateform\n- `is_public`, `is_private`, `is_unlisted`, `is_direct_message` will match depending on the tweet visibility\n- `has_media` will match if the tweet has an embedded image or media\n- `has_kept_quote` will match if you decided to keep a message of yours which quote this tweet\n- `has_kept_reply` will match if you decided to keep a message of yours which directly reply to this tweet. It will not follow indirect chains of tweets, if you reply to someone else's tweet which itself replies to a tweet you decided to keep: this will not match. However, if you consitently keep each message which has a reply from you, this rule will help you keep alive a whole thread provided you manage to keep the last one of the thread.\n\n\nUsers are expected in numeric (integer ids) or string (without the leading \"@\" but with the instance name on Mastodon). The magic value `:me` will match the current user.\n\nFor Twitter, a tweet is marked as private if the author account is protected, public otherwise.\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [TweetDeletion](https://github.com/edas/TweetDeletion).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedas%2FTweetDeletion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedas%2FTweetDeletion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedas%2FTweetDeletion/lists"}