-
Notifications
You must be signed in to change notification settings - Fork 5
/
openapi_v2_message.go
55 lines (48 loc) · 1.4 KB
/
openapi_v2_message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package nano
import (
"strconv"
"github.com/sirupsen/logrus"
)
type MessageType int
const (
MessageTypeText MessageType = iota
MessageTypeTextImage
MessageTypeMarkdown
MessageTypeArk
MessageTypeEmbed
MessageTypeUnk1
MessageTypeUnk2
MessageTypeMedia
)
func (mt2 MessageType) String() string {
switch mt2 {
case MessageTypeText:
return "文本"
case MessageTypeTextImage:
return "图文混排"
case MessageTypeMarkdown:
return "MD"
case MessageTypeArk:
return "模版"
case MessageTypeEmbed:
return "嵌入"
case MessageTypeMedia:
return "富媒体"
default:
return "未知类型" + strconv.Itoa(int(mt2))
}
}
// PostMessageToQQUser 向 openid 指定的用户发送消息
//
// https://bot.q.qq.com/wiki/develop/api-231017/server-inter/message/send-receive/send.html#%E5%8D%95%E8%81%8A
func (bot *Bot) PostMessageToQQUser(id string, content *MessagePost) (*Message, error) {
logrus.Infoln(getLogHeader(), "<= [Q]单:", id+",", content)
return bot.postMessageTo("/v2/users/"+id+"/messages", content)
}
// PostMessageToQQGroup 向 openid 指定的群发送消息
//
// https://bot.q.qq.com/wiki/develop/api-231017/server-inter/message/send-receive/send.html#%E7%BE%A4%E8%81%8A
func (bot *Bot) PostMessageToQQGroup(id string, content *MessagePost) (*Message, error) {
logrus.Infoln(getLogHeader(), "<= [Q]群:", id+",", content)
return bot.postMessageTo("/v2/groups/"+id+"/messages", content)
}