@alemonjs/bubble 2.1.0-alpha.5 → 2.1.0-alpha.6
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/send.js +21 -5
- package/package.json +2 -2
package/lib/send.js
CHANGED
|
@@ -14,7 +14,7 @@ const sendToRoom = async (client, param, val) => {
|
|
|
14
14
|
const threadId = String(param?.thread_id ?? '');
|
|
15
15
|
const messageId = param?.message_id ? String(param?.message_id) : undefined;
|
|
16
16
|
const images = val.filter(item => item.type === 'Image' || item.type === 'ImageURL' || item.type === 'ImageFile');
|
|
17
|
-
const
|
|
17
|
+
const mdAndButtons = val.filter(item => item.type === 'Markdown' || item.type === 'BT.group');
|
|
18
18
|
const content = val
|
|
19
19
|
.filter(item => item.type === 'Mention' || item.type === 'Text' || item.type === 'Link')
|
|
20
20
|
.map(item => {
|
|
@@ -93,8 +93,8 @@ const sendToRoom = async (client, param, val) => {
|
|
|
93
93
|
return [createResult(ResultCode.Ok, '完成', null)];
|
|
94
94
|
}
|
|
95
95
|
let contentMd = '';
|
|
96
|
-
if (
|
|
97
|
-
|
|
96
|
+
if (mdAndButtons && mdAndButtons.length > 0) {
|
|
97
|
+
mdAndButtons.forEach(item => {
|
|
98
98
|
if (item.type === 'Markdown') {
|
|
99
99
|
const md = item.value;
|
|
100
100
|
md.forEach(line => {
|
|
@@ -141,15 +141,31 @@ const sendToRoom = async (client, param, val) => {
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
else if (item.type === 'BT.group' && item.value.length > 0) {
|
|
145
|
+
contentMd += `<box>${item.value?.map(row => {
|
|
146
|
+
const val = row.value;
|
|
147
|
+
if (val.length === 0) {
|
|
148
|
+
return '';
|
|
149
|
+
}
|
|
150
|
+
return `<flex>${val.map(button => {
|
|
151
|
+
const value = button.value;
|
|
152
|
+
const options = button.options;
|
|
153
|
+
const autoEnter = options?.autoEnter ?? false;
|
|
154
|
+
const label = typeof value === 'object' ? value.title : value;
|
|
155
|
+
const command = options?.data || label;
|
|
156
|
+
return `<btn command="${command}" enter="${String(autoEnter)}" >${label}</btn>`;
|
|
157
|
+
}).join('')}</flex>`;
|
|
158
|
+
}).join('')}</box>`;
|
|
159
|
+
}
|
|
144
160
|
});
|
|
145
161
|
}
|
|
146
162
|
if ((content && content.length > 0) || (contentMd && contentMd.length > 0)) {
|
|
147
163
|
if (channelId) {
|
|
148
|
-
const res = await client.sendMessage(channelId, { content: content
|
|
164
|
+
const res = await client.sendMessage(channelId, { content: content !== '' ? content : contentMd, type: 'text' });
|
|
149
165
|
return [createResult(ResultCode.Ok, '完成', res)];
|
|
150
166
|
}
|
|
151
167
|
if (threadId) {
|
|
152
|
-
const res = await client.sendDm(threadId, { content: content
|
|
168
|
+
const res = await client.sendDm(threadId, { content: content !== '' ? content : contentMd, type: 'text' });
|
|
153
169
|
return [createResult(ResultCode.Ok, '完成', res)];
|
|
154
170
|
}
|
|
155
171
|
return [createResult(ResultCode.Ok, '完成', null)];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/bubble",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.6",
|
|
4
4
|
"description": "bubble platform",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
"type": "git",
|
|
66
66
|
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|