Skip to content

Commit

Permalink
fix(qq): fix base64 data url regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 17, 2024
1 parent e5a70df commit bbe05fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ export class QQMessageEncoder<C extends Context = Context> extends MessageEncode
file_type,
srv_send_msg: false,
}
const capture = /^data:([\w/-]+);base64,(.*)$/.exec(url)
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
const capture = /^data:([\w/.+-]+);base64,(.*)$/.exec(url)
if (capture?.[2]) {
data.file_data = capture[2]
} else if (await this.bot.ctx.http.isLocal(url)) {
Expand Down
1 change: 1 addition & 0 deletions adapters/qq/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export async function adaptSession<C extends Context = Context>(bot: QQBot<C>, i
}
session.event.button = {
id: input.d.data.resolved.button_id,
// @ts-ignore
data: input.d.data.resolved.button_data,
}
// session.messageId = input.d.id // event_id is not supported for sending message
Expand Down

0 comments on commit bbe05fe

Please sign in to comment.