Add telegram restart
This commit is contained in:
@@ -423,26 +423,25 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, UberEatsBot, Weathe
|
|||||||
await super()._on_new_message_raw(message, whitelist_callbacks, blacklist_callbacks)
|
await super()._on_new_message_raw(message, whitelist_callbacks, blacklist_callbacks)
|
||||||
|
|
||||||
async def _on_ready(self):
|
async def _on_ready(self):
|
||||||
await super()._on_ready()
|
if not self._is_initialized:
|
||||||
if self._is_initialized:
|
flanautils.do_every(multibot_constants.CHECK_OLD_DATABASE_MESSAGES_EVERY_SECONDS, self.check_old_database_actions)
|
||||||
return
|
for chat in Chat.find({
|
||||||
|
'platform': self.platform.value,
|
||||||
|
'config.ubereats': {"$exists": True, "$eq": True},
|
||||||
|
'ubereats.cookies': {"$exists": True, "$ne": []}
|
||||||
|
}):
|
||||||
|
chat = await self.get_chat(chat.id)
|
||||||
|
chat.pull_from_database(overwrite_fields=('_id', 'config', 'ubereats'))
|
||||||
|
if (
|
||||||
|
chat.ubereats['next_execution']
|
||||||
|
and
|
||||||
|
(delta_time := chat.ubereats['next_execution'] - datetime.datetime.now(datetime.timezone.utc)) > datetime.timedelta()
|
||||||
|
):
|
||||||
|
flanautils.do_later(delta_time, self.start_ubereats, chat)
|
||||||
|
else:
|
||||||
|
await self.start_ubereats(chat)
|
||||||
|
|
||||||
flanautils.do_every(multibot_constants.CHECK_OLD_DATABASE_MESSAGES_EVERY_SECONDS, self.check_old_database_actions)
|
await super()._on_ready()
|
||||||
for chat in Chat.find({
|
|
||||||
'platform': self.platform.value,
|
|
||||||
'config.ubereats': {"$exists": True, "$eq": True},
|
|
||||||
'ubereats.cookies': {"$exists": True, "$ne": []}
|
|
||||||
}):
|
|
||||||
chat = await self.get_chat(chat.id)
|
|
||||||
chat.pull_from_database(overwrite_fields=('_id', 'config', 'ubereats'))
|
|
||||||
if (
|
|
||||||
chat.ubereats['next_execution']
|
|
||||||
and
|
|
||||||
(delta_time := chat.ubereats['next_execution'] - datetime.datetime.now(datetime.timezone.utc)) > datetime.timedelta()
|
|
||||||
):
|
|
||||||
flanautils.do_later(delta_time, self.start_ubereats, chat)
|
|
||||||
else:
|
|
||||||
await self.start_ubereats(chat)
|
|
||||||
|
|
||||||
@inline(False)
|
@inline(False)
|
||||||
async def _on_recover_message(self, message: Message):
|
async def _on_recover_message(self, message: Message):
|
||||||
|
|||||||
@@ -83,10 +83,11 @@ class FlanaTeleBot(TelegramBot, FlanaBot):
|
|||||||
await super()._on_new_message_raw(message, whitelist_callbacks, blacklist_callbacks)
|
await super()._on_new_message_raw(message, whitelist_callbacks, blacklist_callbacks)
|
||||||
|
|
||||||
async def _on_ready(self):
|
async def _on_ready(self):
|
||||||
await super()._on_ready()
|
|
||||||
if not self._is_initialized:
|
if not self._is_initialized:
|
||||||
await self._update_whitelist()
|
await self._update_whitelist()
|
||||||
|
|
||||||
|
await super()._on_ready()
|
||||||
|
|
||||||
# -------------------------------------------------------- #
|
# -------------------------------------------------------- #
|
||||||
# -------------------- PUBLIC METHODS -------------------- #
|
# -------------------- PUBLIC METHODS -------------------- #
|
||||||
# -------------------------------------------------------- #
|
# -------------------------------------------------------- #
|
||||||
|
|||||||
@@ -122,10 +122,11 @@ class PenaltyBot(MultiBot, ABC):
|
|||||||
await self.punish(user, message, flanautils.text_to_time(await self.filter_mention_ids(message.text, message)), message)
|
await self.punish(user, message, flanautils.text_to_time(await self.filter_mention_ids(message.text, message)), message)
|
||||||
|
|
||||||
async def _on_ready(self):
|
async def _on_ready(self):
|
||||||
await super()._on_ready()
|
|
||||||
if not self._is_initialized:
|
if not self._is_initialized:
|
||||||
flanautils.do_every(constants.CHECK_PUNISHMENTS_EVERY_SECONDS, self.check_old_punishments)
|
flanautils.do_every(constants.CHECK_PUNISHMENTS_EVERY_SECONDS, self.check_old_punishments)
|
||||||
|
|
||||||
|
await super()._on_ready()
|
||||||
|
|
||||||
@bot_mentioned
|
@bot_mentioned
|
||||||
@group
|
@group
|
||||||
@admin(send_negative=True)
|
@admin(send_negative=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user