Created
August 3, 2021 20:29
-
-
Save Ge0rg3/9ddfce10e8ade83758ce4ff41538e7d7 to your computer and use it in GitHub Desktop.
Script made to win this intigriti competition: https://twitter.com/intigriti/status/1422527390211878914
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 re | |
import requests as rq | |
from subprocess import Popen | |
from time import sleep | |
gift_card_regex = r"[0-9a-z]{4}\s[0-9a-z]{4}\s[0-9a-z]{4}\s[0-9a-z]{4}" | |
while True: | |
try: | |
resp = rq.get("https://discord.com/api/v9/guilds/870275171938873395/messages/search?author_id=864079810829484062", headers={ | |
"authorization": "AUTH_TOKEN" | |
}).json() | |
except rq.exceptions.SSLError: | |
print("SSL Error") | |
continue | |
rate_limit = resp.get("retry_after") | |
if rate_limit is not None: | |
print(f"Being ratelimited, sleeping for {rate_limit}") | |
sleep(rate_limit + 1) | |
continue | |
most_recent = resp.get("messages")[0][0] | |
content = most_recent.get("content") | |
gift_card_matches = re.findall(gift_card_regex, content) | |
if len(gift_card_matches) == 0: | |
sleep(5) | |
continue | |
else: | |
gift_card = gift_card_matches[0] | |
print(f"FOUND: {gift_card}") | |
for i in range(50): | |
sleep(1) | |
Popen(["telegram-send", gift_card]) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment