fix: Simplificar traducción y corregir imports

- Eliminar segmentación, traducir texto completo de una vez
- Añadir imports faltantes get_name_to_code, get_flag_mapping
- Restaurar filtro: solo enviar botones si hay texto (sin multimedia)
This commit is contained in:
2026-03-20 04:55:13 -06:00
parent afc446a9aa
commit 100fef5c90
2 changed files with 20 additions and 59 deletions

View File

@@ -10,8 +10,8 @@ import html
from botdiscord.config import get_discord_token, load_config, get_languages
from botdiscord.database import init_db, get_active_languages, get_bot_languages, save_message, get_welcome_message
from botdiscord.ui import PersistentTranslationView, ConfigView, WelcomeTranslationView
from botdiscord.translate import get_reverse_mapping, load_lang_mappings
from botdiscord.ui import PersistentTranslationView, ConfigView, WelcomeTranslationView, TranslationButton
from botdiscord.translate import get_reverse_mapping, load_lang_mappings, get_name_to_code, get_flag_mapping
load_config()
@@ -116,14 +116,14 @@ async def on_message(message):
if message.author.bot: return
text_content = message.content.strip()
if not text_content and not message.attachments: return
if not text_content: return
# Filtros de stickers/emojis/etc
if message.stickers or text_content.startswith('https://tenor.com/') or \
re.fullmatch(r'<(a?):[a-zA-Z0-9_]+:[0-9]+>', text_content):
return
if text_content and len(text_content) < 2: return
if len(text_content) < 2: return
active_codes = get_active_langs_for_guild(message.guild.id)
if not active_codes: return
@@ -141,7 +141,6 @@ async def on_message(message):
text_to_translate = mention_pattern.sub(replace_mention, text_escaped)
save_message(message.id, message.guild.id, message.author.id, text_to_translate, mentions_map, 'discord')
from botdiscord.ui import TranslationButton
view = discord.ui.View(timeout=None)
name_to_code = get_name_to_code("discord")
flag_mapping = get_flag_mapping("discord")