feat(plugins): group auto-translation extension plugin#300
Merged
rmyndharis merged 7 commits intoJun 18, 2026
Merged
Conversation
One-field passthrough (whatsapp-web.js already attaches mentionedIds) so command handlers can target a user by @mention — the reliable cross-user identity under WhatsApp's LID scheme, since mentions and message authors share the @lid namespace. Additive and optional.
Ports the translation feature onto the Tier-2 capability layer (rmyndharis#294): the framework-agnostic core/ (coordinator, command parser, reply formatter, ports) is reused unchanged, with ChatGateway/ConfigStore implemented over ctx.messages / ctx.engine / ctx.storage and per-group state in plugin KV storage. Registered disabled by default; enable via POST /plugins/translation/enable. Supersedes the core-module approach in rmyndharis#278 now that the plugin send-capability exists.
This was referenced Jun 17, 2026
… live - Add the configSchema to the translation plugin's registered manifest so GET /plugins exposes it and the dashboard config form (rmyndharis#303) can render the LibreTranslate URL + API key (and other) fields. The schema was previously only in manifest.json, which built-in registration does not read. - Implement onConfigChange to rebuild the coordinator from the updated config, so a URL/key change saved from the dashboard takes effect immediately without a disable/enable cycle. Extracted buildCoordinator() shared by onEnable/onConfigChange.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the WhatsApp group auto-translation feature (originally proposed as a core module in #278) to a first-party EXTENSION plugin, built on the Tier-2 capability layer from #294. The translation logic was already isolated behind ports, so the framework-agnostic core lifts in unchanged; the OpenWA wiring is now
ctx.messages/ctx.engine/ctx.storage. Registered disabled by default — enable viaPOST /plugins/translation/enable.Supersedes #278. Thanks for landing #294 so quickly —
ctx.messages/ctx.engineare exactly what this needed.How it maps to the Tier-2 layer
ChatGateway→ctx.messages.sendText/reply(sends routed throughMessageService, persistence preserved) +ctx.engine.getGroupInfo(admin resolution).ConfigStore→ctx.storage(oneGroupStateJSON per group).ctx.config(manifestconfigSchema; defaults tohttp://localhost:7001).ctx.registerHook('message:received', …)inonEnable.coordinator, command parser, reply formatter, ports) is reused unchanged.What's included
src/plugins/extensions/translation/— the plugin:core/(reused),libretranslate.client.ts(timeout + circuit breaker),plugin-chat.gateway.ts,plugin-config.store.ts,index.ts,manifest.json.ExtensionsRegistrar, mirroringauto-reply.mentionedIdsonIncomingMessage(whatsapp-web.js already attaches it). It enables@mentioncommand targeting — the reliable cross-user identity under LID, since mentions and message authors share the@lidnamespace.Behavior
Per-message source detection (LibreTranslate) with learn-by-observation of each participant's language; one combined quote-reply per message into the other participants' languages; never translates a message into its own language (resilient to detector misfires on colloquial text). In-group
/trcommands (on/off,setlang,auto,ignore/unignore,grant/revoke,status,help) — every command replies. Permissions: group admins (LID-aware via the groupowner) plus admin-delegated members. The bot's own sends arefromMeand route throughmessage:sent, so there is no translation loop.Configuration
libretranslateUrl(defaulthttp://localhost:7001),libretranslateApiKey?,timeoutMs,commandPrefix(/tr),minLength,maxLength,denyReply— seemanifest.jsonconfigSchema; set per-instance via the plugins config API.Testing
ctx-backed gateway/store shims + thementionedIdsmapper cases); lint + format clean; build clean.Known limitations / follow-ups
@mention; non-owner admin auto-detection on a differing scheme could build on the newsenderPhone/RESOLVE_LID_TO_PHONE([Feature]: How we can get phone number from @lid #263) — a follow-up.onGroupJoinfor announce-on-add (currently announces on first activity); per-plugin send throttle; media/caption translation; dashboard config UI — all follow-ups.LibreTranslateadd the ability to use a remote LibreTranlate via configurable API key / URL