From 8a23baf6265dfa66ef7c8cda79ccf0abaf3c29d9 Mon Sep 17 00:00:00 2001 From: AlberLC Date: Thu, 23 Mar 2023 05:09:00 +0100 Subject: [PATCH] Update FlanaBot send methods --- flanabot/bots/flana_bot.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/flanabot/bots/flana_bot.py b/flanabot/bots/flana_bot.py index 6a13fa7..9be4cc9 100644 --- a/flanabot/bots/flana_bot.py +++ b/flanabot/bots/flana_bot.py @@ -11,7 +11,7 @@ import pymongo import pytz from flanaapis import InstagramLoginError, MediaNotFoundError, PlaceNotFoundError from flanautils import return_if_first_empty -from multibot import BadRoleError, MultiBot, RegisteredCallback, Role, bot_mentioned, constants as multibot_constants, group, inline, owner +from multibot import BadRoleError, MultiBot, RegisteredCallback, Role, User, bot_mentioned, constants as multibot_constants, group, inline, owner from flanabot import constants from flanabot.bots.connect_4_bot import Connect4Bot @@ -456,12 +456,16 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, UberEatsBot, Weathe before_date = datetime.datetime.now(datetime.timezone.utc) - multibot_constants.DATABASE_MESSAGE_EXPIRATION_TIME BotAction.delete_many_raw({'platform': self.platform.value, 'date': {'$lte': before_date}}) - async def send_bye(self, message: Message) -> multibot_constants.ORIGINAL_MESSAGE: - return await self.send(random.choice((*constants.BYE_PHRASES, flanautils.CommonWords.random_time_greeting())), message) + async def send_bye(self, chat: int | str | User | Chat | Message) -> multibot_constants.ORIGINAL_MESSAGE: + chat = await self.get_chat(chat) + return await self.send(random.choice((*constants.BYE_PHRASES, flanautils.CommonWords.random_time_greeting())), chat) - async def send_hello(self, message: Message) -> multibot_constants.ORIGINAL_MESSAGE: - return await self.send(random.choice((*constants.HELLO_PHRASES, flanautils.CommonWords.random_time_greeting())), message) + async def send_hello(self, chat: int | str | User | Chat | Message) -> multibot_constants.ORIGINAL_MESSAGE: + chat = await self.get_chat(chat) + return await self.send(random.choice((*constants.HELLO_PHRASES, flanautils.CommonWords.random_time_greeting())), chat) - async def send_insult(self, message: Message) -> multibot_constants.ORIGINAL_MESSAGE | None: - await self.typing_delay(message) - return await self.send(random.choice(constants.INSULTS), message) + async def send_insult(self, chat: int | str | User | Chat | Message) -> multibot_constants.ORIGINAL_MESSAGE | None: + chat = await self.get_chat(chat) + async with await self.typing(chat): + await asyncio.sleep(random.randint(1, 3)) + return await self.send(random.choice(constants.INSULTS), chat)