mirror of
https://codeberg.org/vlw/labylib.git
synced 2025-09-13 17:43:41 +02:00
Added new cosmetic "Moose Hat"
This commit is contained in:
parent
c8fe34620d
commit
69f46ec52b
1 changed files with 67 additions and 0 deletions
67
labylib/MooseHat.py
Normal file
67
labylib/MooseHat.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
import requests
|
||||
|
||||
class Visibility:
|
||||
|
||||
endpoint = "https://www.labymod.net/api/change"
|
||||
|
||||
def __init__(self,cookie):
|
||||
self.cookies = dict(PHPSESSID = cookie)
|
||||
|
||||
self.headers = {
|
||||
"accept": "*/*",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"accept-language": "en-US,en;q=0.9,sv;q=0.8",
|
||||
"cache-control": "no-cache",
|
||||
"dnt": "1",
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0",
|
||||
"origin": "https://www.labymod.net",
|
||||
"pragma": "no-cache",
|
||||
"referer": "https://www.labymod.net/dashboard",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-requested-with": "XMLHttpRequest",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
}
|
||||
|
||||
self.body = ""
|
||||
|
||||
# Payload
|
||||
self.addEncodedFormData("type","switch")
|
||||
self.addEncodedFormData("item",576242)
|
||||
self.addEncodedFormData("site","control")
|
||||
|
||||
# -----------------------------------
|
||||
|
||||
# Add URLEncoded form data (x-www-form-urlencoded)
|
||||
def addEncodedFormData(self,key,value):
|
||||
body = "&"
|
||||
|
||||
# Remove '&' delimiter for first item
|
||||
if(self.body == ""):
|
||||
body = ""
|
||||
|
||||
body += f"{key}={value}"
|
||||
|
||||
self.body += body
|
||||
|
||||
# -----------------------------------
|
||||
|
||||
def update(self,value):
|
||||
# Interpret strings
|
||||
if(type(value) != int):
|
||||
if(value == "show"):
|
||||
value = 1
|
||||
else:
|
||||
value = 0
|
||||
|
||||
self.addEncodedFormData("value",value)
|
||||
|
||||
request = requests.post(Visibility.endpoint,
|
||||
headers = self.headers,
|
||||
cookies = self.cookies,
|
||||
data = self.body
|
||||
)
|
||||
|
||||
# Raise exception if request fails
|
||||
request.raise_for_status()
|
Loading…
Add table
Reference in a new issue