Skip to content

Commit

Permalink
Merge pull request TotalAwesome#10 from lvu22292718/main
Browse files Browse the repository at this point in the history
Hexn: Claim and start farming
  • Loading branch information
TotalAwesome authored Jul 20, 2024
2 parents aefe6da + e869fb1 commit 856994b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [anon](https://t.me/AnonEarnBot) (Нужно сперва зарегистрироваться в боте, рефералки можно искать в чате проекта)
- [hamster kombat](https://t.me/Hamster_kombat_bot/start?startapp=kentId102796269)
- [TapCoinsBot](https://t.me/tapcoinsbot/app?startapp=ref_QjG2zG)
- [HEXN](https://t.me/hexn_bot/app?startapp=63b093b0-fcb8-41b5-8f50-bc61983ef4e3)

Боты начнут последовательно фармить на каждом аккаунте

Expand Down
45 changes: 33 additions & 12 deletions bots/hexn/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from bots.base.base import BaseFarmer
from bots.hexn.strings import HEADERS, URL_INIT, URL_LOGIN, URL_START_FARMING, MSG_REFRESH, URL_REFRESH_TOKEN, \
MSG_FARMING_STARTED, MSG_FARMING_ALREADY_STARTED, MSG_FARMING_ERROR, MSG_UNKNOWN_RESPONSE
MSG_FARMING_STARTED, MSG_FARMING_ALREADY_STARTED, MSG_FARMING_ERROR, MSG_UNKNOWN_RESPONSE, URL_CLAIM, MSG_CLAIMED

DEFAULT_EST_TIME = 60 * 10

Expand All @@ -16,8 +16,9 @@ class BotFarmer(BaseFarmer):
auth_data = None
balance = None
end_time = None

initialization_data = dict(peer=name, bot=name, url=URL_INIT)
farming_data = None
referral = 'tgWebAppStartParam=63b093b0-fcb8-41b5-8f50-bc61983ef4e3'
initialization_data = dict(peer=name, bot=name, url=URL_INIT, start_param=referral)

def set_headers(self, *args, **kwargs):
self.headers = HEADERS.copy()
Expand All @@ -36,9 +37,9 @@ def authenticate(self, *args, **kwargs):
result = self.post(URL_LOGIN, json=data)

if result.status_code == 200:
jsonData = result.json()
json_data = result.json()

if jsonData['status'] == 'ERROR' and jsonData['error']['code'] == 'NOT_REGISTERED':
if json_data['status'] == 'ERROR' and json_data['error']['code'] == 'NOT_REGISTERED':
self.is_alive = False
return

Expand All @@ -54,24 +55,29 @@ def set_start_time(self):
est_time = DEFAULT_EST_TIME
self.start_time = time() + est_time

def start_farming(self):
def check_farming_status(self):
data = {
'platform': 'WEB',
}
result = self.post(URL_START_FARMING, json=data)

if result.status_code == 200:
response_json = result.json()

error = response_json.get('error')
data = response_json.get('data')

if error:
error_code = error.get('code')
if error_code == 'PENDING_FARMING_EXISTS':
self.log(MSG_FARMING_ALREADY_STARTED)
farming_details = error.get('details', {}).get('farming', {})
self.end_time = farming_details.get('end_at', 0) // 1000
details = error.get('details', {})
self.farming_data = details.get('farming', {})

if self.farming_data.get('end_at', 0) // 1000 > time():
self.log(MSG_FARMING_ALREADY_STARTED)
self.end_time = self.farming_data.get('end_at', 0) // 1000

return
else:
self.claim()
else:
self.log(MSG_FARMING_ERROR)
elif data:
Expand All @@ -96,5 +102,20 @@ def generate_fingerprint():

return hex_string

def claim(self):

data = {
'platform': 'WEB',
'farming_uuid': self.farming_data.get('uuid')
}

result = self.post(URL_CLAIM, json=data)
response_json = result.json()
if response_json.get('status') == 'OK':
self.log(MSG_CLAIMED)
self.check_farming_status()
else:
self.log(MSG_FARMING_ERROR)

def farm(self):
self.start_farming()
self.check_farming_status()
2 changes: 2 additions & 0 deletions bots/hexn/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
URL_LOGIN = 'https://api.hexn.cc/v1/kyc/auth/telegram/sign-in-mini-app'
URL_REFRESH_TOKEN = 'https://api.hexn.cc/v1/kyc/auth/telegram/sign-in-mini-app'
URL_START_FARMING = 'https://api.hexn.cc/v1/kyc/marketing/farming/start'
URL_CLAIM = 'https://api.hexn.cc/v1/kyc/marketing/farming/claim/'

HEADERS = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0'
Expand All @@ -13,3 +14,4 @@
MSG_FARMING_STARTED = "Фарминг успешно запущен"
MSG_FARMING_ERROR = "Ошибка фарминга"
MSG_UNKNOWN_RESPONSE = "Неизвестный ответ"
MSG_CLAIMED = 'Собрал монеты'

0 comments on commit 856994b

Please sign in to comment.