@alemonjs/bubble 2.1.0-alpha.5 → 2.1.0-alpha.7
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 +25 -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,35 @@ 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 classWind="mt-2" variant="borderless" >${item.value
|
|
146
|
+
?.map(row => {
|
|
147
|
+
const val = row.value;
|
|
148
|
+
if (val.length === 0) {
|
|
149
|
+
return '';
|
|
150
|
+
}
|
|
151
|
+
return `<flex>${val
|
|
152
|
+
.map(button => {
|
|
153
|
+
const value = button.value;
|
|
154
|
+
const options = button.options;
|
|
155
|
+
const autoEnter = options?.autoEnter ?? false;
|
|
156
|
+
const label = typeof value === 'object' ? value.title : value;
|
|
157
|
+
const command = options?.data || label;
|
|
158
|
+
return `<btn command="${command}" enter="${String(autoEnter)}" >${label}</btn>`;
|
|
159
|
+
})
|
|
160
|
+
.join('')}</flex>`;
|
|
161
|
+
})
|
|
162
|
+
.join('')}</box>`;
|
|
163
|
+
}
|
|
144
164
|
});
|
|
145
165
|
}
|
|
146
166
|
if ((content && content.length > 0) || (contentMd && contentMd.length > 0)) {
|
|
147
167
|
if (channelId) {
|
|
148
|
-
const res = await client.sendMessage(channelId, { content: content
|
|
168
|
+
const res = await client.sendMessage(channelId, { content: content !== '' ? content : contentMd, type: 'text' });
|
|
149
169
|
return [createResult(ResultCode.Ok, '完成', res)];
|
|
150
170
|
}
|
|
151
171
|
if (threadId) {
|
|
152
|
-
const res = await client.sendDm(threadId, { content: content
|
|
172
|
+
const res = await client.sendDm(threadId, { content: content !== '' ? content : contentMd, type: 'text' });
|
|
153
173
|
return [createResult(ResultCode.Ok, '完成', res)];
|
|
154
174
|
}
|
|
155
175
|
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.7",
|
|
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
|
+
}
|