diff --git a/coolq/bot.go b/coolq/bot.go index 3083d13..dda64e9 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -139,6 +139,14 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int newElem = append(newElem, gv) continue } + if i, ok := elem.(*PokeElement); ok { + if group := bot.Client.FindGroup(groupId); group != nil { + if mem := group.FindMember(i.Target); mem != nil { + mem.Poke() + return 0 + } + } + } newElem = append(newElem, elem) } m.Elements = newElem diff --git a/coolq/cqcode.go b/coolq/cqcode.go index b67674a..c5a74f2 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -26,6 +26,14 @@ var paramReg = regexp.MustCompile(`,([\w\-.]+?)=([^,\]]+)`) var IgnoreInvalidCQCode = false +type PokeElement struct { + Target int64 +} + +func (e *PokeElement) Type() message.ElementType { + return message.At +} + func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []MSG) { ur := false if len(raw) != 0 { @@ -319,6 +327,12 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. return message.NewText(d["text"]), nil case "image": return bot.makeImageElem(t, d, group) + case "poke": + if !group { + return nil, errors.New("todo") // TODO: private poke + } + t, _ := strconv.ParseInt(d["qq"], 10, 64) + return &PokeElement{Target: t}, nil case "record": if !group { return nil, errors.New("private voice unsupported now") diff --git a/docs/cqhttp.md b/docs/cqhttp.md index 56bef0b..3b5a995 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -32,6 +32,20 @@ Type: `redbag` 示例: `[CQ:redbag,title=恭喜发财]` +### 戳一戳 + +Type: `poke` + +范围: **发送(仅群聊)** + +参数: + +| 参数名 | 类型 | 说明 | +| ------ | ------ | ----------- | +| qq | int64 | 需要戳的成员 | + +示例: `[CQ:poke,qq=123456]` + ### 合并转发 Type: `forward`