UNPKG

heybox-bot

Version:

A heybox chat bot frame

1,061 lines 32.5 kB
"use strict"; // noinspection DuplicatedCode var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserMessageBuilder = exports.ImageUserMessageImpl = exports.MarkdownUserMessageImpl = exports.AbstractUserMessageImpl = exports.MessageBuilder = exports.CardMessageImpl = exports.CardOriginal = exports.ExtendedMarkdownMessageImpl = exports.AbstractMessageImpl = void 0; const constants_1 = __importDefault(require("../../constants")); const utils_1 = require("../../utils"); const dayjs_1 = __importDefault(require("dayjs")); const utc_1 = __importDefault(require("dayjs/plugin/utc")); /** * AbstractMessageImpl 是一个抽象类,实现了 Message 接口的部分功能。 * 它提供了一个基础结构,用于构建和处理消息,特别是那些需要转换为特定格式的消息。 */ class AbstractMessageImpl { /** * 构造函数,初始化消息类型。 * @param msgType 消息类型,用于区分不同的消息种类。 */ constructor(msgType) { /** * addition_original 是一个可选字段,包含原始的附加信息,如图片文件信息。 */ this.addition_original = { img_files_info: [] }; /** * addition 是一个字符串字段,以 JSON 格式存储附加信息,默认包含空的图片文件信息数组。 */ this.addition = '{"img_files_info":[]}'; /** * channel_id 表示消息所属的频道ID。 */ this.channel_id = ''; /** * heychat_ack_id 是一个只读字段,用于存储消息的确认ID,确保消息的唯一性和可追踪性。 */ this.heychat_ack_id = `${utils_1.Util.getAckId()}`; /** * msg 是消息的主体内容。 */ this.msg = ''; /** * reply_id 用于存储回复的消息ID,如果当前消息是回复其他消息的。 */ this.reply_id = ''; /** * room_id 表示消息所属的房间ID。 */ this.room_id = ''; this.msg_type = msgType; } /** * 设置消息的目标房间和频道。 * @param roomId 目标房间的ID。 * @param channelId 目标频道的ID。 * @returns 返回当前实例,支持链式调用。 */ to(roomId, channelId) { this.room_id = roomId; this.channel_id = channelId; return this; } /** * 设置当前消息为回复指定消息ID的消息。 * @param msgId 被回复的消息的ID。 * @returns 返回当前实例,支持链式调用。 */ reply(msgId) { this.reply_id = msgId; return this; } } exports.AbstractMessageImpl = AbstractMessageImpl; /** * 实现了ExtendedMarkdownMessage接口的类,用于创建和操作扩展Markdown消息 */ class ExtendedMarkdownMessageImpl extends AbstractMessageImpl { /** * 私有构造函数,确保类的实例只能通过create方法创建 */ constructor() { super(10); // 定义了消息中@角色的ID this.at_role_id = ''; // 定义了消息中@用户的ID this.at_user_id = ''; // 定义了是否@所有人 this.at_all = false; // 定义了是否@在线用户 this.at_hear = false; // 定义了频道类型 this.channel_type = 1; // 定义了提及频道的ID this.mention_channel_id = ''; // 定义了消息类型,固定为10 this.msg_type = 10; } /** * 创建ExtendedMarkdownMessageImpl类的实例 * @returns ExtendedMarkdownMessageImpl的实例 */ static create() { return new ExtendedMarkdownMessageImpl(); } /** * 添加文本内容到消息中,支持Markdown格式 * @param text 要添加的文本 * @param bold 是否加粗文本 * @param italic 是否斜体文本 * @param strikethrough 是否划线文本 * @returns 当前实例,支持链式调用 */ text(text, bold = false, italic = false, strikethrough = false) { let msg = `${text}`; if (italic) msg = `*${msg}*`; if (bold) msg = `**${msg}**`; if (strikethrough) msg = `~~${msg}~~`; const flag = this.msg.endsWith('*') || this.msg.endsWith('~'); if (this.msg[this.msg.length - 1] == msg[0] && flag) this.msg += ' '; this.msg += msg; return this; } /** * 添加超链接到消息中,支持Markdown格式 * @param url 链接地址 * @param text 显示的文本 * @param bold 是否加粗文本 * @param italic 是否斜体文本 * @param strikethrough 是否划线文本 * @returns 当前实例,支持链式调用 */ link(url, text = url, bold = false, italic = false, strikethrough = false) { this.msg += `[`; this.text(text, bold, italic, strikethrough); this.msg += `](${url})`; return this; } /** * 添加图片到消息中,支持Markdown格式 * @param url 图片地址 * @param width 图片宽度 * @param height 图片高度 * @returns 当前实例,支持链式调用 */ addImage(url, width, height) { var _a; (_a = this.addition_original) === null || _a === void 0 ? void 0 : _a.img_files_info.push({ url, width, height }); this.msg += `![](${url})`; this.addition = JSON.stringify(this.addition_original); return this; } /** * 公共方法,用于添加图片,支持本地文件或URL * @param url 图片地址或本地文件 * @param width 图片宽度 * @param height 图片高度 * @returns 当前实例,支持链式调用 */ image(url, width, height) { if (typeof url !== 'string' || !url.includes(constants_1.default.CDN_URL)) { this.addImage(utils_1.Request.uploadFileSync(url), width, height); return this; } else { this.addImage(url, width, height); } return this; } /** * 添加@用户到消息中 * @param user 用户信息 * @returns 当前实例,支持链式调用 */ at(user) { if (this.at_user_id != '') this.at_user_id += ','; const userId = user.user_id; this.at_user_id += `${userId}`; this.text(`@{id:${userId}} `); return this; } /** * 添加@角色到消息中 * @param roleId 角色ID * @returns 当前实例,支持链式调用 */ atRole(roleId) { if (this.at_role_id != '') this.at_role_id += ','; this.at_role_id += `${roleId}`; this.text(`@{id:${roleId}} `); return this; } /** * 添加提及频道到消息中 * @param mentionChannelId 频道ID * @returns 当前实例,支持链式调用 */ mentionChannel(mentionChannelId) { if (this.mention_channel_id != '') this.mention_channel_id += ','; this.mention_channel_id += `${mentionChannelId}`; this.text(`#{id:${mentionChannelId}} `); return this; } /** * 添加@所有人到消息中 * @returns 当前实例,支持链式调用 */ atAll() { this.at_all = true; this.text('@{all} '); return this; } /** * 添加@在线用户到消息中 * @returns 当前实例,支持链式调用 */ atHear() { this.at_hear = true; this.text('@{hear} '); return this; } /** * 添加标题到消息中,支持Markdown格式 * @param text 标题文本 * @param level 标题级别,1或2 * @returns 当前实例,支持链式调用 */ header(text, level = 1) { if (!this.msg.endsWith('\n')) this.text('\n'); this.text(`${'#'.repeat(level)} ${text}\n`); return this; } /** * 添加有序列表到消息中 * @param text 有序列表文本 * @returns 当前实例,支持链式调用 */ order(text) { const lastLine = this.getLastLine(); const lastLineNum = lastLine.split('.')[0]; let num = 1; if (lastLineNum.match(/^\d+$/)) { num = parseInt(lastLineNum) + 1; } if (!this.msg.endsWith('\n')) this.text('\n'); this.text(`${num}. ${text}\n`); return this; } /** * 添加列表项到消息中,支持Markdown格式 * @param text 列表项文本 * @param indent 缩进级别,默认为1 * @returns 当前实例,支持链式调用 */ list(text, indent = 1) { if (!this.msg.endsWith('\n')) this.text('\n'); for (let i = 1; i < indent; i++) { this.text(' '); } this.text(`* ${text}\n`); return this; } /** * 获取消息中的最后一行文本 * @returns 最后一行文本 */ getLastLine() { const line = this.msg.split('\n').pop(); return line || ''; } /** * 转换当前实例为Message类型,移除不必要的属性 * @returns 转换后的Message实例 */ convert() { const message = Object.assign({}, this); delete message.at_all; delete message.at_hear; delete message.addition_original; return message; } } exports.ExtendedMarkdownMessageImpl = ExtendedMarkdownMessageImpl; /** * 表示原始卡片信息 * 此类用于存储原始卡片数据的集合和相关处理逻辑 */ class CardOriginal { /** * 构造函数,初始化卡片数据 * @param borderColor 边框颜色,默认为空字符串 * @param size 卡片大小,默认为'medium' */ constructor(borderColor = '', size = 'medium') { // 当前操作的卡片索引 this.index = 0; this.data = [ { type: 'card', border_color: borderColor, size: size, modules: [] } ]; } /** * 新增一个卡片 * @param borderColor 边框颜色,默认为空字符串 * @param size 卡片大小,默认为'medium' * @returns 返回当前实例 */ newCard(borderColor = '', size = 'medium') { this.data.push({ type: 'card', border_color: borderColor, size: size, modules: [] }); this.index = this.data.length - 1; return this; } /** * 添加一个模块到当前卡片 * @param module 要添加的模块 * @returns 返回当前实例 */ addModule(module) { this.data[this.index].modules.push(module); return this; } /** * 添加一个标题模块 * @param text 标题文本 * @returns 返回当前实例 */ header(text) { this.addModule({ type: 'header', content: { type: 'plain-text', text: text } }); return this; } /** * 添加一个段落模块 * @param paragraph 段落内容 * @returns 返回当前实例 */ section(...paragraph) { if (paragraph.length > 5) { throw new Error('段落内容不能超过5列'); } this.addModule({ type: 'section', paragraph: paragraph }); return this; } /** * 添加一个带图片的文本模块 * @param text 文本内容 * @param image 图片路径 * @param position 图片位置 */ textWithImage(text, image, position = 'right') { const txt = { type: 'plain-text', text: text }; const img = { type: 'image', url: utils_1.Request.uploadFileSync(image), size: 'medium' }; this.addModule({ type: 'section', paragraph: position == 'right' ? [txt, img] : [img, txt] }); } /** * 添加一个带图片的Markdown模块 * @param markdown Markdown内容 * @param image 图片路径 * @param position 图片位置 */ markdownWithImage(markdown, image, position = 'right') { const md = { type: 'markdown', text: markdown }; const img = { type: 'image', url: utils_1.Request.uploadFileSync(image), size: 'medium' }; this.addModule({ type: 'section', paragraph: position == 'right' ? [md, img] : [img, md] }); } /** * 添加一个带按钮的文本模块 * @param text 文本内容 * @param button 按钮配置 * @returns 返回当前实例 */ textWithButton(text, button) { button.type = 'button'; this.addModule({ type: 'section', paragraph: [ { type: 'plain-text', text: text }, { type: 'button', event: button.event || 'internal', value: button.value || button.text, text: button.text, theme: button.theme || 'primary' } ] }); return this; } /** * 添加一个带按钮的Markdown模块 * @param markdown Markdown内容 * @param button 按钮配置 * @returns 返回当前实例 */ markdownWithButton(markdown, button) { button.type = 'button'; this.addModule({ type: 'section', paragraph: [ { type: 'markdown', text: markdown }, { type: 'button', event: button.event || 'internal', value: button.value || button.text, text: button.text, theme: button.theme || 'primary' } ] }); return this; } /** * 添加一个纯文本模块 * @param text 文本内容 * @returns 返回当前实例 */ text(text) { this.addModule({ type: 'section', paragraph: [ { type: 'plain-text', text: text } ] }); return this; } /** * 添加一个Markdown模块 * @param markdown Markdown内容 * @returns 返回当前实例 */ markdown(markdown) { this.addModule({ type: 'section', paragraph: [ { type: 'markdown', text: markdown } ] }); return this; } /** * 添加一个图片模块 * @param images 图片路径数组 * @returns 返回当前实例 */ images(...images) { if (images.length > 9) { throw new Error('图片数量不能超过9张'); } this.addModule({ type: 'images', urls: images.map(image => ({ url: utils_1.Request.uploadFileSync(image) })) }); return this; } /** * 添加一个按钮组模块 * @param buttons 按钮配置数组 * @returns 返回当前实例 */ buttons(...buttons) { if (buttons.length > 3) { throw new Error('按钮数量不能超过3个'); } this.addModule({ type: 'button-group', btns: buttons.map(button => { return { type: 'button', event: button.event || 'internal', value: button.value || button.text, text: button.text, theme: button.theme || 'primary' }; }) }); return this; } /** * 添加一个分割线模块 * @param text 分割线文本,可选 * @returns 返回当前实例 */ divider(text = undefined) { this.addModule({ type: 'divider', text: text }); return this; } /** * 添加一个倒计时模块 * @param time 倒计时时间戳 * @param mode 倒计时模式 * @returns 返回当前实例 */ countdown(time, mode) { this.addModule({ type: 'countdown', mode: mode, end_time: time }); return this; } /** * 将卡片数据转换为字符串 * @returns 返回卡片数据的JSON字符串 */ toString() { return JSON.stringify(this); } } exports.CardOriginal = CardOriginal; /** * 实现卡片消息的类 */ class CardMessageImpl extends AbstractMessageImpl { // 私有构造函数,防止外部直接实例化 constructor() { super(20); // 消息类型,固定为20 this.msg_type = 20; // 卡片原始对象 this.card_original = new CardOriginal(); } /** * 创建卡片消息实例 * @returns 返回卡片消息实例 */ static create() { return new CardMessageImpl(); } /** * 添加一个标题模块 * @param text 标题文本 * @returns 返回当前实例 */ header(text) { this.card_original.header(text); this.msg = this.card_original.toString(); return this; } /** * 添加一个段落模块 * @param paragraph 段落内容 * @returns 返回当前实例 */ section(...paragraph) { this.card_original.section(...paragraph); this.msg = this.card_original.toString(); return this; } /** * 添加一个带图片的文本模块 * @param text 文本内容 * @param image 图片路径 * @param position 图片位置 */ textWithImage(text, image, position = 'right') { this.card_original.textWithImage(text, image, position); this.msg = this.card_original.toString(); return this; } /** * 添加一个带图片的Markdown模块 * @param markdown Markdown内容 * @param image 图片路径 * @param position 图片位置 */ markdownWithImage(markdown, image, position = 'right') { this.card_original.markdownWithImage(markdown, image, position); this.msg = this.card_original.toString(); return this; } /** * 添加一个带按钮的文本模块 * @param text 文本内容 * @param button 按钮配置 * @returns 返回当前实例 */ textWithButton(text, button) { this.card_original.textWithButton(text, button); this.msg = this.card_original.toString(); return this; } /** * 添加一个带按钮的Markdown模块 * @param markdown Markdown内容 * @param button 按钮配置 * @returns 返回当前实例 */ markdownWithButton(markdown, button) { this.card_original.markdownWithButton(markdown, button); this.msg = this.card_original.toString(); return this; } /** * 添加一个纯文本模块 * @param text 文本内容 * @returns 返回当前实例 */ text(text) { this.card_original.text(text); this.msg = this.card_original.toString(); return this; } /** * 添加一个Markdown模块 * @param markdown Markdown内容 * @returns 返回当前实例 */ markdown(markdown) { this.card_original.markdown(markdown); this.msg = this.card_original.toString(); return this; } /** * 添加一个图片模块 * @param images 图片路径数组 * @returns 返回当前实例 */ images(...images) { this.card_original.images(...images); this.msg = this.card_original.toString(); return this; } /** * 添加一个按钮组模块 * @param buttons 按钮配置数组 * @returns 返回当前实例 */ buttons(...buttons) { this.card_original.buttons(...buttons); this.msg = this.card_original.toString(); return this; } /** * 添加一个分割线模块 * @param text 分割线文本,可选 * @returns 返回当前实例 */ divider(text = undefined) { this.card_original.divider(text); this.msg = this.card_original.toString(); return this; } /** * 添加一个倒计时模块 * @param time 倒计时时间戳 * @param mode 倒计时模式 * @returns 返回当前实例 */ countdown(time, mode) { dayjs_1.default.extend(utc_1.default); this.card_original.countdown((0, dayjs_1.default)().utc().local().add(time, 'seconds').unix(), mode); this.msg = this.card_original.toString(); return this; } /** * 将卡片消息转换为通用消息格式 * @returns 返回转换后的消息对象 */ convert() { const message = Object.assign({}, this); delete message.card_original; delete message.addition_original; return message; } } exports.CardMessageImpl = CardMessageImpl; /** * MessageBuilder类用于构建各种类型的消息对象 * 它提供了一系列方法来创建和定制消息,如文本、Markdown、卡片消息等 */ class MessageBuilder { constructor() { // 初始化消息对象为一个空文本消息 this.message = this.text(''); } /** * 将消息类型转换为Markdown格式 * @returns {ExtendedMarkdownMessageImpl} 返回一个扩展的Markdown消息实现对象 */ markdown() { return (this.message = ExtendedMarkdownMessageImpl.create()); } /** * 创建一个卡片消息对象 * @returns {CardMessageImpl} 返回一个实现了卡片消息接口的对象 */ card() { return (this.message = CardMessageImpl.create()); } /** * 在消息中添加一张图片 * @param {string} url 图片的URL地址 * @param {number} width 图片的宽度 * @param {number} height 图片的高度 * @returns {AbstractMessageImpl} 返回消息对象本身,以便进行链式调用 */ image(url, width, height) { return (this.message = this.markdown().image(url, width, height)); } /** * 在消息中添加一段文本 * @param {string} text 要添加的文本内容 * @param {boolean} bold 是否以粗体显示文本,默认为false * @param {boolean} italic 是否以斜体显示文本,默认为false * @returns {AbstractMessageImpl} 返回消息对象本身,以便进行链式调用 */ text(text, bold = false, italic = false) { return (this.message = this.markdown().text(text, bold, italic)); } /** * 构建最终的消息对象 * @returns {Message} 返回构建完成的消息对象 */ build() { return this.message.convert(); } } exports.MessageBuilder = MessageBuilder; /** * 定义一个抽象的用户消息实现类,提供了消息的基本属性和方法 * @implements {UserMessage} */ class AbstractUserMessageImpl { constructor() { /** * Heychat确认ID,所有消息的确认ID都是唯一的 */ this.heychat_ack_id = `${utils_1.Util.getAckId()}`; /** * 接收消息的用户ID,默认为0 */ this.to_user_id = 0; } /** * 设置消息的接收者ID * @param {number} userId - 接收消息的用户ID * @returns {this} 返回当前实例,支持链式调用 */ to(userId) { this.to_user_id = userId; return this; } } exports.AbstractUserMessageImpl = AbstractUserMessageImpl; /** * Markdown用户消息的具体实现类,用于创建和操作Markdown格式的消息 * @implements {MarkdownUserMessage} * @extends {AbstractUserMessageImpl} */ class MarkdownUserMessageImpl extends AbstractUserMessageImpl { /** * 构造函数,私有以防止外部直接实例化 */ constructor() { super(); /** * 消息类型常量,Markdown消息类型为4 */ this.msg_type = 4; /** * Markdown消息内容 */ this.msg = ''; /** * 消息的附加信息,以字符串形式存储 */ this.addition = '{}'; /** * 消息的原始附加信息,包含图片文件信息 */ this.addition_original = { img_files_info: [] }; } /** * 创建一个新的MarkdownUserMessageImpl实例 * @returns {MarkdownUserMessageImpl} 新的实例对象 */ static create() { return new MarkdownUserMessageImpl(); } /** * 添加文本内容到消息中,支持Markdown格式 * @param {string} text - 要添加的文本 * @param {boolean} bold - 是否加粗文本,默认为false * @param {boolean} italic - 是否斜体文本,默认为false * @param {boolean} strikethrough - 是否删除线文本,默认为false * @returns {this} 返回当前实例,支持链式调用 */ text(text, bold = false, italic = false, strikethrough = false) { let msg = `${text}`; if (italic) msg = `*${msg}*`; if (bold) msg = `**${msg}**`; if (strikethrough) msg = `~~${msg}~~`; const flag = this.msg.endsWith('*') || this.msg.endsWith('~'); if (this.msg[this.msg.length - 1] == msg[0] && flag) this.msg += ' '; this.msg += msg; return this; } /** * 添加超链接到消息中 * @param {string} url - 链接地址 * @param {string} text - 显示的链接文本,默认为链接地址 * @param {boolean} bold - 是否加粗文本,默认为false * @param {boolean} italic - 是否斜体文本,默认为false * @param {boolean} strikethrough - 是否删除线文本,默认为false * @returns {this} 返回当前实例,支持链式调用 */ link(url, text = url, bold = false, italic = false, strikethrough = false) { this.msg += `[`; this.text(text, bold, italic, strikethrough); this.msg += `](${url})`; return this; } /** * 添加图片到消息中,内部使用 * @param {string} url - 图片链接地址 * @param {number} width - 图片宽度 * @param {number} height - 图片高度 * @returns {this} 返回当前实例,支持链式调用 */ addImage(url, width, height) { var _a; (_a = this.addition_original) === null || _a === void 0 ? void 0 : _a.img_files_info.push({ url, width, height }); this.msg += `![](${url})`; this.addition = JSON.stringify(this.addition_original); return this; } /** * 添加图片到消息中,支持不同来源的图片 * @param {BufferSource | string} url - 图片链接地址或文件 * @param {number} width - 图片宽度 * @param {number} height - 图片高度 * @returns {this} 返回当前实例,支持链式调用 */ image(url, width, height) { if (typeof url !== 'string' || !url.includes(constants_1.default.CDN_URL)) { this.addImage(utils_1.Request.uploadFileSync(url), width, height); return this; } else { this.addImage(url, width, height); } return this; } /** * 添加标题到消息中 * @param {string} text - 标题文本 * @param {1 | 2} level - 标题级别,默认为1 * @returns {this} 返回当前实例,支持链式调用 */ header(text, level = 1) { if (!this.msg.endsWith('\n')) this.text('\n'); this.text(`${'#'.repeat(level)} ${text}\n`); return this; } /** * 添加有序列表到消息中 * @param {string} text - 有序列表文本 * @returns {this} 返回当前实例,支持链式调用 */ order(text) { const lastLine = this.getLastLine(); const lastLineNum = lastLine.split('.')[0]; let num = 1; if (lastLineNum.match(/^\d+$/)) { num = parseInt(lastLineNum) + 1; } if (!this.msg.endsWith('\n')) this.text('\n'); this.text(`${num}. ${text}\n`); return this; } /** * 添加列表项到消息中 * @param {string} text - 列表项文本 * @param {number} indent - 缩进级别,默认为1 * @returns {this} 返回当前实例,支持链式调用 */ list(text, indent = 1) { if (!this.msg.endsWith('\n')) this.text('\n'); for (let i = 1; i < indent; i++) { this.text(' '); } this.text(`* ${text}\n`); return this; } /** * 获取消息的最后一行文本 * @returns {string} 最后一行文本,如果没有则返回空字符串 */ getLastLine() { const line = this.msg.split('\n').pop(); return line || ''; } /** * 将当前实例转换为UserMessage接口定义的消息格式 * @returns {UserMessage} 转换后的消息对象 */ convert() { const message = Object.assign({}, this); delete message.addition_original; return message; } } exports.MarkdownUserMessageImpl = MarkdownUserMessageImpl; /** * 图片用户消息的具体实现类,用于创建和操作图片消息 * @implements {ImageUserMessage} * @extends {AbstractUserMessageImpl} */ class ImageUserMessageImpl extends AbstractUserMessageImpl { /** * 构造函数,私有以防止外部直接实例化 * @param {BufferSource | string} img - 图片链接地址或文件 */ constructor(img) { super(); /** * 消息类型常量,图片消息类型为3 */ this.msg_type = 3; this.img = utils_1.Request.uploadFileSync(img); } /** * 创建一个新的ImageUserMessageImpl实例 * @param {BufferSource | string} img - 图片链接地址或文件 * @returns {ImageUserMessageImpl} 新的实例对象 */ static create(img) { return new ImageUserMessageImpl(img); } /** * 将当前实例转换为UserMessage接口定义的消息格式 * @returns {UserMessage} 转换后的消息对象 */ convert() { return this; } } exports.ImageUserMessageImpl = ImageUserMessageImpl; /** * 用户消息构建器,用于创建和操作不同类型的消息 */ class UserMessageBuilder { constructor() { /** * 当前构建的消息实例,默认为Markdown消息实例 */ this.message = MarkdownUserMessageImpl.create(); } /** * 创建一个新的Markdown消息实例 * @returns {MarkdownUserMessageImpl} 新的Markdown消息实例 */ markdown() { return (this.message = MarkdownUserMessageImpl.create()); } /** * 创建一个新的图片消息实例 * @param {BufferSource | string} image - 图片链接地址或文件 * @returns {AbstractUserMessageImpl} 新的图片消息实例 */ image(image) { return (this.message = ImageUserMessageImpl.create(image)); } /** * 创建一个新的Markdown消息实例,并添加文本内容 * @param {string} text - 要添加的文本 * @returns {AbstractUserMessageImpl} 新的Markdown消息实例 */ text(text) { return (this.message = MarkdownUserMessageImpl.create().text(text)); } /** * 构建并返回当前消息实例 * @returns {UserMessage} 构建后的消息对象 */ build() { return this.message.convert(); } } exports.UserMessageBuilder = UserMessageBuilder; //# sourceMappingURL=index.js.map