shamhi / TapSwapBot

Bot that mines coins in Tapswap
https://t.me/tapswap_bot
246 stars 81 forks source link

Developers help #194

Open mrdarkerr opened 1 month ago

mrdarkerr commented 1 month ago
async def send_taps(self, http_client: aiohttp.ClientSession, taps: int) -> dict[str]:
        response_text = ''
        try:
            timestamp = int(time() * 1000)
            content_id = int((timestamp * self.user_id * self.user_id / self.user_id) % self.user_id % self.user_id)

            json_data = {'taps': taps, 'time': timestamp}

            http_client.headers['Content-Id'] = str(content_id)

            response = await http_client.post(url='https://api.tapswap.club/api/player/submit_taps', json=json_data)
            response_text = await response.text()
            response.raise_for_status()

            response_json = await response.json()
            player_data = response_json['player']

            return player_data
        except Exception as error:
            logger.error(f"{self.session_name} | Unknown error when Tapping: {escape_html(error)} | "
                         f"Response text: {escape_html(response_text)[:128]}...")
            return{}

After running the script for some time, I get the error Unknown error when Tapping: 400, message='Bad Request'

And after restarting the script, the problem is solved I am not a Python programmer and I want you to help me to reset all tasks in case of an error in the send_taps function as if I restarted the script. As if I started the script and selected the number 2

I would be very grateful if you could help me

mrdarkerr commented 1 month ago

If you have a more logical solution for this, that's better

I would also like to add that as you said, one of the users said that I started a bot for each session, but it had no effect