Skip to content

Commit

Permalink
feat(chat): support qq faces
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 11, 2021
1 parent c215069 commit eb7f7a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-discord/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function adaptMessage(bot: DiscordBot, meta: DC.Message, session: P
everyone: meta.mention_everyone,
users: meta.mentions.map(adaptUser),
roles: meta.mention_roles.map(id => ({ id })),
channels: meta.mention_channels.map(data => ({
channels: (meta.mention_channels || []).map(data => ({
channelId: data.id,
channelName: data.name,
groupId: data.guild_id,
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-onebot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"dependencies": {
"axios": "^0.21.1",
"koishi-utils": "^4.2.2",
"qface": "1.1.0",
"ws": "^7.4.5"
}
}
6 changes: 3 additions & 3 deletions packages/adapter-onebot/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CQBot } from './bot'
import { Adapter, Session } from 'koishi-core'
import { Logger, camelCase, renameProperty, paramCase, segment } from 'koishi-utils'
import * as qface from 'qface'
import * as Koishi from 'koishi-core'
import * as OneBot from './types'

Expand Down Expand Up @@ -42,9 +43,8 @@ export function adaptMessage(message: OneBot.Message): Koishi.MessageInfo {
mention.everyone = true
return segment('at', { type: 'all' })
},
reply(data) {
return segment('quote', data)
},
face: ({ id }) => segment('face', { id, url: qface.getUrl(id) }),
reply: (data) => segment('quote', data),
}),
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-chat/client/utils/message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<template v-for="({ type, data }) in segment.parse(content)">
<span v-if="type === 'text'">{{ data.content }}</span>
<k-image v-else-if="type === 'image'" :src="data.url"/>
<img class="face" v-else-if="type === 'face'" :src="data.url"/>
<span v-else-if="segmentTypes[type]">[{{ segmentTypes[type] }}]</span>
<span v-else>[未知]</span>
</template>
Expand All @@ -20,7 +21,6 @@ defineProps<{
}>()
const segmentTypes = {
face: '表情',
record: '语音',
video: '短视频',
image: '图片',
Expand Down Expand Up @@ -50,6 +50,11 @@ const segmentTypes = {
max-height: 320px;
max-width: 100%;
}
img.face {
height: 1.25rem;
vertical-align: middle;
}
}
</style>

0 comments on commit eb7f7a9

Please sign in to comment.