Skip to content

Commit

Permalink
Added Github_Unfollowers with all changes requested
Browse files Browse the repository at this point in the history
  • Loading branch information
vismitap committed Feb 20, 2021
1 parent 696b8db commit 325baf8
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,7 @@ $RECYCLE.BIN/


# Chrome driver
chromedriver.exe
chromedriver.exe

# for node_modules
node_modules
1 change: 1 addition & 0 deletions JavaScript/Github_Unfollowers/Followers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
42 changes: 42 additions & 0 deletions JavaScript/Github_Unfollowers/Github_Unfollowers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Script to track recent unfollowers on github using github api
// Author: vismitap

const prompt = require("prompt-sync")();
const Username = prompt("What is your Github Username? : ");

// require node-fetch
const node_fetch = require("node-fetch");

//require fs for memory of old and updated data
const fs = require("fs");

let url = `https://api.github.com/users/${Username}/followers`;

let current = JSON.parse(fs.readFileSync("Followers.json"));
console.table(current);

// fetch data and store in set
node_fetch(url)
.then((res) => res.json())
.then((out) => {
let i = 0;
let set = new Set();

// find the followers username on github from the returned json by github API
for (i in out) {
set.add(out[i]["login"]);
}

if (current.length == 0) {
console.log(`Hey ${Username},
Welcome to Github_Unfollowers!
On your way to know the unfollowers!
Run the command once again!`);
} else {
const unfollowers = current.filter((e) => !set.has(e));
console.log("The unfollowers are: ")
console.table(unfollowers);
}
fs.writeFileSync("Followers.json", JSON.stringify(Array.from(set)));
})
.catch((err) => console.log(err));
18 changes: 18 additions & 0 deletions JavaScript/Github_Unfollowers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Github_Unfollowers
Github_Unfollowers is a script to track the recent people who unfollowed you on Github using the Github API.
* It uses the github API to fetch data of followers.
* The data is then stored in `Followers.json` file and compared with new data and hence the unfollowers can be found!

# Setup instructions
* cd to Rotten-Scripts\JavaScript\Github_unfollowers.
* Run `npm install` to install all dependencies.
* Check whether there is [] in `Followers.json` in the beginning.
* Run `node Github_unfollowers.js` and unleash the magic ✨✨.

# Output
![Run First Time](https://i.imgur.com/mL87JCi.png)
![Run Second Time](https://i.imgur.com/qdVkCRK.png)
![Final Output](https://i.imgur.com/TF50DbH.png)

# Author
Vismita Prabhu - [@vismitap](https://github.com/vismitap)
37 changes: 37 additions & 0 deletions JavaScript/Github_Unfollowers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion JavaScript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ It enables interactive web pages and thus is an essential part of web applicatio
| 16 | ROT13 | [Click Here](ROT13) | [tej5169](https://github.com/tej5169) |
| 17 | RSA Key Pair Generator | [Click Here](RSA_Key_Pair_Generator) | [Mohit Bhat](https://github.com/mbcse) |
| 18 | Send emails | [Click Here](Send_Emails) | [Namya LG](https://github.com/Namyalg) |
| 19 | Who don't follow you | [Click Here](Who_Don't_Follow_You) | [Harsh Barshan Mishra](https://github.com/HarshCasper) |
| 19 | Who don't follow you | [Click Here](Who_Don't_Follow_You) | [Harsh Barshan Mishra](https://github.com/HarshCasper) |
| 20 | Github_Unfollowers | [Click Here](Github_Unfollowers) | [Vismita Prabhu](https://github.com/vismitap) |

0 comments on commit 325baf8

Please sign in to comment.