Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2e7e68619 | ||
|
|
f12d0c18c1 | ||
|
|
b55f933a32 | ||
|
|
5fa102b157 | ||
|
|
1e8a33c0c4 | ||
|
|
daef039ce5 | ||
|
|
7ad4c4052e | ||
|
|
641dc72738 | ||
|
|
cafa7ce1c5 |
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['FlanaBot']
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
@@ -10,12 +12,13 @@ import flanaapis.geolocation.functions
|
|||||||
import flanaapis.weather.functions
|
import flanaapis.weather.functions
|
||||||
import flanautils
|
import flanautils
|
||||||
import plotly.graph_objects
|
import plotly.graph_objects
|
||||||
|
import pymongo
|
||||||
from flanaapis import InstagramLoginError, MediaNotFoundError, Place, PlaceNotFoundError, WeatherEmoji, instagram, tiktok, twitter
|
from flanaapis import InstagramLoginError, MediaNotFoundError, Place, PlaceNotFoundError, WeatherEmoji, instagram, tiktok, twitter
|
||||||
from flanautils import Media, MediaType, NotFoundError, OrderedSet, Source, TimeUnits, TraceMetadata, return_if_first_empty
|
from flanautils import Media, MediaType, NotFoundError, OrderedSet, Source, TimeUnits, TraceMetadata, return_if_first_empty
|
||||||
from multibot import Action, BadRoleError, BotAction, MultiBot, SendError, User, admin, bot_mentioned, constants as multibot_constants, group, ignore_self_message, inline, reply
|
from multibot import Action, BadRoleError, BotAction, MultiBot, SendError, User, admin, bot_mentioned, constants as multibot_constants, group, ignore_self_message, inline, reply
|
||||||
|
|
||||||
from flanabot import constants
|
from flanabot import constants
|
||||||
from flanabot.models import ButtonsMessageType, Chat, Message, Punishment, WeatherChart
|
from flanabot.models import Chat, Message, Punishment, WeatherChart
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------- #
|
# ----------------------------------------------------------------------------------------------------- #
|
||||||
@@ -128,7 +131,8 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
self.register(self._on_weather_chart_config_show, (constants.KEYWORDS['weather_chart'], multibot_constants.KEYWORDS['config']))
|
self.register(self._on_weather_chart_config_show, (constants.KEYWORDS['weather_chart'], multibot_constants.KEYWORDS['config']))
|
||||||
self.register(self._on_weather_chart_config_show, (multibot_constants.KEYWORDS['show'], constants.KEYWORDS['weather_chart'], multibot_constants.KEYWORDS['config']))
|
self.register(self._on_weather_chart_config_show, (multibot_constants.KEYWORDS['show'], constants.KEYWORDS['weather_chart'], multibot_constants.KEYWORDS['config']))
|
||||||
|
|
||||||
self.register_button(self._on_button_press)
|
self.register_button(self._on_config_button_press, list(Chat.DEFAULT_CONFIG.keys()))
|
||||||
|
self.register_button(self._on_weather_button_press, WeatherEmoji.values)
|
||||||
|
|
||||||
async def _change_config(self, config_name: str, message: Message, value: bool = None):
|
async def _change_config(self, config_name: str, message: Message, value: bool = None):
|
||||||
if value is None:
|
if value is None:
|
||||||
@@ -148,20 +152,15 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
last_2s_messages = Message.find({
|
last_2s_messages = Message.find({
|
||||||
'platform': self.platform.value,
|
'platform': self.platform.value,
|
||||||
'author': message.author.object_id,
|
'author': message.author.object_id,
|
||||||
'last_update': {
|
'last_update': {'$gte': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=2)}
|
||||||
'$gte': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=2)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
last_7s_messages = Message.find({
|
last_7s_messages = Message.find({
|
||||||
'platform': self.platform.value,
|
'platform': self.platform.value,
|
||||||
'author': message.author.object_id,
|
'author': message.author.object_id,
|
||||||
'last_update': {
|
'last_update': {'$gte': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=7)}
|
||||||
'$gte': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=7),
|
|
||||||
'$lt': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=2)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(last_2s_messages) >= 5 or len(last_7s_messages) >= 7:
|
if len(last_2s_messages) >= constants.FLOOD_2s_LIMIT or len(last_7s_messages) >= constants.FLOOD_7s_LIMIT:
|
||||||
n_punishments = len(Punishment.find({
|
n_punishments = len(Punishment.find({
|
||||||
'platform': self.platform.value,
|
'platform': self.platform.value,
|
||||||
'user_id': message.author.id,
|
'user_id': message.author.id,
|
||||||
@@ -184,10 +183,11 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
config = message.chat.config
|
config = message.chat.config
|
||||||
|
|
||||||
buttons_texts = [f"{'✔' if v else '❌'} {k}" for k, v in config.items()]
|
buttons_texts = [f"{'✔' if v else '❌'} {k}" for k, v in config.items()]
|
||||||
|
# noinspection PyTypeChecker
|
||||||
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,)
|
||||||
|
|
||||||
@@ -195,15 +195,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:
|
||||||
@@ -292,59 +292,23 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
# ---------------------------------------------- #
|
# ---------------------------------------------- #
|
||||||
# HANDLERS #
|
# HANDLERS #
|
||||||
# ---------------------------------------------- #
|
# ---------------------------------------------- #
|
||||||
async def _on_button_press(self, message: Message):
|
|
||||||
await self._accept_button_event(message)
|
|
||||||
|
|
||||||
match message.button_pressed_text:
|
|
||||||
case WeatherEmoji.ZOOM_IN.value:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
message.weather_chart.zoom_in()
|
|
||||||
case WeatherEmoji.ZOOM_OUT.value:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
message.weather_chart.zoom_out()
|
|
||||||
case WeatherEmoji.LEFT.value:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
message.weather_chart.move_left()
|
|
||||||
case WeatherEmoji.RIGHT.value:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
message.weather_chart.move_right()
|
|
||||||
case WeatherEmoji.PRECIPITATION_VOLUME.value:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
message.weather_chart.trace_metadatas['rain_volume'].show = not message.weather_chart.trace_metadatas['rain_volume'].show
|
|
||||||
message.weather_chart.trace_metadatas['snow_volume'].show = not message.weather_chart.trace_metadatas['snow_volume'].show
|
|
||||||
case emoji if emoji in WeatherEmoji.values:
|
|
||||||
buttons_message_type = ButtonsMessageType.WEATHER
|
|
||||||
trace_metadata_name = WeatherEmoji(emoji).name.lower()
|
|
||||||
message.weather_chart.trace_metadatas[trace_metadata_name].show = not message.weather_chart.trace_metadatas[trace_metadata_name].show
|
|
||||||
case _ if message.button_pressed_user.is_admin and 'auto_' in (config := message.button_pressed_text.split()[1]):
|
|
||||||
buttons_message_type = ButtonsMessageType.CONFIG
|
|
||||||
message.chat.config[config] = not message.chat.config[config]
|
|
||||||
message.save()
|
|
||||||
await self.edit('<b>Estos son los ajustes del grupo:</b>\n\n', self._get_config_buttons(message), message)
|
|
||||||
case _:
|
|
||||||
return
|
|
||||||
|
|
||||||
if buttons_message_type is ButtonsMessageType.WEATHER:
|
|
||||||
message.weather_chart.apply_zoom()
|
|
||||||
message.weather_chart.draw()
|
|
||||||
message.save()
|
|
||||||
|
|
||||||
image_bytes = message.weather_chart.to_image()
|
|
||||||
await self.edit(Media(image_bytes, MediaType.IMAGE), message)
|
|
||||||
|
|
||||||
async def _on_bye(self, message: Message):
|
async def _on_bye(self, message: Message):
|
||||||
if not message.chat.is_group or self.is_bot_mentioned(message):
|
if not message.chat.is_group or self.is_bot_mentioned(message):
|
||||||
await self.send_bye(message)
|
await self.send_bye(message)
|
||||||
|
|
||||||
|
async def _on_config_button_press(self, message: Message):
|
||||||
|
await self._accept_button_event(message)
|
||||||
|
|
||||||
|
if not message.button_pressed_user.is_admin or 'auto_' not in (config := message.button_pressed_text.split()[1]):
|
||||||
|
return
|
||||||
|
|
||||||
|
message.chat.config[config] = not message.chat.config[config]
|
||||||
|
|
||||||
|
await self.edit('<b>Estos son los ajustes del grupo:</b>\n\n', self._get_config_buttons(message), message)
|
||||||
|
|
||||||
@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
|
||||||
@@ -460,14 +424,18 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
@inline(False)
|
@inline(False)
|
||||||
async def _on_recover_message(self, message: Message):
|
async def _on_recover_message(self, message: Message):
|
||||||
if message.replied_message:
|
if message.replied_message:
|
||||||
message_deleted_bot_action = BotAction.find_one({'action': bytes(Action.MESSAGE_DELETED), 'chat': message.chat.object_id, 'affected_objects': message.replied_message.object_id})
|
message_deleted_bot_action = BotAction.find_one({'action': Action.MESSAGE_DELETED.value, 'chat': message.chat.object_id, 'affected_objects': message.replied_message.object_id})
|
||||||
elif self.is_bot_mentioned(message):
|
elif self.is_bot_mentioned(message):
|
||||||
message_deleted_bot_action = BotAction.find_one({'action': bytes(Action.MESSAGE_DELETED), 'chat': message.chat.object_id, 'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.RECOVERY_DELETED_MESSAGE_BEFORE}})
|
message_deleted_bot_action = BotAction.find_one({
|
||||||
|
'action': Action.MESSAGE_DELETED.value,
|
||||||
|
'chat': message.chat.object_id,
|
||||||
|
'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.RECOVERY_DELETED_MESSAGE_BEFORE}
|
||||||
|
}, sort_keys=(('date', pymongo.DESCENDING),))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not message_deleted_bot_action:
|
if not message_deleted_bot_action:
|
||||||
await self.send_error(random.choice(constants.RECOVER_PHRASES), message)
|
await self.send_error('No hay nada que recuperar.', message)
|
||||||
return
|
return
|
||||||
|
|
||||||
affected_object_ids = [affected_message_object_id for affected_message_object_id in message_deleted_bot_action.affected_objects]
|
affected_object_ids = [affected_message_object_id for affected_message_object_id in message_deleted_bot_action.affected_objects]
|
||||||
@@ -475,10 +443,12 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
for deleted_message in deleted_messages:
|
for deleted_message in deleted_messages:
|
||||||
await self.send(deleted_message.text, message)
|
await self.send(deleted_message.text, message)
|
||||||
|
|
||||||
message_deleted_bot_action.delete()
|
|
||||||
|
|
||||||
async def _on_scraping(self, message: Message, delete_original: bool = None) -> OrderedSet[Media]:
|
async def _on_scraping(self, message: Message, delete_original: bool = None) -> OrderedSet[Media]:
|
||||||
sended_media_messages = await self._search_and_send_medias(message.replied_message) if message.replied_message else OrderedSet()
|
sended_media_messages = OrderedSet()
|
||||||
|
if message.replied_message:
|
||||||
|
word_matches = flanautils.cartesian_product_string_matching(message.text, constants.KEYWORDS['scraping'], min_ratio=multibot_constants.PARSE_CALLBACKS_MIN_RATIO_DEFAULT)
|
||||||
|
if sum(max(matches.values()) for matches in word_matches.values()):
|
||||||
|
sended_media_messages += await self._search_and_send_medias(message.replied_message)
|
||||||
sended_media_messages += await self._search_and_send_medias(message)
|
sended_media_messages += await self._search_and_send_medias(message)
|
||||||
await self.send_inline_results(message)
|
await self.send_inline_results(message)
|
||||||
|
|
||||||
@@ -491,6 +461,8 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
(
|
(
|
||||||
delete_original is None
|
delete_original is None
|
||||||
and
|
and
|
||||||
|
not message.replied_message
|
||||||
|
and
|
||||||
message.chat.config['auto_delete_original']
|
message.chat.config['auto_delete_original']
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
@@ -548,6 +520,33 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
for user in await self._find_users_to_punish(message):
|
for user in await self._find_users_to_punish(message):
|
||||||
await self.unpunish(user, message, message)
|
await self.unpunish(user, message, message)
|
||||||
|
|
||||||
|
async def _on_weather_button_press(self, message: Message):
|
||||||
|
await self._accept_button_event(message)
|
||||||
|
|
||||||
|
match message.button_pressed_text:
|
||||||
|
case WeatherEmoji.ZOOM_IN.value:
|
||||||
|
message.weather_chart.zoom_in()
|
||||||
|
case WeatherEmoji.ZOOM_OUT.value:
|
||||||
|
message.weather_chart.zoom_out()
|
||||||
|
case WeatherEmoji.LEFT.value:
|
||||||
|
message.weather_chart.move_left()
|
||||||
|
case WeatherEmoji.RIGHT.value:
|
||||||
|
message.weather_chart.move_right()
|
||||||
|
case WeatherEmoji.PRECIPITATION_VOLUME.value:
|
||||||
|
message.weather_chart.trace_metadatas['rain_volume'].show = not message.weather_chart.trace_metadatas['rain_volume'].show
|
||||||
|
message.weather_chart.trace_metadatas['snow_volume'].show = not message.weather_chart.trace_metadatas['snow_volume'].show
|
||||||
|
case emoji if emoji in WeatherEmoji.values:
|
||||||
|
trace_metadata_name = WeatherEmoji(emoji).name.lower()
|
||||||
|
message.weather_chart.trace_metadatas[trace_metadata_name].show = not message.weather_chart.trace_metadatas[trace_metadata_name].show
|
||||||
|
case _:
|
||||||
|
return
|
||||||
|
|
||||||
|
message.weather_chart.apply_zoom()
|
||||||
|
message.weather_chart.draw()
|
||||||
|
|
||||||
|
image_bytes = message.weather_chart.to_image()
|
||||||
|
await self.edit(Media(image_bytes, MediaType.IMAGE), message)
|
||||||
|
|
||||||
async def _on_weather_chart(self, message: Message):
|
async def _on_weather_chart(self, message: Message):
|
||||||
bot_state_message: Message | None = None
|
bot_state_message: Message | None = None
|
||||||
if message.is_inline:
|
if message.is_inline:
|
||||||
@@ -568,7 +567,7 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
possible_mentioned_ids.append(user.name.split('#')[0].lower())
|
possible_mentioned_ids.append(user.name.split('#')[0].lower())
|
||||||
possible_mentioned_ids.append(f'@{user.id}')
|
possible_mentioned_ids.append(f'@{user.id}')
|
||||||
|
|
||||||
if roles := await self.get_group_roles(message):
|
if roles := await self.get_roles(message):
|
||||||
for role in roles:
|
for role in roles:
|
||||||
possible_mentioned_ids.append(f'@{role.id}')
|
possible_mentioned_ids.append(f'@{role.id}')
|
||||||
|
|
||||||
@@ -758,10 +757,7 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
message.song_infos.add(media.song_info)
|
message.song_infos.add(media.song_info)
|
||||||
message.save()
|
message.save()
|
||||||
|
|
||||||
try:
|
if not (bot_message := await self.send(media, message)):
|
||||||
bot_message = await self.send(media, message)
|
|
||||||
except SendError as e:
|
|
||||||
await self._manage_exceptions(e, message)
|
|
||||||
fails += 1
|
fails += 1
|
||||||
else:
|
else:
|
||||||
sended_media_messages.append(bot_message)
|
sended_media_messages.append(bot_message)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['FlanaDiscBot']
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations # todo0 remove in 3.11
|
from __future__ import annotations # todo0 remove in 3.11
|
||||||
|
|
||||||
|
__all__ = ['whitelisted_event', 'FlanaTeleBot']
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import flanautils
|
|||||||
|
|
||||||
AUTO_WEATHER_EVERY = datetime.timedelta(hours=6)
|
AUTO_WEATHER_EVERY = datetime.timedelta(hours=6)
|
||||||
CHECK_PUNISHMENTS_EVERY_SECONDS = datetime.timedelta(hours=1).total_seconds()
|
CHECK_PUNISHMENTS_EVERY_SECONDS = datetime.timedelta(hours=1).total_seconds()
|
||||||
|
FLOOD_2s_LIMIT = 4
|
||||||
|
FLOOD_7s_LIMIT = 7
|
||||||
HEAT_PERIOD_SECONDS = datetime.timedelta(minutes=15).total_seconds()
|
HEAT_PERIOD_SECONDS = datetime.timedelta(minutes=15).total_seconds()
|
||||||
INSULT_PROBABILITY = 0.00166666667
|
INSULT_PROBABILITY = 0.00166666667
|
||||||
MAX_PLACE_QUERY_LENGTH = 50
|
MAX_PLACE_QUERY_LENGTH = 50
|
||||||
@@ -19,30 +21,67 @@ BYE_PHRASES = ('Adiós.', 'adieu', 'adio', 'adioh', 'adios', 'adió', 'adiós',
|
|||||||
HELLO_PHRASES = ('alo', 'aloh', 'buenas', 'Hola.', 'hello', 'hey', 'hi', 'hola', 'holaaaa', 'holaaaaaaa', 'ola',
|
HELLO_PHRASES = ('alo', 'aloh', 'buenas', 'Hola.', 'hello', 'hey', 'hi', 'hola', 'holaaaa', 'holaaaaaaa', 'ola',
|
||||||
'ola k ase', 'pa ti mi cola', 'saludos')
|
'ola k ase', 'pa ti mi cola', 'saludos')
|
||||||
INSULTS = (
|
INSULTS = (
|
||||||
'Cállate ya anda.',
|
'._.',
|
||||||
'¿Quién te ha preguntado?',
|
'aha',
|
||||||
'¿Tú eres así o te dan apagones cerebrales?',
|
'Aléjate de mi.',
|
||||||
'Ante la duda mi dedo corazón te saluda.',
|
'Ante la duda mi dedo corazón te saluda.',
|
||||||
'Enjoy cancer brain.',
|
|
||||||
'Calla noob.',
|
|
||||||
'Hablas tanta mierda que tu culo tiene envidia de tu boca.',
|
|
||||||
'jAJjajAJjajAJjajAJajJAJajJA',
|
|
||||||
'enjoy xd',
|
|
||||||
'Reported.',
|
|
||||||
'Baneito pa ti en breve.',
|
'Baneito pa ti en breve.',
|
||||||
'Despídete de tu cuenta.',
|
'Calla noob.',
|
||||||
'Flanagan es más guapo que tú.',
|
'Cansino.',
|
||||||
'jajaj',
|
'Cuentame menos.',
|
||||||
'xd',
|
'Cuentame más.',
|
||||||
'Hay un concurso de hostias y tienes todas las papeletas.',
|
'Cállate ya anda.',
|
||||||
'¿Por qué no te callas?',
|
'Cállate.',
|
||||||
'Das penilla.',
|
'Das penilla.',
|
||||||
|
'De verdad. Estás para encerrarte.',
|
||||||
'Deberían hacerte la táctica del C4.',
|
'Deberían hacerte la táctica del C4.',
|
||||||
'Te voy romper las pelotas.',
|
'Despídete de tu cuenta.',
|
||||||
'Más tonto y no naces.',
|
'Déjame tranquilo.',
|
||||||
|
'Enjoy cancer brain.',
|
||||||
|
'Eres cortito, ¿eh?',
|
||||||
|
'Eres más malo que pegarle a un padre.',
|
||||||
'Eres más tonto que peinar bombillas.',
|
'Eres más tonto que peinar bombillas.',
|
||||||
'Eres más tonto que pellizcar cristales.',
|
'Eres más tonto que pellizcar cristales.',
|
||||||
'Eres más malo que pegarle a un padre.'
|
'Estás mal de la azotea.',
|
||||||
|
'Estás mal de la cabeza.',
|
||||||
|
'Flanagan es más guapo que tú.',
|
||||||
|
'Hablas tanta mierda que tu culo tiene envidia de tu boca.',
|
||||||
|
'Hay un concurso de hostias y tienes todas las papeletas.',
|
||||||
|
'Loco.',
|
||||||
|
'Más tonto y no naces.',
|
||||||
|
'No eres muy avispado tú...',
|
||||||
|
'Pesado.',
|
||||||
|
'Que bien, ¿eh?',
|
||||||
|
'Que me dejes en paz.',
|
||||||
|
'Qué pesado.',
|
||||||
|
'Quita bicho.',
|
||||||
|
'Reportaito mi arma.',
|
||||||
|
'Reported.',
|
||||||
|
'Retard.',
|
||||||
|
'Te voy romper las pelotas.',
|
||||||
|
'Tú... no estás muy bien, ¿no?',
|
||||||
|
'Ya estamos otra vez...',
|
||||||
|
'Ya estamos...',
|
||||||
|
'enjoy xd',
|
||||||
|
'jAJjajAJjajAJjajAJajJAJajJA',
|
||||||
|
'jajaj',
|
||||||
|
'o_O',
|
||||||
|
'xd',
|
||||||
|
'¿Otra vez tú?',
|
||||||
|
'¿Pero cuándo te vas a callar?',
|
||||||
|
'¿Por qué no te callas?',
|
||||||
|
'¿Quién te ha preguntado?',
|
||||||
|
'¿Qúe quieres?',
|
||||||
|
'¿Te callas o te callo?',
|
||||||
|
'¿Te imaginas que me interesa?',
|
||||||
|
'¿Te quieres callar?',
|
||||||
|
'¿Todo bien?',
|
||||||
|
'¿Tú eres así o te dan apagones cerebrales?',
|
||||||
|
'🖕',
|
||||||
|
'😑',
|
||||||
|
'🙄',
|
||||||
|
'🤔',
|
||||||
|
'🤨'
|
||||||
)
|
)
|
||||||
|
|
||||||
KEYWORDS = {
|
KEYWORDS = {
|
||||||
@@ -71,14 +110,5 @@ KEYWORDS = {
|
|||||||
'wetter')
|
'wetter')
|
||||||
}
|
}
|
||||||
|
|
||||||
RECOVER_PHRASES = (
|
|
||||||
'No hay nada que recuperar.',
|
|
||||||
'Ya lo he recuperado y enviado, así que callate ya.',
|
|
||||||
'Ya lo he recuperado y enviado, así que mejor estás antento antes de dar por culo.',
|
|
||||||
'Ya lo he recuperado y enviado, no lo voy a hacer dos veces.',
|
|
||||||
'Ya lo he recuperado y enviado. A ver si leemos más y jodemos menos.',
|
|
||||||
'Ya lo he reenviado.'
|
|
||||||
)
|
|
||||||
|
|
||||||
SCRAPING_PHRASES = ('Analizando...', 'Buscando...', 'Hackeando internet... 👀', 'Rebuscando en la web...',
|
SCRAPING_PHRASES = ('Analizando...', 'Buscando...', 'Hackeando internet... 👀', 'Rebuscando en la web...',
|
||||||
'Robando cosas...', 'Scrapeando...', 'Scraping...')
|
'Robando cosas...', 'Scrapeando...', 'Scraping...')
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import flanautils
|
|||||||
os.environ |= flanautils.find_environment_variables('../.env')
|
os.environ |= flanautils.find_environment_variables('../.env')
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from flanabot.bots.flana_disc_bot import FlanaDiscBot
|
from flanabot.bots.flana_disc_bot import FlanaDiscBot
|
||||||
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from flanabot.models.chat import *
|
from flanabot.models.chat import *
|
||||||
from flanabot.models.enums import *
|
|
||||||
from flanabot.models.message import *
|
from flanabot.models.message import *
|
||||||
from flanabot.models.punishment import *
|
from flanabot.models.punishment import *
|
||||||
from flanabot.models.weather_chart import *
|
from flanabot.models.weather_chart import *
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['Chat']
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from multibot.models import Chat as MultiBotChat
|
from multibot.models import Chat as MultiBotChat
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
from enum import auto
|
|
||||||
|
|
||||||
from flanautils import FlanaEnum
|
|
||||||
|
|
||||||
|
|
||||||
class ButtonsMessageType(FlanaEnum):
|
|
||||||
CONFIG = auto()
|
|
||||||
WEATHER = auto()
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations # todo0 remove in 3.11
|
from __future__ import annotations # todo0 remove in 3.11
|
||||||
|
|
||||||
|
__all__ = ['Message']
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['Direction', 'WeatherChart']
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
aiohttp==3.7.4.post0
|
aiohttp==3.8.1
|
||||||
aiosignal==1.2.0
|
aiosignal==1.2.0
|
||||||
anyio==3.5.0
|
anyio==3.5.0
|
||||||
asgiref==3.4.1
|
asgiref==3.4.1
|
||||||
async-generator==1.10
|
async-generator==1.10
|
||||||
async-timeout==3.0.1
|
async-timeout==4.0.2
|
||||||
attrs==21.4.0
|
attrs==21.4.0
|
||||||
beautifulsoup4==4.10.0
|
beautifulsoup4==4.10.0
|
||||||
certifi==2021.10.8
|
certifi==2021.10.8
|
||||||
@@ -14,7 +14,7 @@ click==8.0.3
|
|||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
cryptg==0.2.post4
|
cryptg==0.2.post4
|
||||||
cryptography==36.0.1
|
cryptography==36.0.1
|
||||||
discord.py==2.0.0a4269+gb7e25645
|
discord.py @ git+https://github.com/Rapptz/discord.py@b7e25645dc68bbb828bf1ede711d098c6b183237
|
||||||
fastapi==0.71.0
|
fastapi==0.71.0
|
||||||
flanaapis
|
flanaapis
|
||||||
flanautils
|
flanautils
|
||||||
@@ -47,6 +47,7 @@ selenium-stealth==1.0.6
|
|||||||
six==1.16.0
|
six==1.16.0
|
||||||
sniffio==1.2.0
|
sniffio==1.2.0
|
||||||
sortedcontainers==2.4.0
|
sortedcontainers==2.4.0
|
||||||
|
soupsieve==2.3.1
|
||||||
starlette==0.17.1
|
starlette==0.17.1
|
||||||
sympy==1.9
|
sympy==1.9
|
||||||
Telethon==1.24.0
|
Telethon==1.24.0
|
||||||
@@ -54,7 +55,7 @@ tenacity==8.0.1
|
|||||||
TikTokApi==4.1.0
|
TikTokApi==4.1.0
|
||||||
trio==0.19.0
|
trio==0.19.0
|
||||||
trio-websocket==0.9.2
|
trio-websocket==0.9.2
|
||||||
twitchio==2.1.4
|
twitchio==2.3.0
|
||||||
typing_extensions==4.0.1
|
typing_extensions==4.0.1
|
||||||
ujson==5.1.0
|
ujson==5.1.0
|
||||||
urllib3==1.26.8
|
urllib3==1.26.8
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ os.environ |= flanautils.find_environment_variables('../.env')
|
|||||||
import unittest
|
import unittest
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from multibot import constants as multibot_constants
|
|
||||||
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ class TestParseCallbacks(unittest.TestCase):
|
|||||||
def _test_no_always_callbacks(self, phrases: Iterable[str], callback: callable):
|
def _test_no_always_callbacks(self, phrases: Iterable[str], callback: callable):
|
||||||
for i, phrase in enumerate(phrases):
|
for i, phrase in enumerate(phrases):
|
||||||
with self.subTest(phrase):
|
with self.subTest(phrase):
|
||||||
callbacks = [registered_callback.callback for registered_callback in self.flana_tele_bot._parse_callbacks(phrase, multibot_constants.RATIO_REWARD_EXPONENT, multibot_constants.KEYWORDS_LENGHT_PENALTY, multibot_constants.MINIMUM_RATIO_TO_MATCH)
|
callbacks = [registered_callback.callback for registered_callback in self.flana_tele_bot._parse_callbacks(phrase, self.flana_tele_bot._registered_callbacks)
|
||||||
if not registered_callback.always]
|
if not registered_callback.always]
|
||||||
self.assertEqual(1, len(callbacks))
|
self.assertEqual(1, len(callbacks))
|
||||||
self.assertEqual(callback, callbacks[0], f'\n\nExpected: {callback.__name__}\nActual: {callbacks[0].__name__}')
|
self.assertEqual(callback, callbacks[0], f'\n\nExpected: {callback.__name__}\nActual: {callbacks[0].__name__}')
|
||||||
@@ -92,8 +91,7 @@ class TestParseCallbacks(unittest.TestCase):
|
|||||||
def test_on_delete_original_config_activate(self):
|
def test_on_delete_original_config_activate(self):
|
||||||
phrases = [
|
phrases = [
|
||||||
'activa el borrado automatico',
|
'activa el borrado automatico',
|
||||||
'flanabot pon el auto delete activado',
|
'flanabot pon el auto delete activado'
|
||||||
'flanabot activa el autodelete'
|
|
||||||
]
|
]
|
||||||
self._test_no_always_callbacks(phrases, self.flana_tele_bot._on_delete_original_config_activate)
|
self._test_no_always_callbacks(phrases, self.flana_tele_bot._on_delete_original_config_activate)
|
||||||
|
|
||||||
@@ -104,8 +102,7 @@ class TestParseCallbacks(unittest.TestCase):
|
|||||||
def test_on_delete_original_config_deactivate(self):
|
def test_on_delete_original_config_deactivate(self):
|
||||||
phrases = [
|
phrases = [
|
||||||
'desactiva el borrado automatico',
|
'desactiva el borrado automatico',
|
||||||
'flanabot pon el auto delete desactivado',
|
'flanabot pon el auto delete desactivado'
|
||||||
'flanabot desactiva el autodelete'
|
|
||||||
]
|
]
|
||||||
self._test_no_always_callbacks(phrases, self.flana_tele_bot._on_delete_original_config_deactivate)
|
self._test_no_always_callbacks(phrases, self.flana_tele_bot._on_delete_original_config_deactivate)
|
||||||
|
|
||||||
@@ -119,9 +116,9 @@ class TestParseCallbacks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_on_mute(self):
|
def test_on_mute(self):
|
||||||
phrases = [
|
phrases = [
|
||||||
# 'silencia',
|
'silencia',
|
||||||
# 'silencia al pavo ese',
|
'silencia al pavo ese',
|
||||||
# 'calla a ese pesao',
|
'calla a ese pesao',
|
||||||
'haz que se calle',
|
'haz que se calle',
|
||||||
'quitale el microfono a ese',
|
'quitale el microfono a ese',
|
||||||
'quitale el micro',
|
'quitale el micro',
|
||||||
|
|||||||
Reference in New Issue
Block a user