mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-27 21:10:13 +00:00
Reworked implementation of the multilingual-response feature (issue #218) as a reusable, framework-level capability instead of logic bolted onto HelloCommand. - modules/lang_detector.py: keyword-first detection (reliable for the short greetings typical on mesh) with optional langdetect for longer text; results are constrained to languages that actually have a translation file. - core.py: cache Translator instances by language (get_translator) so per-message switching never re-reads files, and expose available_languages() derived from translations/*.json. Store translation_path; keep cache/path consistent on config reload. - base_command.py: task-local translator override via a ContextVar (safe under asyncio concurrency, no global mutation), plus detect_response_language() and a respond_in_sender_language() context manager any command can opt into. - hello_command.py: build the reply inside respond_in_sender_language(); the only awaited call (send_response) stays outside the override window. - Gated by [Localization] auto_detect_language (default false); langdetect is an optional [lang] extra, not a hard dependency. Tests: unit coverage for the detector and the base-command wiring.
44 lines
1023 B
Plaintext
44 lines
1023 B
Plaintext
# Runtime dependencies — keep in sync with pyproject.toml [project.dependencies]
|
|
pyserial>=3.5
|
|
bleak>=0.20.0
|
|
asyncio-mqtt>=0.11.0
|
|
configparser>=5.3.0
|
|
python-dateutil>=2.8.2
|
|
apscheduler>=3.10.0
|
|
colorlog>=6.7.0
|
|
requests>=2.31.0
|
|
urllib3>=2.0.0
|
|
pyephem>=4.1.4
|
|
geopy>=2.3.0
|
|
maidenhead>=1.4.0
|
|
pytz>=2023.3
|
|
aiohttp>=3.8.0
|
|
meshcore>=2.3.6
|
|
openmeteo-requests>=1.7.2
|
|
requests-cache>=1.1.1
|
|
retry-requests>=1.0.0
|
|
flask>=2.3.0
|
|
flask-socketio>=5.3.0
|
|
flask-compress>=1.14
|
|
meshcore-cli
|
|
feedparser>=6.0.10
|
|
paho-mqtt>=1.6.0
|
|
cryptography>=41.0.0
|
|
pynacl>=1.5.0
|
|
aiosqlite>=0.19.0
|
|
|
|
# Optional: profanity filtering (pip install meshcore-bot[profanity])
|
|
# better-profanity>=0.7.0
|
|
# unidecode>=1.3.0
|
|
|
|
# Optional: improved geocoding accuracy (pip install meshcore-bot[geo])
|
|
# pycountry>=23.12.0
|
|
# us>=2.0.0
|
|
|
|
# Optional: automatic language detection for multilingual replies
|
|
# (pip install meshcore-bot[lang]); the keyword detector works without it
|
|
# langdetect>=1.0.9
|
|
|
|
# Testing dependencies live in pyproject extras:
|
|
# pip install -e ".[test]"
|