Skip to content

Commit

Permalink
🔥 feat:onebot11更多消息结构
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Apr 20, 2024
1 parent 21e888c commit d39a78d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- [ ] 支持redis集群

> 关于`puppeteer`,由于内置的chrome过于臃肿,将会移除内置的pupppeteer,分开搭建或使用远程、作为插件等方式使用puppeteer。
> [karin-plugin-puppeteer](https://github.com/KarinJS/karin-plugin-puppeteer)
> [karin-plugin-puppeteer](https://github.com/KarinJS/karin-puppeteer)
### 感谢

Expand Down
41 changes: 36 additions & 5 deletions lib/adapter/onebot/OneBot11.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,45 @@ class OneBot11 {
case 'face':
elements.push({ type: 'face', data: { id: i.id } })
break
case 'image':
elements.push({ type: 'image', data: { file: i.file } })
break
case 'at':
elements.push({ type: 'at', data: { qq: String(i.uid || i.uin) } })
break
case 'reply':
elements.push({ type: 'reply', data: { id: i.message_id } })
break
case 'file':
elements.push({ type: 'file', data: { file: i.file } })
case 'image':
case 'video':
case 'file': {
elements.push({ type: i.type, data: { file: i.file } })
break
}
case 'xml':
case 'json': {
elements.push({ type: i.type, data: { data: i.data } })
break
}
case 'node': {
const { type, user_id, nickname, content } = i
elements.push({ type, data: { user_id, nickname, content } })
break
}
case 'forward': {
elements.push({ type: 'forward', data: { id: i.id } })
break
}
case 'record': {
elements.push({ type: 'record', data: { file: i.file, magic: i.magic || false } })
break
}
case 'music': {
if (i.platform) {
elements.push({ type: 'music', data: { type: i.platform, id: i.id } })
} else {
const { url, audio, title, content, image } = i
elements.push({ type: 'music', data: { type: 'custom', url, audio, title, content, image } })
}
break
}
case 'button': {
elements.push({ type: 'button', data: { buttons: i.buttons } })
break
Expand All @@ -372,6 +399,10 @@ class OneBot11 {
}
break
}
case 'poke': {
elements.push({ type: 'poke', data: { type: i.poke, id: i.id } })
break
}
default: {
elements.push(i)
logger.info(i)
Expand Down
2 changes: 1 addition & 1 deletion lib/bot/segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Segment {
},
action: {
// 设置 0 跳转按钮:http 或 小程序 客户端识别 scheme,设置 1 回调按钮:回调后台接口, data 传给后台,设置 2 指令按钮:自动在输入框插入 @bot data
type: type === 0 ? 0 : (type || 2),
type,
// 操作相关的数据
data: i.data || i.link || i.text,
// 客户端不支持本action的时候,弹出的toast文案
Expand Down

0 comments on commit d39a78d

Please sign in to comment.