Skip to content

Instantly share code, notes, and snippets.

@Heliodex
Created May 20, 2022 23:35
Show Gist options
  • Save Heliodex/38a89e4a05803f7b15d0a55abfe5428d to your computer and use it in GitHub Desktop.
Save Heliodex/38a89e4a05803f7b15d0a55abfe5428d to your computer and use it in GitHub Desktop.
Ping a discord webhook to notify of the online status of a Roblox user.
# Heliodex 2022/05/20
# Last edited 2022/05/20
# Checks every minute to see if a Roblox user is online, and pings a discord webhook if that status has changed.
import requests
import json
from time import sleep
from dateutil import parser
while True:
responseText = json.loads(requests.get(
"https://api.roblox.com/users/303400323/onlinestatus/").text)
textToSend = ""
online = responseText["IsOnline"]
previouslyOnline = False
if responseText["IsOnline"] == True:
textToSend = "https://www.roblox.com/users/303400323/profile IS ONLINE"
else:
lastOnline = str(parser.parse(responseText["LastOnline"]))[0:19]
# 2022-05-20 05:51:42
textToSend = f"https://www.roblox.com/users/303400323/profile Last online {lastOnline}."
print(textToSend)
if previouslyOnline != online: # only if it is different to last time
print(previouslyOnline)
print(online)
requests.post("*", data={"content": textToSend})
previouslyOnline = online
sleep(60)
@Heliodex
Copy link
Author

Heliodex commented Jan 2, 2023

just remembered this
it was made in 25 minutes to beat @Mantaraix imagine using 3 days in c# to build the same thing but that actuall y works well

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