@alemonjs/qq-bot 2.1.0-alpha.23 → 2.1.0-alpha.25

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.
Files changed (2) hide show
  1. package/lib/sends.js +26 -4
  2. package/package.json +1 -1
package/lib/sends.js CHANGED
@@ -97,10 +97,10 @@ const mdFormatters = {
97
97
  if (belong === 'channel') {
98
98
  return '';
99
99
  }
100
- if (belong === 'all') {
101
- return '<qqbot-at-everyone />';
100
+ if (belong === 'user') {
101
+ return `<qqbot-at-user id="${value}" />`;
102
102
  }
103
- if (value === 'everyone' || value === 'all' || value === '' || typeof value !== 'string') {
103
+ if (value === 'everyone') {
104
104
  return '<qqbot-at-everyone />';
105
105
  }
106
106
  return `<qqbot-at-user id="${value}" />`;
@@ -239,7 +239,29 @@ const resolveRichMediaUrl = async (images, uploadMedia) => {
239
239
  url = item.value;
240
240
  }
241
241
  else if (item.type === 'ImageFile' || item.type === 'Image') {
242
- const fileData = item.type === 'ImageFile' ? readFileSync(item.value, 'base64') : item.value;
242
+ let fileData;
243
+ if (item.type === 'ImageFile') {
244
+ fileData = readFileSync(item.value, 'base64');
245
+ }
246
+ else {
247
+ if (typeof item.value === 'string' && (item.value.startsWith('https://') || item.value.startsWith('http://'))) {
248
+ fileData = await axios.get(item.value, { responseType: 'arraybuffer' }).then(res => Buffer.from(res.data, 'binary').toString('base64'));
249
+ continue;
250
+ }
251
+ else if (typeof item.value === 'string' && item.value.startsWith('file://')) {
252
+ const localFilePath = item.value.replace('file://', '');
253
+ fileData = readFileSync(localFilePath, 'base64');
254
+ continue;
255
+ }
256
+ else if (typeof item.value === 'string' && item.value.startsWith('base64://')) {
257
+ fileData = item.value.replace('base64://', '');
258
+ continue;
259
+ }
260
+ else if (Buffer.isBuffer(item.value)) {
261
+ fileData = item.value.toString('base64');
262
+ continue;
263
+ }
264
+ }
243
265
  const fileInfo = await uploadMedia({ file_type: 1, file_data: fileData }).then(res => res?.file_info);
244
266
  if (fileInfo) {
245
267
  url = fileInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alemonjs/qq-bot",
3
- "version": "2.1.0-alpha.23",
3
+ "version": "2.1.0-alpha.25",
4
4
  "description": "阿柠檬qq-bot平台连接",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",