├── Gemfile ├── .gitignore ├── unfollow.gif ├── LICENSE ├── unfollow.rb ├── Gemfile.lock └── README.md /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "twitter" 4 | gem "pry" 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .keys 2 | unfollowed_full_names.txt 3 | unfollowed_usernames.txt 4 | -------------------------------------------------------------------------------- /unfollow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KrauseFx/twitter-unfollow/HEAD/unfollow.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Felix Krause 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /unfollow.rb: -------------------------------------------------------------------------------- 1 | require 'twitter' 2 | require 'shellwords' 3 | 4 | class Unfollow 5 | def run 6 | raise "Please create a list called 'Old Follows'" if old_follows_list.nil? 7 | followings = client.following 8 | 9 | followings.each do |user| 10 | next if user.screen_name == "KrauseFx" # trolololol 11 | 12 | puts "Unfollowing user #{user.screen_name} (#{user.name})" 13 | client.add_list_member(old_follows_list, user.id) 14 | client.unfollow(user.id) 15 | `echo "#{user.screen_name.shellescape}" >> unfollowed_usernames.txt` 16 | `echo "#{user.screen_name.shellescape} (#{user.name.shellescape}): #{user.description.shellescape}" >> unfollowed_full_names.txt` 17 | sleep 1 18 | end 19 | end 20 | 21 | def old_follows_list 22 | @_old_follows_list ||= client.lists.find { |a| a.name == "Old Follows" } 23 | end 24 | 25 | def client 26 | client = Twitter::REST::Client.new do |config| 27 | config.consumer_key = ENV["CONSUMER_KEY"] 28 | config.consumer_secret = ENV["CONSUMER_SECRET"] 29 | config.access_token = ENV["ACCESS_TOKEN"] 30 | config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"] 31 | end 32 | end 33 | end 34 | 35 | Unfollow.new.run 36 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.5.0) 5 | public_suffix (~> 2.0, >= 2.0.2) 6 | buftok (0.2.0) 7 | coderay (1.1.1) 8 | domain_name (0.5.20161129) 9 | unf (>= 0.0.5, < 1.0.0) 10 | equalizer (0.0.11) 11 | faraday (0.11.0) 12 | multipart-post (>= 1.2, < 3) 13 | http (2.1.0) 14 | addressable (~> 2.3) 15 | http-cookie (~> 1.0) 16 | http-form_data (~> 1.0.1) 17 | http_parser.rb (~> 0.6.0) 18 | http-cookie (1.0.3) 19 | domain_name (~> 0.5) 20 | http-form_data (1.0.1) 21 | http_parser.rb (0.6.0) 22 | memoizable (0.4.2) 23 | thread_safe (~> 0.3, >= 0.3.1) 24 | method_source (0.8.2) 25 | multipart-post (2.0.0) 26 | naught (1.1.0) 27 | pry (0.10.4) 28 | coderay (~> 1.1.0) 29 | method_source (~> 0.8.1) 30 | slop (~> 3.4) 31 | public_suffix (2.0.5) 32 | simple_oauth (0.3.1) 33 | slop (3.6.0) 34 | thread_safe (0.3.5) 35 | twitter (6.1.0) 36 | addressable (~> 2.5) 37 | buftok (~> 0.2.0) 38 | equalizer (= 0.0.11) 39 | faraday (~> 0.11.0) 40 | http (~> 2.1) 41 | http_parser.rb (~> 0.6.0) 42 | memoizable (~> 0.4.2) 43 | naught (~> 1.1) 44 | simple_oauth (~> 0.3.1) 45 | unf (0.1.4) 46 | unf_ext 47 | unf_ext (0.0.7.2) 48 | 49 | PLATFORMS 50 | ruby 51 | 52 | DEPENDENCIES 53 | pry 54 | twitter 55 | 56 | BUNDLED WITH 57 | 1.14.3 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # twitter-unfollow 2 | 3 | > My goal for the next months is to spend less time on social media and more time creating. Instead of reacting to things, I want to focus on having a bigger vision, planning things ahead and doing what has the highest impact. 4 | > 5 | > I've been reading every single tweet in my timeline for the last 4 years with no interruption. 6 | > 7 | > In total I have over 100 custom mute filters, including custom regexes like `(@United|delta|Delta|JetBlue|jetblue)`), and muted clients like Buffer 8 | > 9 | > It's time for me to stop reading so much on social media portals, and focus on reading books instead. 10 | > 11 | > I'll still follow a small amount of people via Twitter lists, since there are certain things I really don't want to miss 12 | 13 | ![unfollow.gif](unfollow.gif) 14 | 15 | [View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter) 16 | 17 | This script does the following: 18 | 19 | - Unfollow everybody 20 | - Puts them into a list called "Old Follows" 21 | - Store the usernames of everyone in `unfollowed_usernames.txt` (this allows you to pretty easily follow everyone again when you feel like it) 22 | - Store the usernames, together with full name and bio into `unfollowed_full_names.txt` (this allows you to search for users) 23 | 24 | ``` 25 | bundle install 26 | bundle exec ruby unfollow.rb 27 | ``` 28 | 29 | ## Notes: 30 | - Make sure to have DMs open to still be able to chat with your friends. 31 | - Use a list to follow a small subset of people. This way you follow 0 people and nobody feels left out. The list can be private. 32 | - Make sure to create a list called "Old Follows" 33 | 34 | ## Technical Notes 35 | - Create your application via [Twitter Apps](https://apps.twitter.com) 36 | - Set the following environment variables 37 | - `ENV["CONSUMER_KEY"]` 38 | - `ENV["CONSUMER_SECRET"]` 39 | - `ENV["ACCESS_TOKEN"]` 40 | - `ENV["ACCESS_TOKEN_SECRET"]` 41 | - Due to the API limits this script can only unfollow about 420 people per run. You'll need to regenerate keys after this 🤷‍♀️ 42 | 43 | [View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter) 44 | --------------------------------------------------------------------------------