Skip to content

Instantly share code, notes, and snippets.

@H3wastooshort
Last active June 13, 2021 05:31
Show Gist options
  • Save H3wastooshort/3f0c36a27621487301da12263e0c3d60 to your computer and use it in GitHub Desktop.
Save H3wastooshort/3f0c36a27621487301da12263e0c3d60 to your computer and use it in GitHub Desktop.
Get an audible and visible notification for [MySpace93](https://myspace.windows93.net/index.php?id=77990). Based off of [sophiezhng/myspace_93_check_notifs.py](https://gist.github.com/sophiezhng/89e1f887202da95d92f4b49e1fba7236)
import json
import requests
import time
from playsound import playsound
user_IDs = ["77990", "82448"] #Enter you user IDs here. Put them in quotes and seperate them by commas
user_id = ""
last_state = [False] * len(user_IDs)
def check():
try:
r = requests.get('https://myspace.windows93.net/api.php?id='+user_id)
except requests.exceptions.ConnectionError:
print("ConnectionError")
return
except:
print("Error")
return
user = make_json_request(r)
if user == False:
print("API Error")
return
notifs = user['notifications']
changes_exist = False
#print("For " + user_id + ": ")
print("For " + user['name'] + ":")
if notifs['new fwiends'] == True:
print("You have new fwiends")
changes_exist = True
if notifs['new fwiend requests'] == True:
print("You have new fwiend requests!")
changes_exist = True
if notifs['new message'] == True:
print("You have messages!")
changes_exist = True
if notifs['new comment'] == True:
print("You have new comment(s)!")
changes_exist = True
if notifs['new blog comment'] == True:
print("You have new blog comment(s)!")
changes_exist = True
if changes_exist == False:
print('Nothing new')
global last_state
if changes_exist and not last_state[user_IDs.index(user_id)]:
playsound("notify.wav")
last_state[user_IDs.index(user_id)] = changes_exist
print("")
def make_json_request(request):
json = request.json()
if json["success"] == 'false':
print("ERROR: "+json["msg"])
return False
else:
return json
while True:
for user_id in user_IDs:
check()
time.sleep(10)
@KLanausse
Copy link

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment