Last active
June 24, 2024 16:20
-
-
Save EnyCode/fbbfb910ed1b8120148e241c513a30ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import requests | |
| ids = [] | |
| leaderboard = [] | |
| # for this to work you need a xoxc token (from requests) and a xoxd token (from cookies) | |
| parseName = False | |
| xoxc = "" | |
| xoxd = "" | |
| form_data = """-----------------------------8251765621166424207856791925 | |
| Content-Disposition: form-data; name="content" | |
| null | |
| -----------------------------8251765621166424207856791925 | |
| Content-Disposition: form-data; name="token" | |
| """ + xoxc + """ | |
| -----------------------------8251765621166424207856791925-- | |
| """ | |
| with open("ids.json") as f: | |
| ids = json.load(f) | |
| for slackId in ids: | |
| x = requests.get("https://hackhour.hackclub.com/api/stats/" + slackId).json() | |
| if x["ok"] == True: | |
| leaderboard.append({"slackId": slackId, "hours": (x["data"]["total"] or 0) // 60}) | |
| else: | |
| print("id", slackId, "failed") | |
| leaderboard.sort(key=lambda x: -x["hours"]) | |
| print("\033[1mLeaderboard:\033[0m") | |
| i = 0 | |
| for person in leaderboard: | |
| i += 1 | |
| name = person["slackId"] | |
| if parseName: | |
| x = requests.post("https://slack.com/api/users.info?user=" + name, headers={"Content-Type": "multipart/form-data; boundary=---------------------------8251765621166424207856791925", "Cookie": "d=" + xoxd}, data=form_data).json() | |
| if x["ok"] == True: | |
| name = x["user"]["profile"]["display_name"] | |
| else: | |
| print(x) | |
| prefix = "" | |
| if i == 1: | |
| prefix = "🥇" | |
| elif i == 2: | |
| prefix = "🥈" | |
| elif i == 3: | |
| prefix = "🥉" | |
| print("\033[1m" + str(i) + ".\033[0m", prefix, name, "-\033[1m", person["hours"], "\033[0mhours") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this, create a file called ids.json with a list of all your friends' ids inside.