ChatApp with Bots
Implement a small in-memory chat application that supports multiple channels and extensible bots.
Each channel maintains its own message history and any bot state associated with that channel. The design should allow new bot types to be added without modifying the core chat logic.
For this problem, process a list of commands:
REGISTER botName ...: register one or more botsSEND channelId userId text...: append the user message to that channel and then append any bot replies triggered by the messagePRINT channelId: emit the full message history for that channel in order
Assume two example bots exist: EchoBot replies with the same text it receives, and HelpBot replies with a help string when the message text is help.
Complete the function runChatAppCommands in the editor below.
runChatAppCommands has the following parameter:
String[] commands: the commands to process in order
Returns
String[]: the lines produced by all PRINT commands, in order.
1Example 1
Each channel keeps an independent message log. EchoBot answers in channel A, while HelpBot answers in channel B.
2Example 2
The same bot can respond multiple times inside the same channel, and channel history preserves insertion order.
Constraints
Limits and guarantees your solution can rely on.
1 <= commands.length <= 10^5- The number of channels is at most
10^4. - The number of registered bots is at most
10^2. - Commands arrive sequentially; no concurrency handling is required.