Add FlanaBot._on_delete_until

This commit is contained in:
AlberLC
2023-08-05 00:55:06 +02:00
parent 7adfa819df
commit 69e352d5ec
2 changed files with 15 additions and 2 deletions

View File

@@ -12,7 +12,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, User, bot_mentioned, constants as multibot_constants, group, inline, owner
from multibot import BadRoleError, MultiBot, RegisteredCallback, Role, User, admin, bot_mentioned, constants as multibot_constants, group, inline, owner, reply
from flanabot import constants
from flanabot.bots.connect_4_bot import Connect4Bot
@@ -57,6 +57,9 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, UberEatsBot, Weathe
self.register(self._on_delete, multibot_constants.KEYWORDS['delete'])
self.register(self._on_delete, (multibot_constants.KEYWORDS['delete'], multibot_constants.KEYWORDS['message']))
self.register(self._on_delete_until, (multibot_constants.KEYWORDS['delete'], constants.KEYWORDS['until']))
self.register(self._on_delete_until, (multibot_constants.KEYWORDS['delete'], constants.KEYWORDS['until'], multibot_constants.KEYWORDS['message']))
self.register(self._on_hello, multibot_constants.KEYWORDS['hello'])
self.register(self._on_help, multibot_constants.KEYWORDS['help'])
@@ -246,7 +249,16 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, UberEatsBot, Weathe
await self.delete_message(message)
return
await self.clear(n_messages + 1, message.chat)
await self.clear(message.chat, n_messages + 1)
@inline(False)
@admin(send_negative=True)
@reply
async def _on_delete_until(self, message: Message):
if message.chat.is_group and not self.is_bot_mentioned(message):
return
await self.clear(message.chat, until_message=message.replied_message)
async def _on_hello(self, message: Message):
if message.chat.is_private or self.is_bot_mentioned(message):

View File

@@ -104,6 +104,7 @@ KEYWORDS = {
'sound', 'suena'),
'tunnel': ('canal', 'channel', 'tunel', 'tunnel'),
'unpunish': ('absolve', 'forgive', 'innocent', 'inocente', 'perdona', 'spare'),
'until': ('hasta', 'until'),
'vote': ('votacion', 'votar', 'vote', 'voting', 'voto'),
'weather': ('atmosfera', 'atmosferico', 'calle', 'calor', 'caloret', 'clima', 'climatologia', 'cloud', 'cloudless',
'cloudy', 'cold', 'congelar', 'congelado', 'denbora', 'despejado', 'diluvio', 'frio', 'frost', 'hielo',