generated from nathanwoodburn/firewallet-plugin-template
80 lines
2.2 KiB
Python
80 lines
2.2 KiB
Python
import json
|
|
import account
|
|
import requests
|
|
|
|
# Plugin Data
|
|
info = {
|
|
"name": "Shakestation",
|
|
"description": "Connect to Shakestation",
|
|
"version": "1.0",
|
|
"author": "Nathan.Woodburn/"
|
|
}
|
|
|
|
# Functions
|
|
functions = {
|
|
"main":{
|
|
"name": "Function name",
|
|
"type": "default",
|
|
"description": "Description",
|
|
"params": {},
|
|
"returns": {
|
|
"status":
|
|
{
|
|
"name": "Status of the function",
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"domain_info": {
|
|
"name": "Domain info",
|
|
"type": "search",
|
|
"description": "Check if Shakestation has information on a domain",
|
|
"params": {},
|
|
"returns": {
|
|
"info":
|
|
{
|
|
"name": "Shakestation information",
|
|
"type": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def main(params, authentication):
|
|
return {"status": "Success"}
|
|
|
|
def domain_info(params, authentication):
|
|
domain = params.get("domain")
|
|
if not domain:
|
|
return {"info": "No domain provided"}
|
|
|
|
response = requests.post(f"https://shakestation.io/api",
|
|
data={"action":"getTLD","tld":domain})
|
|
|
|
if response.status_code != 200:
|
|
return {"info": "Failed to fetch data from Shakestation"}
|
|
data = response.json()
|
|
|
|
# Parse info
|
|
if "data" not in data:
|
|
return {"info": "No data found for the provided domain"}
|
|
if "type" not in data["data"]:
|
|
return {"info": "No type found in the data"}
|
|
domainType = data["data"]["type"]
|
|
if domainType == "marketplace":
|
|
score = data["data"].get("score", "No score available")
|
|
price = data["data"].get("price", "No price available")
|
|
return {"info": f"Domain is listed on Shakestation with score {score} and price {price}"}
|
|
|
|
|
|
|
|
|
|
|
|
return {"info": f"TODO: {domainType} domain type not implemented yet. Data: {data}"}
|
|
|
|
if __name__ == "__main__":
|
|
# Example usage
|
|
params = {"domain": "pinwheelgalaxy"}
|
|
authentication = None # Replace with actual authentication if needed
|
|
result = domain_info(params, authentication)
|
|
print(json.dumps(result, indent=2)) |