消息格式
信息
一些常用的消息格式说明
可能存在部分平台不支持一些个性效果,实际以对应平台的要求为准
如果想更定制化发送消息,请了解对应平台包client接口说明
Text
src/response/**/*/res.ts
import { Text, useMessage } from 'alemonjs'
const selects = onSelects(['message.create'])
export default onResponse(selects, event => {
// 创建
const [message] = useMessage(event)
message.send(
format(
Text('这个'),
Text('标题', { style: 'bold' }),
Text('被加粗了')
)
)
message.send(
format(Text('这个'), Text('标题'), Text('没有变化'))
)
message.send(
format(
Text(`// 我的代码块 \nconst Send = useSend(event)`, {
style: 'block'
})
)
)
})
Editformat
编辑
预览
Image
src/response/**/*/res.ts
import { useMessage, Image } from 'alemonjs'
import jpgURL from '@src/assets/test.jpeg'
import { readFileSync } from 'node:fs'
const selects = onSelects(['message.create'])
export default onResponse(selects, event => {
const [message] = useMessage(event)
const { url, file } = Image
// file
message.send(format(file(jpgURL)))
// url
message.send(format(url('https://xxx.com/yyy.png')))
// buffer
const img = readFileSync(jpgURL)
message.send(format(Image(img)))
})
Mention
response/**/*/res.ts
import { useMessage, Text, Mention } from 'alemonjs'
const selects = onSelects(['message.create'])
export default onResponse(selects, event => {
const [message] = useMessage(event)
// 发送多种类型的消息
message.send(
format(
Text('Hello '),
Mention(event.UserId),
Text(', How are things going?')
)
)
// @ 所有人
message.send(format(Mention()))
// @ channel
message.send(
format(
Mention(event.ChannelId, {
belong: 'channel'
})
)
)
})
Editformat
编辑
预览