Created
November 28, 2024 14:50
-
-
Save woctezuma/8817d73e6f68ef2a2a7d4c9e269be1e0 to your computer and use it in GitHub Desktop.
Write and delete a review for the Steam Awards 2024
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
BASE_URL = "http://localhost:1242" | |
TIMEOUT_IN_SECONDS = 3 | |
def publish_review(bot_name: str, app_id: int) -> requests.Response: | |
endpoint = "/Api/Recommend/PublishReview/" | |
data = { | |
"Recommends": [ | |
{ | |
"AppId": app_id, | |
"RateUp": True, | |
"AllowReply": True, | |
"ForFree": True, | |
"Public": True, | |
"Comment": "This is my review for the Steam Awards.", | |
}, | |
], | |
} | |
return requests.post( | |
url=f"{BASE_URL}{endpoint}{bot_name}", | |
json=data, | |
timeout=TIMEOUT_IN_SECONDS, | |
) | |
def delete_review(bot_name: str, app_id: int) -> requests.Response: | |
endpoint = "/Api/Recommend/DeleteReview/" | |
data = { | |
"AppIds": [app_id], | |
} | |
return requests.post( | |
url=f"{BASE_URL}{endpoint}{bot_name}", | |
json=data, | |
timeout=TIMEOUT_IN_SECONDS, | |
) | |
def is_successful(r: requests.Response, bot_name: str, app_id: int) -> bool: | |
d = json.loads(r.text) | |
return d["Result"][bot_name][str(app_id)] | |
def main() -> None: | |
for bot_name in ["MyBot_A", "MyBot_B", "MyBot_C"]: | |
app_id = 2570630 | |
r = publish_review(bot_name, app_id) | |
if is_successful(r, bot_name, app_id): | |
delete_review(bot_name, app_id) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: chr233/ASFEnhance#340