dragxd commited on
Commit
dadaa53
·
1 Parent(s): 36102f9

fixed the bot.py

Browse files
Files changed (1) hide show
  1. core/bot.py +8 -1
core/bot.py CHANGED
@@ -61,7 +61,9 @@ class Bot(TelegramClient):
61
  kwargs["api_id"] = api_id or Var.API_ID
62
  kwargs["api_hash"] = api_hash or Var.API_HASH
63
  kwargs["base_logger"] = TelethonLogger
64
- utils.MIN_CHANNEL_ID = -1009147483647
 
 
65
  super().__init__(None, **kwargs)
66
  self.pyro_client = Client(
67
  name="pekka",
@@ -97,6 +99,11 @@ class Bot(TelegramClient):
97
  self.logger.critical("String session expired. Create new!")
98
  sys.exit(1)
99
  self.logger.critical("String session expired.")
 
 
 
 
 
100
  except (AccessTokenExpiredError, AccessTokenInvalidError):
101
  self.logger.critical(
102
  "Bot token is expired or invalid. Create new from @Botfather and add in BOT_TOKEN env variable!"
 
61
  kwargs["api_id"] = api_id or Var.API_ID
62
  kwargs["api_hash"] = api_hash or Var.API_HASH
63
  kwargs["base_logger"] = TelethonLogger
64
+ kwargs["connection_retries"] = 3
65
+ kwargs["timeout"] = 30
66
+ utils.MIN_CHANNEL_ID = -1002881690459
67
  super().__init__(None, **kwargs)
68
  self.pyro_client = Client(
69
  name="pekka",
 
99
  self.logger.critical("String session expired. Create new!")
100
  sys.exit(1)
101
  self.logger.critical("String session expired.")
102
+ except ConnectionError as e:
103
+ self.logger.error(f"Connection failed: {e}")
104
+ self.logger.info("Retrying connection in 10 seconds...")
105
+ await asyncio.sleep(10)
106
+ await self.start_client(**kwargs)
107
  except (AccessTokenExpiredError, AccessTokenInvalidError):
108
  self.logger.critical(
109
  "Bot token is expired or invalid. Create new from @Botfather and add in BOT_TOKEN env variable!"