Skip to content

Commit

Permalink
feat(qq): insert space before attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 26, 2023
1 parent 03bded7 commit 88d18ee
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion adapters/discord/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@satorijs/adapter-discord",
"description": "Discord Adapter for Satorijs",
"version": "4.1.5",
"version": "4.1.6",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion adapters/discord/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function decodeMessage(

// embed 的 update event 太阴间了 只有 id embeds channel_id guild_id 四个成员
if (data.attachments?.length) {
if (message.content) message.content += ' '
if (!/\s$/.test(message.content)) message.content += ' '
message.content += data.attachments.map(v => {
if (v.height && v.width && v.content_type?.startsWith('image/')) {
return h('image', {
Expand Down
2 changes: 1 addition & 1 deletion adapters/qq/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@satorijs/adapter-qq",
"description": "QQ Adapter for Satorijs",
"version": "4.1.14",
"version": "4.1.16",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
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 @@ -69,6 +69,7 @@ export async function decodeMessage(
.replace(/<@!(\d+)>/g, (_, $1) => h.at($1).toString())
// .replace(/<#(.+)>/, (_, $1) => h.sharp($1).toString()) // not used?
const { attachments = [] } = data
if (attachments.length && !/\s$/.test(message.content)) message.content += ' '
message.content = attachments
.filter(({ content_type }) => content_type.startsWith('image'))
.reduce((content, attachment) => content + h.image('https://' + attachment.url), message.content)
Expand Down

0 comments on commit 88d18ee

Please sign in to comment.