feat: add support for Markdown messages in QQ channel
This commit is contained in:
parent
81dfdf5f45
commit
06d0e43b50
3 changed files with 15 additions and 3 deletions
|
|
@ -11,7 +11,8 @@ PicoClaw 通过 QQ 开放平台的官方机器人 API 提供对 QQ 的支持。
|
|||
"enabled": true,
|
||||
"app_id": "YOUR_APP_ID",
|
||||
"app_secret": "YOUR_APP_SECRET",
|
||||
"allow_from": []
|
||||
"allow_from": [],
|
||||
"allow_markdown": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +24,7 @@ PicoClaw 通过 QQ 开放平台的官方机器人 API 提供对 QQ 的支持。
|
|||
| app_id | string | 是 | QQ 机器人应用的 App ID |
|
||||
| app_secret | string | 是 | QQ 机器人应用的 App Secret |
|
||||
| allow_from | array | 否 | 用户ID白名单,空表示允许所有用户 |
|
||||
| allow_markdown| bool| 否 | 是否允许使用 Markdown 格式发送消息 |
|
||||
|
||||
## 设置流程
|
||||
|
||||
|
|
|
|||
|
|
@ -122,12 +122,21 @@ func (c *QQChannel) Send(ctx context.Context, msg bus.OutboundMessage) error {
|
|||
}
|
||||
|
||||
// construct message
|
||||
msgToCreate := &dto.MessageToCreate{
|
||||
msgToCreate := dto.MessageToCreate{
|
||||
Content: msg.Content,
|
||||
MsgType: dto.TextMsg,
|
||||
}
|
||||
if c.config.AllowMarkdown {
|
||||
msgToCreate = dto.MessageToCreate{
|
||||
MsgType: dto.MarkdownMsg,
|
||||
Markdown: &dto.Markdown{
|
||||
Content: msg.Content,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// send C2C message
|
||||
_, err := c.api.PostC2CMessage(ctx, msg.ChatID, msgToCreate)
|
||||
_, err := c.api.PostC2CMessage(ctx, msg.ChatID, &msgToCreate)
|
||||
if err != nil {
|
||||
logger.ErrorCF("qq", "Failed to send C2C message", map[string]any{
|
||||
"error": err.Error(),
|
||||
|
|
|
|||
|
|
@ -309,6 +309,7 @@ type QQConfig struct {
|
|||
AppID string `json:"app_id" env:"PICOCLAW_CHANNELS_QQ_APP_ID"`
|
||||
AppSecret string `json:"app_secret" env:"PICOCLAW_CHANNELS_QQ_APP_SECRET"`
|
||||
AllowFrom FlexibleStringSlice `json:"allow_from" env:"PICOCLAW_CHANNELS_QQ_ALLOW_FROM"`
|
||||
AllowMarkdown bool `json:"allow_markdown" env:"PICOCLAW_CHANNELS_QQ_ALLOW_MARKDOWN"`
|
||||
GroupTrigger GroupTriggerConfig `json:"group_trigger,omitempty"`
|
||||
ReasoningChannelID string `json:"reasoning_channel_id" env:"PICOCLAW_CHANNELS_QQ_REASONING_CHANNEL_ID"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue