Skip to content

Instantly share code, notes, and snippets.

@Zzz9194
Last active April 16, 2020 07:21
Show Gist options
  • Save Zzz9194/e8d34da29f4c24725f20cbafc27d3602 to your computer and use it in GitHub Desktop.
Save Zzz9194/e8d34da29f4c24725f20cbafc27d3602 to your computer and use it in GitHub Desktop.
import requests
def psaCheck(uid) -> str:
# A list of all valid NHC group
allGroups = ['mayflower department of justice','new haven county transit authority','mayflower national guard','mayflower public broadcasting service','mayflower state legislature','mayflower parks and wildlife department','lander police department','mayflower state police','mayflower courts','plymouth police department','new haven county fire department','new haven county sherrifs office']
userGroups = getGroups(uid) # The dictionary of all a users' groups
counter = 0 # <- Keeps track of the number of violations
for group in list(userGroups.keys()):
# The keys are all the group names
if group in allGroups:
# All role checking rules
if group == 'mayflower national guard':
if userGroups[group].lower() in ['colonel','brigadier general','major general']: # Colonel+ Roles are valid in the PSA
counter += 1
else:
pass
elif group == "mayflower public broadcasting service":
if userGroups[group].lower() == 'part-time employee': # Part time employees are the only ones excused from PSA violations
pass
else:
counter += 1
elif group == "mayflower state legislature":
if userGroups[group].lower() in ["senator",'president pro tempore']: # The only people in the senate who count as a violation
counter += 1
else:
pass
elif group == "mayflower courts":
if userGroups[group].lower() in ['district court','chief judge','supreme court','chief justice']: # The only people in the court who count as a violation
counter += 1
else:
pass
else:
counter += 1 # If none of the groups are a specified violation then you pass
if counter > 2: # If there's more than two PSA violations its illegal -- Otherwise it's fine
print(f"{id_to_name(uid)} is making a PSA violation. They are in the following groups -> " + str(userGroups))
else:
print(f"{id_to_name(uid)} has not made a PSA violation")
def getGroups(uid) -> str:
# Gets all groups and passes them into a dictionary in a specific format
r = requests.get(f"https://groups.roblox.com/v2/users/{uid}/groups/roles").json()
memberList = {}
for group in r['data']:
# Passes a dictionary where the key is the group name and the value to that key is the group role E.g. {"Mayflower State Police":"Corporal"}
memberList[group['group']['name']] = group['role']['name']
return memberList
def id_to_name(uid) -> str:
# Changes your given userID into a username
r = requests.get(f"https://api.roblox.com/users/{uid}").json()
username = r['Username']
return username
psaCheck(175656524)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment