Documentation
¶
Index ¶
- type RobotCustom
- func (rc *RobotCustom) AtAll() RobotOption
- func (rc *RobotCustom) AtMobiles(m ...string) RobotOption
- func (rc *RobotCustom) BtnOrientation(v string) RobotOption
- func (rc *RobotCustom) FeedCard(title, msgURL, picURL string) RobotOption
- func (rc *RobotCustom) HideAvatar(v string) RobotOption
- func (rc *RobotCustom) MultiCard(title, url string) RobotOption
- func (rc *RobotCustom) ParseOutgoing(r io.Reader) (og RobotOutgoing, err error)
- func (rc *RobotCustom) SendActionCard(title, text string, opts ...RobotOption) error
- func (rc *RobotCustom) SendFeedCard(opts ...RobotOption) error
- func (rc *RobotCustom) SendLink(title, text, msgURL, picURL string, opts ...RobotOption) error
- func (rc *RobotCustom) SendMarkdown(title, text string, opts ...RobotOption) error
- func (rc *RobotCustom) SendText(content string, opts ...RobotOption) error
- func (rc *RobotCustom) SetSecret(s string) *RobotCustom
- func (rc *RobotCustom) SetWebhook(t string) *RobotCustom
- func (rc *RobotCustom) SingleCard(title, url string) RobotOption
- func (rc *RobotCustom) WithOutgoing(og RobotOutgoing) RobotOption
- type RobotOption
- type RobotOutgoing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RobotCustom ¶
type RobotCustom struct {
// contains filtered or unexported fields
}
RobotCustom 群机器人-自定义
官方文档: https://developers.dingtalk.com/document/app/custom-robot-access
func (*RobotCustom) AtAll ¶
func (rc *RobotCustom) AtAll() RobotOption
AtAll 设置是否@所有人
适用Text/Markdown类型
示例:
robot.SendMarkdown("TEST: Markdown&AtAll", markdown, robot.AtAll())
func (*RobotCustom) AtMobiles ¶
func (rc *RobotCustom) AtMobiles(m ...string) RobotOption
AtMobiles 设置@人的手机号
适用Text/Markdown类型
示例:
robot.SendMarkdown("TEST: Markdown&AtMobiles", markdown, robot.AtMobiles("19900001111"))
func (*RobotCustom) BtnOrientation ¶
func (rc *RobotCustom) BtnOrientation(v string) RobotOption
BtnOrientation 按钮排列(0-竖直排列, 1-横向排列, 默认1)
适用ActionCard类型
示例:
robot.SendActionCard(
"TEST: ActionCard&BtnOrientation",
"BtnOrientation content",
robot.MultiCard("内容不错", "https://github.com/shockerli"),
robot.MultiCard("不感兴趣", "https://github.com/shockerli"),
robot.BtnOrientation("0"),
)
func (*RobotCustom) FeedCard ¶
func (rc *RobotCustom) FeedCard(title, msgURL, picURL string) RobotOption
FeedCard 添加一个FeedCard项
适用FeedCard类型
示例:
robot.SendFeedCard(
robot.FeedCard("3月15日起,Chromium 不能再调用谷歌 API", "https://bodhi.fedoraproject.org/updates/FEDORA-2021-48866282e5%29", "https://www.wangbase.com/blogimg/asset/202101/bg2021012506.jpg"),
robot.FeedCard("考古学家在英国发现两枚11世纪北宋时期的中国硬币", "https://www.caitlingreen.org/2020/12/another-medieval-chinese-coin-from-england.html", "https://www.wangbase.com/blogimg/asset/202101/bg2021012208.jpg"),
)
func (*RobotCustom) HideAvatar ¶
func (rc *RobotCustom) HideAvatar(v string) RobotOption
HideAvatar 隐藏头像(0-显示, 1-隐藏, 默认0)
适用ActionCard类型
示例:
robot.SendActionCard(
"TEST: ActionCard&HideAvatar",
"24565\n\n\n\nSingleCard content with image",
robot.SingleCard("阅读全文", "https://github.com/shockerli"),
robot.HideAvatar("1"),
)
func (*RobotCustom) MultiCard ¶
func (rc *RobotCustom) MultiCard(title, url string) RobotOption
MultiCard 添加一个MultiCard项
适用ActionCard类型
示例:
robot.SendActionCard(
"TEST: ActionCard&MultiCard",
"MultiCard content",
robot.MultiCard("内容不错", "https://github.com/shockerli"),
robot.MultiCard("不感兴趣", "https://github.com/shockerli"),
)
func (*RobotCustom) ParseOutgoing ¶
func (rc *RobotCustom) ParseOutgoing(r io.Reader) (og RobotOutgoing, err error)
ParseOutgoing 解析Outgoing消息体
示例:
robot.ParseOutgoing(callbackBody)
func (*RobotCustom) SendActionCard ¶
func (rc *RobotCustom) SendActionCard(title, text string, opts ...RobotOption) error
SendActionCard 发送ActionCard消息
示例:
robot.SendActionCard(
"TEST: ActionCard&SingleCard",
"SingleCard content",
robot.SingleCard("阅读全文", "https://github.com/shockerli"),
)
func (*RobotCustom) SendFeedCard ¶
func (rc *RobotCustom) SendFeedCard(opts ...RobotOption) error
SendFeedCard 发送FeedCard消息
示例:
robot.SendFeedCard(
robot.FeedCard("3月15日起,Chromium 不能再调用谷歌 API", "https://bodhi.fedoraproject.org/updates/FEDORA-2021-48866282e5%29", "https://www.wangbase.com/blogimg/asset/202101/bg2021012506.jpg"),
robot.FeedCard("考古学家在英国发现两枚11世纪北宋时期的中国硬币", "https://www.caitlingreen.org/2020/12/another-medieval-chinese-coin-from-england.html", "https://www.wangbase.com/blogimg/asset/202101/bg2021012208.jpg"),
)
func (*RobotCustom) SendLink ¶
func (rc *RobotCustom) SendLink(title, text, msgURL, picURL string, opts ...RobotOption) error
SendLink 发送Link消息
示例:
robot.SendLink( "TEST: Link", "link content", "https://github.com/shockerli", "https://www.wangbase.com/blogimg/asset/202101/bg2021011601.jpg", )
func (*RobotCustom) SendMarkdown ¶
func (rc *RobotCustom) SendMarkdown(title, text string, opts ...RobotOption) error
SendMarkdown 发送Markdown消息
示例:
robot.SendMarkdown("TEST: Markdown", markdown)
robot.SendMarkdown("TEST: Markdown&AtAll", markdown, robot.AtAll())
robot.SendMarkdown("TEST: Markdown&AtMobiles", markdown, robot.AtMobiles("19900001111"))
func (*RobotCustom) SendText ¶
func (rc *RobotCustom) SendText(content string, opts ...RobotOption) error
SendText 发送Text消息
示例:
robot.SendText("TEST: Text")
robot.SendText("TEST: Text&AtAll", robot.AtAll())
robot.SendText("TEST: Text&AtMobiles", robot.AtMobiles("19900001111"))
func (*RobotCustom) SetSecret ¶
func (rc *RobotCustom) SetSecret(s string) *RobotCustom
SetSecret 设置Secret
func (*RobotCustom) SetWebhook ¶
func (rc *RobotCustom) SetWebhook(t string) *RobotCustom
SetWebhook 设置Token
func (*RobotCustom) SingleCard ¶
func (rc *RobotCustom) SingleCard(title, url string) RobotOption
SingleCard 整体跳转配置
适用ActionCard类型
示例:
robot.SendActionCard(
"TEST: ActionCard&SingleCard",
"SingleCard content",
robot.SingleCard("阅读全文", "https://github.com/shockerli"),
)
func (*RobotCustom) WithOutgoing ¶
func (rc *RobotCustom) WithOutgoing(og RobotOutgoing) RobotOption
WithOutgoing 通过Outgoing的临时消息接口发送
示例:
og, err := robot.ParseOutgoing(bytes.NewBufferString(callbackBody))
err = robot.SendText("callback", robot.WithOutgoing(og))
type RobotOutgoing ¶
type RobotOutgoing struct {
// 被@人的信息
AtUsers []struct {
DingTalkID string `json:"dingtalkId"` // 加密的人员ID
} `json:"atUsers"`
ChatBotUserID string `json:"chatbotUserId"` // 加密的机器人ID
ConversationID string `json:"conversationId"` // 加密的会话ID
ConversationTitle string `json:"conversationTitle"` // 会话标题(群聊时才有,即群名)
ConversationType string `json:"conversationType"` // 1-单聊、2-群聊
CreateAt int64 `json:"createAt"` // 消息的时间戳,单位ms
IsAdmin bool `json:"isAdmin"` // 是否为管理员发送的消息
IsInAtList bool `json:"isInAtList"` //
MsgID string `json:"msgId"` // 加密的消息ID
MsgType string `json:"msgtype"` // 消息类型: 目前只支持Text
SceneGroupCode string `json:"sceneGroupCode"` // 群组场景类型Code
SenderID string `json:"senderId"` // 加密的发送者ID
SenderNick string `json:"senderNick"` // 发送者昵称
SessionWebhook string `json:"sessionWebhook"` // 临时的发送消息接口
SessionWebhookExpiredTime int64 `json:"sessionWebhookExpiredTime"` // SessionWebhook可用的有效截止时间
Text robotText `json:"text"` // Text类型的消息体
}
RobotOutgoing Outgoing回调消息体
示例:
"msgtype": "text" }
{
"conversationId": "ciddz7nmHDaX/7Niz+Gb5VVrw==",
"sceneGroupCode": "project",
"atUsers": [
{
"dingtalkId": "$:LWCP_v1:$0sIVIuw1HvQQ5gRAtFWzypo0+T1TgPOP"
},
{
"dingtalkId": "$:LWCP_v1:$I3cyfTzrws4nCbY289cXbKCVcdd1wize"
}
],
"chatbotUserId": "$:LWCP_v1:$I3cyfTzrws4nCbY289cXbKCVcdd1wize",
"msgId": "msgaKcioIqERkELm2T8TlE9CA==",
"senderNick": "Jioby",
"isAdmin": false,
"sessionWebhookExpiredTime": 1612178396066,
"createAt": 1612172996026,
"conversationType": "2",
"senderId": "$:LWCP_v1:$deZJcSfMzexC2YK+oLkk1g==",
"conversationTitle": "xxx",
"isInAtList": true,
"sessionWebhook": "https://oapi.dingtalk.com/robot/sendBySession?session=eb18e18e8669b0a3cd7dff1388fe5e6a",
"text": {
"content": " 哈哈哈"
},
"msgtype": "text"
}


