0% found this document useful (0 votes)
69 views2 pages

Code Pal Result

Uploaded by

checkingminer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views2 pages

Code Pal Result

Uploaded by

checkingminer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import requests

import json

class GorillaTagPlayerTracker:
"""
Class to track Gorilla Tag players and send their codes to a Discord webhook.

Attributes:
-
webhook_url:https://discord.com/channels/1155884798896787596/1265343146049540127
The URL of the Discord webhook to send the player codes to.
"""

def __init__(self, webhook_url: str):


"""
Constructor to instantiate the GorillaTagPlayerTracker class.

Parameters:
- webhook_url: str
The URL of the Discord webhook to send the player codes to.
"""

self.webhook_url = webhook_url

def track_player_codes(self, playfab_id: str):


"""
Tracks the codes that a Gorilla Tag player goes into and sends them to the
Discord webhook.

Parameters:
- playfab_id:FB5FCEBC4A0E0387
The PlayFab ID of the player to track.

Returns:
- bool:
True if the tracking and sending of codes is successful, False
otherwise.
"""

# Make a request to the Gorilla Tag API to get the player's codes
api_url = f"https://api.gorillatagstats.com/player/{playfab_id}/codes"
response = requests.get(api_url)

# Check if the request was successful


if response.status_code == 200:
# Parse the response JSON
codes = json.loads(response.text)

# Extract the username and codes from the response


username = codes['username']
player_codes = codes['codes']

# Send the username and codes to the Discord webhook


discord_message = f"{username} {player_codes}"
payload = {
"content": discord_message
}
response = requests.post(self.webhook_url, json=payload)
# Check if the webhook request was successful
if response.status_code == 204:
return True
else:
return False
else:
return False

# Example of using the GorillaTagPlayerTracker class:

# Example 1: Tracking a player's codes and sending them to Discord


webhook_url = "https://discord.com/api/webhooks/your-webhook-url"
tracker = GorillaTagPlayerTracker(webhook_url)
playfab_id = "your-playfab-id"
success = tracker.track_player_codes(playfab_id)
if success:
print("Player codes tracked and sent to Discord successfully.")
else:
print("Failed to track player codes or send them to Discord.")

You might also like