3 Commits

Author SHA1 Message Date
AlberLC
5fb55404cf Fix commands at private 2022-06-23 03:10:49 +02:00
AlberLC
2768d8e949 Fix commands at private 2022-06-23 02:17:59 +02:00
AlberLC
b0ca5a2ded Add ports to db local access 2022-06-23 02:17:33 +02:00
2 changed files with 12 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ services:
mongodb:
image: mongo
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USER}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}

View File

@@ -299,8 +299,10 @@ class FlanaBot(MultiBot, ABC):
if not message.chat.is_group or self.is_bot_mentioned(message):
await self.send_bye(message)
@bot_mentioned
async def _on_choose(self, message: Message):
if message.chat.is_group and not self.is_bot_mentioned(message):
return
discarded_words = {*constants.KEYWORDS['choose'], *constants.KEYWORDS['random'], self.name, f'<@{self.id}>'}
if final_words := [word for word in message.text.split() if not flanautils.cartesian_product_string_matching(word.lower(), discarded_words, min_ratio=multibot_constants.PARSE_CALLBACKS_MIN_RATIO_DEFAULT)]:
await self.send(random.choice(final_words), message)
@@ -310,7 +312,7 @@ class FlanaBot(MultiBot, ABC):
async def _on_config_button_press(self, message: Message):
await self._accept_button_event(message)
if not message.buttons_info.presser_user.is_admin:
if message.buttons_info.presser_user.is_admin is False:
return
config = message.buttons_info.pressed_text.split()[1]
@@ -381,8 +383,10 @@ class FlanaBot(MultiBot, ABC):
async def _on_delete_original_config_show(self, message: Message):
await self._show_config('auto_delete_original', message)
@bot_mentioned
async def _on_dice(self, message: Message):
if message.chat.is_group and not self.is_bot_mentioned(message):
return
if top_number := flanautils.sum_numbers_in_text(message.text):
await self.send(random.randint(1, top_number), message)
else:
@@ -436,8 +440,10 @@ class FlanaBot(MultiBot, ABC):
def _distribute_poll_buttons(self, texts: Sequence[str]) -> list[list[str]]:
pass
@bot_mentioned
async def _on_poll(self, message: Message):
if message.chat.is_group and not self.is_bot_mentioned(message):
return
discarded_words = {*constants.KEYWORDS['poll'], self.name.lower(), f'<@{self.id}>'}
if final_options := [option.title() for option in message.text.split() if not flanautils.cartesian_product_string_matching(option.lower(), discarded_words, min_ratio=multibot_constants.PARSE_CALLBACKS_MIN_RATIO_DEFAULT)]:
await self.send('Encuesta en curso...', self._distribute_poll_buttons(final_options), message, buttons_key=ButtonsGroup.POLL, contents={'poll': {'is_active': True, 'votes': {option: [] for option in final_options}}})