Change _manage_exceptions context arg

This commit is contained in:
AlberLC
2022-06-06 04:22:26 +02:00
parent 7ad4c4052e
commit daef039ce5
2 changed files with 7 additions and 12 deletions

View File

@@ -191,7 +191,7 @@ class FlanaBot(MultiBot, ABC):
return flanautils.chunks(buttons_texts, 3) return flanautils.chunks(buttons_texts, 3)
@return_if_first_empty(exclude_self_types='FlanaBot', globals_=globals()) @return_if_first_empty(exclude_self_types='FlanaBot', globals_=globals())
async def _manage_exceptions(self, exceptions: BaseException | Iterable[BaseException], message: Message): async def _manage_exceptions(self, exceptions: BaseException | Iterable[BaseException], context: Chat | Message):
if not isinstance(exceptions, Iterable): if not isinstance(exceptions, Iterable):
exceptions = (exceptions,) exceptions = (exceptions,)
@@ -199,15 +199,15 @@ class FlanaBot(MultiBot, ABC):
try: try:
raise exception raise exception
except BadRoleError as e: except BadRoleError as e:
await self.send_error(f'Rol no encontrado en {e}', message) await self.send_error(f'Rol no encontrado en {e}', context)
except InstagramLoginError as e: except InstagramLoginError as e:
await self.send_error(f'No me puedo loguear en Instagram {random.choice(multibot_constants.SAD_EMOJIS)} 👉 {e}', message) await self.send_error(f'No me puedo loguear en Instagram {random.choice(multibot_constants.SAD_EMOJIS)} 👉 {e}', context)
except MediaNotFoundError as e: except MediaNotFoundError as e:
await self.send_error(f'No he podido sacar nada de {e.source} {random.choice(multibot_constants.SAD_EMOJIS)}', message) await self.send_error(f'No he podido sacar nada de {e.source} {random.choice(multibot_constants.SAD_EMOJIS)}', context)
except PlaceNotFoundError as e: except PlaceNotFoundError as e:
await self.send_error(f'No he podido encontrar "{e}" {random.choice(multibot_constants.SAD_EMOJIS)}', message) await self.send_error(f'No he podido encontrar "{e}" {random.choice(multibot_constants.SAD_EMOJIS)}', context)
except Exception as e: except Exception as e:
await super()._manage_exceptions(e, message) await super()._manage_exceptions(e, context)
@staticmethod @staticmethod
def _medias_sended_info(medias: Iterable[Media]) -> str: def _medias_sended_info(medias: Iterable[Media]) -> str:
@@ -343,12 +343,6 @@ class FlanaBot(MultiBot, ABC):
@group @group
@bot_mentioned @bot_mentioned
async def _on_config_list_show(self, message: Message): async def _on_config_list_show(self, message: Message):
# config_info = pprint.pformat(message.chat.config)
# config_info = flanautils.translate(config_info, {'{': None, '}': None, ',': None, 'True': '', "'": None, 'False': '❌'})
# config_info = config_info.splitlines()
# config_info = '\n'.join(config_info_.strip() for config_info_ in config_info)
# await self.send(f'<b>Estos son los ajustes del grupo:</b>\n\n<code>{config_info}</code>', message)
await self.send('<b>Estos son los ajustes del grupo:</b>\n\n', self._get_config_buttons(message), message) await self.send('<b>Estos son los ajustes del grupo:</b>\n\n', self._get_config_buttons(message), message)
async def _on_covid_chart(self, message: Message): # todo2 async def _on_covid_chart(self, message: Message): # todo2

View File

@@ -12,6 +12,7 @@ from flanabot.bots.flana_tele_bot import FlanaTeleBot
async def main(): async def main():
flana_disc_bot = FlanaDiscBot() flana_disc_bot = FlanaDiscBot()
flana_tele_bot = FlanaTeleBot() flana_tele_bot = FlanaTeleBot()
await asyncio.gather( await asyncio.gather(
flana_disc_bot.start(), flana_disc_bot.start(),
flana_tele_bot.start() flana_tele_bot.start()