Coder Social home page Coder Social logo

techwiz-3 / who-unfollowed-me Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 25.0 516 KB

๐Ÿ˜ก Python CLI tool that shows you who has unfollowed you on GitHub. PRs welcome!

License: GNU General Public License v3.0

Python 100.00%
pythoncli cli github github-followers tui python python-script rich hacktoberfest github-api

who-unfollowed-me's Introduction

Who Unfollowed Me

Python Implementation

About

Python CLI tool that shows you who has unfollowed you on GitHub.
Heavily inspired by msaaddev/who-unfollowed-me

Installation

PyPI - Downloads

pip install unfollow

Usage

The first time you run the tool, you will be asked to enter your GitHub username. Subsequent runs will show any unfollowers, with names and links.

I used this project to learn a lot about rich, thus I created numerous themes which you can use.

unfollow - colored text and some panels
unfollow panels - colored text inside panels
unfollow bubbles - all text inside beautiful bubbles - requires a nerd font
unfollow simple - no colors or emojis, just plain text and a table

Inspiration

As mentioned, msaaddev/who-unfollowed-me was the reason I created this project and has been a great reference. While I love the project, three things stood out to me that I wanted to improve in my own implementation:

  1. The data files for the tool are not hidden and are stored in your current directory rather than the home directory
  2. Output looks good but a huge amount is self promotion rather than actual relevant info. (Please don't get me wrong, everyone can self promote as much as they like, I'm just talking about what I wanted to improve)
  3. If the tool is run without internet connection, the file that stores the username is erased

Gallery

Bubbles (w/nerd font)

Panels

Development

  1. Clone the repo and cd into it:
git clone https://github.com/TechWiz-3/who-unfollowed-me.git
cd who-unfollowed-me
  1. Ensure poetry is installed by running:pip install poetry
  2. Run: poetry install
  3. Make your changes
  4. To test your changes, run: poetry run unfollow in project root directory

๐ŸŽ‰ Commit labels

If you're interested in the commit labels used in this repo, check out my git-commit-emoji project

who-unfollowed-me's People

Contributors

41646f6c666f avatar anupeshverma avatar archontiskostis avatar chrisli-03 avatar ckorobov avatar das-amit avatar dinoosawruss avatar ethmtrgt avatar ftonato avatar github-actions[bot] avatar hitblast avatar hridoyhazard avatar iammu avatar kailashchoudhary11 avatar kat-kan avatar khuirul-huda avatar lakhaninawaz avatar lunarmarathon avatar lyer1 avatar minetest-j45 avatar mujeeb91 avatar rexdivakar avatar shahgnp avatar shivanshdengla avatar shubham7668 avatar smritiwaiba avatar techwiz-3 avatar thekavyakarthik avatar tintinthong avatar yentlhendrickx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

who-unfollowed-me's Issues

Config file

Create unfollow.toml config file in ~/.unfollow/

Allow the config file to dictate the following:

  1. Theme... i.e. panels, bubbles or simple.
  2. Allow changing of default emojis used in the regular style
  3. Allow customization of all colored text that uses rich markup [style here] (initially just for the regular theme but for all themes if possible) - this can be done because instead of doing console.print("[style here]text[/style here]", the previous text can be set as a default variable and if a config is loaded from unfollow.toml` it can replace the default variable)

Add CI

GitHub actions:

  1. Linting
  2. Automated Pypi releases (triggers on workflow_dispatch and release)
    1. Also add binary builds (pyinstaller) to upload to release
  3. Binary building -> upload artifacts

Add config versioning to autoresolve breaking change

Hi
Happy to take and work on this issue

To fix the breaking change in #34 a version could be added to the config, if the version is missing the config could be renamed and the new default one can be created so that it doesn't lead to unexpected crashes.

Think its best to rename the config and then create the default rather than just overwriting it incase someone did have some configuration done that they can copy and paste across

It would just need to be a simple version=1 at the top that is then incremented whenever any changes to the config layout are made

Issue running locally

Hey everybody, the current setup of the repo doesn't allow for local testing, I'm really sorry for this issue and will work to fix it ASAP. Suggestions or PRS are welcome for this issue as well.

Explicitly return Error when GITHUB API rate limit is exceeded

Rate limit gets hit for unauthenticated request very easily. The error tho is uninformative, for example.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/cli.py", line 181, in main
    get_links()
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/cli.py", line 84, in get_links
    info = unfollow_main()
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 212, in main
    return unfollowed_future.result()
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 174, in run_unfollow
    unfollows = get_unfollows(username)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 130, in get_unfollows
    get_followers(username, write_file=True)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 90, in get_followers
    write_followers(user_object["login"])
TypeError: string indices must be integers

The CLI should handle a 403 response

{'message': "API rate limit exceeded for 175.136.21.106. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", 'documentation_url': 
'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'}

and raise the Error in a comprehensible so the user knows that the rate limit is exceeded

Translations for different languages in the config file

config.py uses the TOML format to allow users to customise the output they receive from the CLI tool.''

Please add your language for each theme while maintaining current styles

List of languages we ALREADY have:

  • English
  • Hindi
  • German
  • French
  • Turkish
  • Polish
  • Spanish
  • Indonesian
  • Dutch
  • Greek
  • Nepali
  • Gujarati
  • Bangla
  • Chinese
  • Portuguese
  • Punjabi

Please don't use Google Translate, PRs with Google Translate detected will not be accepted ๐Ÿ˜ญ

Create no-color version

Create a no-color, no-emoji version called "simple". It will be dealt with similarly to bubbles and panels.

All files will be relevant in this issue although I would start with cli.py.

Code should be pretty self explanatory after looking at it tho ๐Ÿ‘. Any questions please go ahead and ask ๐Ÿ™

Automatically load token and remove `--token` option

Personally, I also have an opinion about the use of --token flag. I believe the CLI should automatically load the token even if the --token flag is not specified and read from UNFOLLOW_TOKEN. That can be another issue @TechWiz-3 if you want.

Originally posted by @tintinthong in #29 (comment)

  • Automatically load token
  • If successfully loaded ensure that HEADERS is assigned correctly
  • If UNFOLLOW_TOKEN is empty or cannot be loaded, assign HEADERS to an empty dict

If user no longer exists, notify

Currently, when a user is following you and they rename their account, the old and new usernames do not match up and so are counted as an unfollow.

After identifying a username is longer following given account, make a function in unfollow.py that checks if the user is still valid! If not valid, in line 126 add [deleted] to the result value in the tuple.

The result will look like this (without the covered text)

Screen Shot 2022-09-30 at 1 39 43 pm

The content of the `${HOME}/.unfollow/followers.json` is plaintext instead of json

When you're saving the followers to the JSON file, instead of saving it as plaintext separated by new lines, you could save the GitHub user ids along with their names inside of JSON objects like this

[
  {
    "id": 123,
    "username": "ddjerqq"
  },
  // more
]

image

this would handle cases where users change their handles!

I could help you with this.

Option to put UNFOLLOW_TOKEN in config file

Option to put the GitHub token used by the program in the config file, eliminating the need to set it as an environment variable.

If the token is not found in the config file, the program should then look for the environment variable as it currently does

Cache the unfollowers from the last week in a file

Currently, users only have one chance at viewing unfollowers since last run. After that the files in ~/.unfollow are updated!

Add a --cached option which allows users to view unfollowers from the last week as part of the info passed into beautify.py. The cached unfollowers should be in .unfollow/cached.[txt|json] (whichever format you choose)

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.