discourse-ai/assets/javascripts/discourse/lib/ai-bot-helper.js

24 lines
664 B
JavaScript
Raw Normal View History

import Composer from "discourse/models/composer";
import I18n from "I18n";
export function composeAiBotMessage(targetBot, composer) {
const currentUser = composer.currentUser;
let botUsername = currentUser.ai_enabled_chat_bots.find(
(bot) => bot.model_name === targetBot
).username;
composer.focusComposer({
fallbackToNewTopic: true,
openOpts: {
action: Composer.PRIVATE_MESSAGE,
recipients: botUsername,
topicTitle: I18n.t("discourse_ai.ai_bot.default_pm_prefix"),
archetypeId: "private_message",
draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY,
hasGroups: false,
warningsDisabled: true,
},
});
}