Created
December 8, 2023 19:02
-
-
Save objcmsgSend/b6efe91dd7f54c9cc6b9db72d09d66d1 to your computer and use it in GitHub Desktop.
Snapchat Testlight Logger
This file contains 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 requests, time | |
from discord_webhook import DiscordWebhook, DiscordEmbed | |
from bs4 import BeautifulSoup | |
# Replace with your Discord webhook URL | |
DISCORD_WEBHOOK_URL = "" | |
# Replace with the user ID you want to mention, really meant for error logging | |
USER_ID_TO_MENTION = "1032414469642526801" | |
# Replace with the URL of the website you want to monitor. This is the Snapchat TestFlight beta URL. | |
WEBSITE_URL = "https://testflight.apple.com/join/p7hGbZUR" | |
last_notification_time = 0 | |
notification_interval = 10 * 60 # 10 minutes in seconds | |
def check_website(): | |
try: | |
response = requests.get(WEBSITE_URL) | |
response.raise_for_status() | |
soup = BeautifulSoup(response.text, 'html.parser') | |
beta_status_div = soup.find('div', class_='beta-status') | |
return beta_status_div and "This beta is full." in beta_status_div.get_text() | |
except requests.RequestException as e: | |
print(f"Error: {e}") | |
webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL) | |
content = f"<@{USER_ID_TO_MENTION}> An error occurred: {e}" | |
webhook.content = content | |
webhook.execute() | |
return False | |
def main(): | |
global last_notification_time | |
while True: | |
try: | |
# Check the website | |
website_status = check_website() | |
if website_status: | |
pass | |
else: | |
current_time = time.time() | |
if current_time - last_notification_time >= notification_interval: | |
webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL) | |
content = f"The Snapchat TestFlight beta is not full!\n\n{WEBSITE_URL}" | |
webhook.content = content | |
webhook.execute() | |
last_notification_time = current_time | |
else: | |
print("Notification already sent within the past 10 minutes. Skipping.") | |
except Exception as e: | |
print(f"An error occurred: {e}") | |
webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL) | |
content = f"<@{USER_ID_TO_MENTION}> An error occurred: {e}" | |
webhook.content = content | |
webhook.execute() | |
time.sleep(5) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment