From b31292919f543b68584890047b5110a1f8b9a5d4 Mon Sep 17 00:00:00 2001 From: Vitaly <7338823+zv09@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:32:16 +0300 Subject: [PATCH 1/2] subj: add a human behaviour simulation - tapping: 1. firstly tap recovered points 2. check for boost availability 3. grab the boost and await a time need to human tap it out, randomly in range 4. log it out - delay between attempt magnifiyer parameter - it is need to calculate a range of time will be used for delay between loop cycles - param must be set >=2 - it multiply delay_between_attempts for self value and make a range randomly [delay...delay * multiplyer] - minor change for pause between switching bot accounts and card upgrades to looks more human manual operations --- .gitignore | 3 ++- README.md | 3 +++ bot.py | 47 +++++++++++++++++++++++++++++------------------ config.py | 1 + hamster_client.py | 3 ++- strings.py | 1 + 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 9d1ed45..2981f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *local* __pycache__ -venv \ No newline at end of file +venv +commit.msg diff --git a/README.md b/README.md index e371efb..cde78f1 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ - Мультиаккаунтинг - Прокси +Дополнительные модификации: +- Смотрите описание в тегах к версиям + Все как обычно. 1. Установить Python (https://www.python.org/) diff --git a/bot.py b/bot.py index e4ddc39..182d460 100644 --- a/bot.py +++ b/bot.py @@ -1,28 +1,39 @@ from random import choice from hamster_client import BOOST_ENERGY, HamsterClient, sleep, logging from config import ACCOUNTS, FEATURES -from strings import DELIMITER +from strings import DELIMITER, CYCLE_BANNER clients = [HamsterClient(**options) for options in ACCOUNTS] def main(): - while True: - for client in clients: - print(DELIMITER) - client.sync() - client.claim_daily_cipher() - client.tap() - client.buy_upgrades() - client.check_task() - client.make_tasks() - client.claim_combo_reward() - if client.is_taps_boost_available: - client.boost(BOOST_ENERGY) - logging.info(client.log_prefix + " ".join(f"{k}: {v} |" for k, v in client.stats.items())) - print(DELIMITER) - sleep(choice(range(1, 10))) - delay_between_attempts = FEATURES.get('delay_between_attempts', 60 * 10) - sleep(choice(range(delay_between_attempts, delay_between_attempts + 60))) + cycle_count = 0 + print(DELIMITER) + while True: + cycle_count += 1 + print(CYCLE_BANNER.format(cycle_count = cycle_count)) + for client in clients: + print(DELIMITER) + if cycle_count == 1: + sleep(choice(range(10, 20))) + else: + sleep(choice(range(60, 120))) + client.sync() + client.claim_daily_cipher() + client.tap() + client.buy_upgrades() + client.check_task() + client.make_tasks() + client.claim_combo_reward() + if client.is_taps_boost_available: + client.boost(BOOST_ENERGY) + client.sync() + sleep(choice(range(110, 130))) + client.tap() + logging.info(client.log_prefix + " ".join(f"{k}: {v} |" for k, v in client.stats.items())) + print(DELIMITER) + delay_between_attempts_random_magnifier = FEATURES.get('delay_between_attempts_random_magnifier', 10) + delay_between_attempts = FEATURES.get('delay_between_attempts', 60) * choice(range(1, delay_between_attempts_random_magnifier)) + sleep(choice(range(delay_between_attempts, delay_between_attempts + 120))) if __name__ == "__main__": diff --git a/config.py b/config.py index 88b3667..060e92a 100644 --- a/config.py +++ b/config.py @@ -29,6 +29,7 @@ "buy_upgrades": True, "buy_decision_method": "payback", "delay_between_attempts": 60 * 10, # эта задержка будет применятся c доп. рандомом ( +/- 60сек ) + "delay_between_attempts_random_magnifier": 2, # Значение может быть только >=2; Определяет рандомно выбор макс. задержки; Если 2, то задержка выбрана между [delay_between_attempts..delay_between_attempts*delay_between_attempts_random_magnifier] "num_purchases_per_cycle": 5, "min_cash_value_in_balance": 10_000_000, } diff --git a/hamster_client.py b/hamster_client.py index df3e72b..9cf234e 100644 --- a/hamster_client.py +++ b/hamster_client.py @@ -133,6 +133,7 @@ def tap(self): def boost(self, boost_name=BOOST_ENERGY): data = {"boostId": boost_name, "timestamp": timestamp()} self.post(URL_BUY_BOOST, json=data) + logging.info(self.log_prefix + "Применил Boost: {boostype}".format(boostype = boost_name)) def upgrade(self, upgrade_name): data = {"upgradeId": upgrade_name, "timestamp": timestamp()} @@ -224,7 +225,7 @@ def buy_upgrades(self): self.state = result.json()["clickerUser"] logging.info(self.log_prefix + MSG_BUY_UPGRADE.format(**upgrade)) counter += 1 - sleep(choice(range(1, 10))) + sleep(choice(range(10, 30))) else: break else: diff --git a/strings.py b/strings.py index a2a1106..6c1ca4f 100644 --- a/strings.py +++ b/strings.py @@ -29,6 +29,7 @@ BOOST_ENERGY = "BoostFullAvailableTaps" DELIMITER = "=" * 150 +CYCLE_BANNER = "░" * 69 + " CYCLE {cycle_count} " + "░" * 69 HEADERS = { "Connection": "keep-alive", From ae8b7867f61a16dd2d874a62500b97ee98b65077 Mon Sep 17 00:00:00 2001 From: Vitaly <7338823+zv09@users.noreply.github.com> Date: Tue, 13 Aug 2024 00:20:11 +0300 Subject: [PATCH 2/2] MSG_TASK_COMPLETED' is not defined error issue --- hamster_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hamster_client.py b/hamster_client.py index 9cf234e..1bb6ccf 100644 --- a/hamster_client.py +++ b/hamster_client.py @@ -10,7 +10,8 @@ URL_CLAIM_DAILY_COMBO, MSG_BUY_UPGRADE, MSG_BAD_RESPONSE, MSG_SESSION_ERROR, \ MSG_COMBO_EARNED, MSG_TAP, MSG_CLAIMED_COMBO_CARDS, MSG_SYNC, URL_CONFIG, \ URL_CLAIM_DAILY_CIPHER, MSG_CIPHER, MSG_CRYPTED_CIPHER, MORSE_CODE_DICT, \ - URL_CHECK_IP, MSG_PROXY_CHECK_ERROR, MSG_PROXY_IP, MSG_PROXY_CONNECTION_ERROR + URL_CHECK_IP, MSG_PROXY_CHECK_ERROR, MSG_PROXY_IP, MSG_PROXY_CONNECTION_ERROR, \ + MSG_TASK_COMPLETED, MSG_TASK_NOT_COMPLETED logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")