Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

subj: add a human behaviour simulation #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*local*
__pycache__
venv
venv
commit.msg
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- Мультиаккаунтинг
- Прокси

Дополнительные модификации:
- Смотрите описание в тегах к версиям

Все как обычно.

1. Установить Python (https://www.python.org/)
Expand Down
47 changes: 29 additions & 18 deletions bot.py
Original file line number Diff line number Diff line change
@@ -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__":
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
6 changes: 4 additions & 2 deletions hamster_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -133,6 +134,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()}
Expand Down Expand Up @@ -224,7 +226,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:
Expand Down
1 change: 1 addition & 0 deletions strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

BOOST_ENERGY = "BoostFullAvailableTaps"
DELIMITER = "=" * 150
CYCLE_BANNER = "░" * 69 + " CYCLE {cycle_count} " + "░" * 69

HEADERS = {
"Connection": "keep-alive",
Expand Down