diff --git a/adapters/dingtalk/src/message.ts b/adapters/dingtalk/src/message.ts index 5197b287..ae097641 100644 --- a/adapters/dingtalk/src/message.ts +++ b/adapters/dingtalk/src/message.ts @@ -92,6 +92,10 @@ export class DingtalkMessageEncoder extends MessageEncoder { // await this.sendMessage('sampleImageMsg', { // photoURL: attrs.url // }) + if (this.bot.ctx.http.isPrivate(attrs.url)) { + throw new Error(`Send ${type} failed, please use public url.`) + // this.buffer += `![${attrs.alt}](https://static.dingtalk.com/media/${media_id}_${width}_${height}.jpg)` + } this.buffer += `![${attrs.alt}](${attrs.url})` } else if (type === 'message') { await this.flush() diff --git a/adapters/line/src/message.ts b/adapters/line/src/message.ts index 8f4f5ba2..ad9d4a5f 100644 --- a/adapters/line/src/message.ts +++ b/adapters/line/src/message.ts @@ -45,6 +45,10 @@ export class LineMessageEncoder extends MessageEncoder { async visit(element: h) { const { type, attrs, children } = element + if (attrs.url && ['image', 'video', 'audio'].includes(type)) { + throw new Error(`Send ${type} failed, please use public url.`) + } + if (type === 'text') { this.buffer += attrs.content } else if (type === 'image' && attrs.url) {