@alemonjs/qq-bot 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/format.js +2 -3
- package/lib/sends.js +14 -2
- package/package.json +1 -1
package/lib/format.js
CHANGED
|
@@ -58,8 +58,7 @@ const markdownToText = (items, hideUnsupported) => {
|
|
|
58
58
|
return String(item?.value ?? '');
|
|
59
59
|
}
|
|
60
60
|
})
|
|
61
|
-
.join('')
|
|
62
|
-
.trim();
|
|
61
|
+
.join('');
|
|
63
62
|
};
|
|
64
63
|
const buttonsToText = (rows) => {
|
|
65
64
|
return rows.map((row) => row.value.map((btn) => `[${btn.value}]`).join(' ')).join('\n');
|
|
@@ -84,7 +83,7 @@ const markdownRawToText = (raw, hideUnsupported) => {
|
|
|
84
83
|
text = text.replace(/^[-*_]{3,}\s*$/gm, hideUnsupported ? '' : '————————');
|
|
85
84
|
text = text.replace(/^[\s]*[-*+]\s+/gm, '· ');
|
|
86
85
|
text = text.replace(/^[\s]*(\d+)\.\s+/gm, '$1. ');
|
|
87
|
-
return text
|
|
86
|
+
return text;
|
|
88
87
|
};
|
|
89
88
|
const dataEnumToText = (item, hideUnsupported) => {
|
|
90
89
|
if (Number(hideUnsupported) >= 4)
|
package/lib/sends.js
CHANGED
|
@@ -172,6 +172,7 @@ const extractContent = (val, mode) => {
|
|
|
172
172
|
'ImageFile',
|
|
173
173
|
'ImageURL',
|
|
174
174
|
'Markdown',
|
|
175
|
+
'MarkdownOriginal',
|
|
175
176
|
'BT.group',
|
|
176
177
|
'ButtonTemplate',
|
|
177
178
|
'Ark.list',
|
|
@@ -209,7 +210,7 @@ const buildBaseParams = (tag, messageId, interactionTag) => {
|
|
|
209
210
|
return { msg_id: messageId };
|
|
210
211
|
};
|
|
211
212
|
const buildMdAndButtonsParams = (val) => {
|
|
212
|
-
const items = val.filter(item => item.type === 'Markdown' || item.type === 'BT.group' || item.type === 'ButtonTemplate');
|
|
213
|
+
const items = val.filter(item => item.type === 'Markdown' || item.type === 'MarkdownOriginal' || item.type === 'BT.group' || item.type === 'ButtonTemplate');
|
|
213
214
|
if (items.length === 0) {
|
|
214
215
|
return null;
|
|
215
216
|
}
|
|
@@ -247,6 +248,14 @@ const buildMdAndButtonsParams = (val) => {
|
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
}
|
|
251
|
+
else if (item.type === 'MarkdownOriginal' && typeof item?.value === 'string') {
|
|
252
|
+
if (params['markdown']?.content) {
|
|
253
|
+
params['markdown'].content += '\n' + item.value;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
params['markdown'] = { content: item.value };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
250
259
|
}
|
|
251
260
|
if (params['keyboard']?.content?.nextId !== undefined) {
|
|
252
261
|
delete params['keyboard'].content.nextId;
|
|
@@ -326,7 +335,10 @@ const flattenMdToText = (content, val) => {
|
|
|
326
335
|
parts.push(buttonsToText(item.value));
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
|
-
return parts
|
|
338
|
+
return parts
|
|
339
|
+
.filter(Boolean)
|
|
340
|
+
.join('\n')
|
|
341
|
+
.replace(/^[^\S\n\r]+|[^\S\n\r]+$/g, '');
|
|
330
342
|
};
|
|
331
343
|
const sendOpenApiMessage = async (content, val, baseParams, uploadMedia, sendMessage, label) => {
|
|
332
344
|
const config = getQQBotConfig();
|