Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/qqfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 25, 2023
2 parents db2285f + 9093165 commit 1edc0d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 8 additions & 3 deletions adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as QQ from './types'
import { Context, Dict, h, MessageEncoder, Quester } from '@satorijs/satori'
import { QQBot } from './bot'
import FormData from 'form-data'
import { escape } from '@satorijs/element'
import { QQGuildBot } from './bot/guild'
import { Entry } from '@satorijs/server-temp'

Expand Down Expand Up @@ -111,7 +110,7 @@ export class QQGuildMessageEncoder<C extends Context = Context> extends MessageE
async visit(element: h) {
const { type, attrs, children } = element
if (type === 'text') {
this.content += escape(attrs.content)
this.content += attrs.content
} else if (type === 'at') {
switch (attrs.type) {
case 'all':
Expand Down Expand Up @@ -297,7 +296,7 @@ export class QQMessageEncoder<C extends Context = Context> extends MessageEncode
async visit(element: h) {
const { type, attrs, children } = element
if (type === 'text') {
this.content += escape(attrs.content)
this.content += attrs.content
} else if (type === 'image' && attrs.url) {
await this.flush()
const data = await this.sendFile(type, attrs)
Expand All @@ -307,6 +306,12 @@ export class QQMessageEncoder<C extends Context = Context> extends MessageEncode
const data = await this.sendFile(type, attrs)
if (data) this.attachedFile = data
await this.flush() // text can't send with video
} else if (type === 'br') {
this.content += '\n'
} else if (type === 'p') {
if (!this.content.endsWith('\n')) this.content += '\n'
await this.render(children)
if (!this.content.endsWith('\n')) this.content += '\n'
} else if (type === 'button-group') {
this.useMarkdown = true
this.rows.push([])
Expand Down
5 changes: 3 additions & 2 deletions adapters/qq/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,13 +1233,14 @@ export interface Interaction {
timestamp: string
guild_id: string
channel_id: string
group_open_id: string
group_openid: string
group_member_openid: string
chat_type: ChatType
data: {
resolved: {
button_data: string
button_id: string
user_id: string
user_id?: string
}
}
version: 1
Expand Down
6 changes: 3 additions & 3 deletions adapters/qq/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ export async function adaptSession<C extends Context = Context>(bot: QQBot<C>, i
session.operatorId = input.d.op_member_openid
} else if (input.t === 'INTERACTION_CREATE') {
session.type = 'interaction/button'
session.userId = input.d.data.resolved.user_id
session.userId = input.d.group_member_openid ?? input.d.data.resolved.user_id
if (input.d.chat_type === QQ.ChatType.GROUP) {
session.guildId = input.d.group_open_id
session.channelId = input.d.group_open_id
session.guildId = input.d.group_openid
session.channelId = input.d.group_openid
session.isDirect = false
} else if (input.d.chat_type === QQ.ChatType.CHANNEL) {
session.channelId = input.d.channel_id
Expand Down

0 comments on commit 1edc0d6

Please sign in to comment.