Update poll_bot._add_handlers
This commit is contained in:
@@ -28,26 +28,30 @@ class PollBot(MultiBot, ABC):
|
||||
self.register(self._on_choose, constants.KEYWORDS['random'], priority=2)
|
||||
self.register(self._on_choose, (constants.KEYWORDS['choose'], constants.KEYWORDS['random']), priority=2)
|
||||
|
||||
self.register(self._on_delete_all_votes, (multibot_constants.KEYWORDS['deactivate'], multibot_constants.KEYWORDS['all'], constants.KEYWORDS['vote']))
|
||||
self.register(self._on_delete_all_votes, (multibot_constants.KEYWORDS['delete'], multibot_constants.KEYWORDS['all'], constants.KEYWORDS['vote']))
|
||||
self.register(lambda message: self._on_delete_votes(message, all_=True), (multibot_constants.KEYWORDS['deactivate'], multibot_constants.KEYWORDS['all'], constants.KEYWORDS['vote']), priority=2)
|
||||
self.register(lambda message: self._on_delete_votes(message, all_=True), (multibot_constants.KEYWORDS['delete'], multibot_constants.KEYWORDS['all'], constants.KEYWORDS['vote']), priority=2)
|
||||
self.register(lambda message: self._on_delete_votes(message, all_=True), multibot_constants.KEYWORDS['reset'], priority=2)
|
||||
self.register(lambda message: self._on_delete_votes(message, all_=True), (multibot_constants.KEYWORDS['reset'], constants.KEYWORDS['poll']), priority=2)
|
||||
|
||||
self.register(self._on_delete_votes, (multibot_constants.KEYWORDS['deactivate'], constants.KEYWORDS['vote']))
|
||||
self.register(self._on_delete_votes, (multibot_constants.KEYWORDS['delete'], constants.KEYWORDS['vote']))
|
||||
self.register(self._on_delete_votes, (multibot_constants.KEYWORDS['deactivate'], constants.KEYWORDS['vote']), priority=2)
|
||||
self.register(self._on_delete_votes, (multibot_constants.KEYWORDS['delete'], constants.KEYWORDS['vote']), priority=2)
|
||||
|
||||
self.register(self._on_dice, constants.KEYWORDS['dice'])
|
||||
|
||||
self.register(self._on_poll, constants.KEYWORDS['poll'], priority=2)
|
||||
self.register(self._on_poll, constants.KEYWORDS['vote'], priority=2)
|
||||
|
||||
self.register(self._on_poll_multi, (constants.KEYWORDS['poll'], constants.KEYWORDS['multiple_answer']), priority=2)
|
||||
self.register(self._on_poll_multi, (constants.KEYWORDS['vote'], constants.KEYWORDS['multiple_answer']), priority=2)
|
||||
|
||||
self.register(self._on_stop_poll, multibot_constants.KEYWORDS['deactivate'])
|
||||
self.register(self._on_stop_poll, (multibot_constants.KEYWORDS['deactivate'], constants.KEYWORDS['poll']))
|
||||
self.register(self._on_stop_poll, multibot_constants.KEYWORDS['stop'])
|
||||
self.register(self._on_stop_poll, (multibot_constants.KEYWORDS['stop'], constants.KEYWORDS['poll']))
|
||||
self.register(self._on_stop_poll, multibot_constants.KEYWORDS['deactivate'], priority=2)
|
||||
self.register(self._on_stop_poll, (multibot_constants.KEYWORDS['deactivate'], constants.KEYWORDS['poll']), priority=2)
|
||||
self.register(self._on_stop_poll, multibot_constants.KEYWORDS['stop'], priority=2)
|
||||
self.register(self._on_stop_poll, (multibot_constants.KEYWORDS['stop'], constants.KEYWORDS['poll']), priority=2)
|
||||
|
||||
self.register(self._on_voting_ban, (multibot_constants.KEYWORDS['deactivate'], multibot_constants.KEYWORDS['permission'], constants.KEYWORDS['vote']))
|
||||
self.register(self._on_voting_ban, (multibot_constants.KEYWORDS['deactivate'], multibot_constants.KEYWORDS['permission'], constants.KEYWORDS['vote']), priority=2)
|
||||
|
||||
self.register(self._on_voting_unban, (multibot_constants.KEYWORDS['activate'], multibot_constants.KEYWORDS['permission'], constants.KEYWORDS['vote']))
|
||||
self.register(self._on_voting_unban, (multibot_constants.KEYWORDS['activate'], multibot_constants.KEYWORDS['permission'], constants.KEYWORDS['vote']), priority=2)
|
||||
|
||||
self.register_button(self._on_poll_button_press, ButtonsGroup.POLL)
|
||||
|
||||
@@ -125,9 +129,6 @@ class PollBot(MultiBot, ABC):
|
||||
else:
|
||||
await self.send(random.choice(('¿Que elija el qué?', '¿Y las opciones?', '?', '🤔')), message)
|
||||
|
||||
async def _on_delete_all_votes(self, message: Message):
|
||||
await self._on_delete_votes(message, all_=True)
|
||||
|
||||
async def _on_delete_votes(self, message: Message, all_=False):
|
||||
if not (poll_message := self._get_poll_message(message)):
|
||||
return
|
||||
@@ -161,7 +162,7 @@ class PollBot(MultiBot, ABC):
|
||||
if message.chat.is_group and not self.is_bot_mentioned(message):
|
||||
return
|
||||
|
||||
discarded_words = {*constants.KEYWORDS['poll'], *constants.KEYWORDS['multiple_answer'], self.name.lower(), f'<@{self.id}>'}
|
||||
discarded_words = {*constants.KEYWORDS['poll'], *constants.KEYWORDS['vote'], *constants.KEYWORDS['multiple_answer'], self.name.lower(), f'<@{self.id}>'}
|
||||
if final_options := [f'{option[0].upper()}{option[1:]}' for option in self._get_options(message.text, discarded_words)]:
|
||||
buttons = self.distribute_buttons(final_options, vertically=True)
|
||||
await self.send(
|
||||
|
||||
Reference in New Issue
Block a user