1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 12:43:31 +08:00

add: poke sending.

This commit is contained in:
Mrs4s 2020-09-13 22:07:45 +08:00
parent fef9395890
commit 741a91cf70
3 changed files with 36 additions and 0 deletions

View File

@ -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

View File

@ -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")

View File

@ -32,6 +32,20 @@ Type: `redbag`
示例: `[CQ:redbag,title=恭喜发财]`
### 戳一戳
Type: `poke`
范围: **发送(仅群聊)**
参数:
| 参数名 | 类型 | 说明 |
| ------ | ------ | ----------- |
| qq | int64 | 需要戳的成员 |
示例: `[CQ:poke,qq=123456]`
### 合并转发
Type: `forward`