Repository: KrauseFx/twitter-unfollow Branch: master Commit: 7471dc6a8154 Files: 5 Total size: 4.2 KB Directory structure: gitextract_ndc21pl8/ ├── .gitignore ├── Gemfile ├── LICENSE ├── README.md └── unfollow.rb ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .keys unfollowed_full_names.txt unfollowed_usernames.txt ================================================ FILE: Gemfile ================================================ source "https://rubygems.org" gem "twitter" gem "pry" ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Felix Krause Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # twitter-unfollow > 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. > > I've been reading every single tweet in my timeline for the last 4 years with no interruption. > > In total I have over 100 custom mute filters, including custom regexes like `(@United|delta|Delta|JetBlue|jetblue)`), and muted clients like Buffer > > It's time for me to stop reading so much on social media portals, and focus on reading books instead. > > I'll still follow a small amount of people via Twitter lists, since there are certain things I really don't want to miss ![unfollow.gif](unfollow.gif) [View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter) This script does the following: - Unfollow everybody - Puts them into a list called "Old Follows" - Store the usernames of everyone in `unfollowed_usernames.txt` (this allows you to pretty easily follow everyone again when you feel like it) - Store the usernames, together with full name and bio into `unfollowed_full_names.txt` (this allows you to search for users) ``` bundle install bundle exec ruby unfollow.rb ``` ## Notes: - Make sure to have DMs open to still be able to chat with your friends. - 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. - Make sure to create a list called "Old Follows" ## Technical Notes - Create your application via [Twitter Apps](https://apps.twitter.com) - Set the following environment variables - `ENV["CONSUMER_KEY"]` - `ENV["CONSUMER_SECRET"]` - `ENV["ACCESS_TOKEN"]` - `ENV["ACCESS_TOKEN_SECRET"]` - Due to the API limits this script can only unfollow about 420 people per run. You'll need to regenerate keys after this 🤷‍♀️ [View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter) ================================================ FILE: unfollow.rb ================================================ require 'twitter' require 'shellwords' class Unfollow def run raise "Please create a list called 'Old Follows'" if old_follows_list.nil? followings = client.following followings.each do |user| next if user.screen_name == "KrauseFx" # trolololol puts "Unfollowing user #{user.screen_name} (#{user.name})" client.add_list_member(old_follows_list, user.id) client.unfollow(user.id) `echo "#{user.screen_name.shellescape}" >> unfollowed_usernames.txt` `echo "#{user.screen_name.shellescape} (#{user.name.shellescape}): #{user.description.shellescape}" >> unfollowed_full_names.txt` sleep 1 end end def old_follows_list @_old_follows_list ||= client.lists.find { |a| a.name == "Old Follows" } end def client client = Twitter::REST::Client.new do |config| config.consumer_key = ENV["CONSUMER_KEY"] config.consumer_secret = ENV["CONSUMER_SECRET"] config.access_token = ENV["ACCESS_TOKEN"] config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"] end end end Unfollow.new.run