Skip to content

Commit

Permalink
Config version request added.
Browse files Browse the repository at this point in the history
  • Loading branch information
masterking32 committed Aug 11, 2024
1 parent bd50201 commit d3a4a5b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ def __init__(self, AccountData):
self.telegram_chat_id = AccountData["telegram_chat_id"]
self.totalKeys = 0
self.balanceKeys = 0
self.configVersion = ""

def GetConfig(self, key, default=None):
if key in self.config:
return self.config[key]
return default

def SendTelegramLog(self, message, level):
if "telegramBotLogging" not in locals():
return

if (
not telegramBotLogging["is_active"]
or self.telegram_chat_id == ""
Expand Down Expand Up @@ -186,6 +190,9 @@ def HttpRequest(
)
return None

if "config-version" in response.headers:
self.configVersion = response.headers["config-version"]

if method == "OPTIONS":
return True

Expand Down Expand Up @@ -492,6 +499,26 @@ def GetAccountConfigRequest(self):
# Send POST request
return self.HttpRequest(url, headers, "POST", 200)

def GetAccountConfigVersionRequest(self):
if self.configVersion == "":
return None

url = f"https://api.hamsterkombatgame.io/clicker/config/{self.configVersion}"
headers = {
"Access-Control-Request-Headers": "authorization",
"Access-Control-Request-Method": "POST",
}

# Send OPTIONS request
self.HttpRequest(url, headers, "OPTIONS", 204)

headers = {
"Authorization": self.Authorization,
}

# Send POST request
return self.HttpRequest(url, headers, "POST", 200)

def ClaimDailyCipherRequest(self, DailyCipher):
url = "https://api.hamsterkombatgame.io/clicker/claim-daily-cipher"
headers = {
Expand Down Expand Up @@ -1084,6 +1111,13 @@ def Start(self):
)

log.info(f"[{self.account_name}] Getting account config data...")
AccountConfigVersionData = None
if self.configVersion != "":
AccountConfigVersionData = self.GetAccountConfigVersionRequest()
log.info(
f"[{self.account_name}] Account config version: {self.configVersion}"
)

AccountConfigData = self.GetAccountConfigRequest()
if AccountConfigData is None or AccountConfigData is False:
log.error(f"[{self.account_name}] Unable to get account config data.")
Expand Down

0 comments on commit d3a4a5b

Please sign in to comment.