message

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseReq

type BaseReq struct {
	// 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all, 则向关注该企业应用的全部成员发送
	Touser string `json:"touser"`

	// 指定接收消息的部门,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
	Toparty string `json:"toparty"`

	// 指定接收消息的标签,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
	Totag string `json:"totag"`

	// 消息类型
	Msgtype string `json:"msgtype"`

	// 企业应用的id,整型。
	Agentid int `json:"agentid"`

	// 表示是否开启重复消息检查,0表示否,1表示是,默认0
	EnableDuplicateCheck int `json:"enable_duplicate_check"`

	// 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
	DuplicateCheckInterval int `json:"duplicate_check_interval"`
}

type ImageReq

type ImageReq struct {
}

type Message

type Message[T Req] struct{}

Message 定义消息范型, 统一发送消息入口, 为了类型安全, 需要实现Req接口

func (*Message[T]) Send

func (m *Message[T]) Send(body T, token string) (Resp, error)

Send 发送消息

type Req

type Req interface {
	// contains filtered or unexported methods
}

type Resp

type Resp struct {
	Errcode        int    `json:"errcode"`        // 返回码
	Errmsg         string `json:"errmsg"`         // 对返回码的文本描述内容
	Invaliduser    string `json:"invaliduser"`    // 不合法的userid,不区分大小写,统一转为小写
	Invalidparty   string `json:"invalidparty"`   // 不合法的partyid
	Invalidtag     string `json:"invalidtag"`     // 不合法的标签id
	Unlicenseduser string `json:"unlicenseduser"` // 没有基础接口许可(包含已过期)的userid
	Msgid          string `json:"msgid"`          // 消息id,用于撤回应用消息

	// 仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,72小时内有效,且只能使用一次
	ResponseCode string `json:"response_code"`
}

type Text

type Text struct {
	Content string `json:"content"`
}

type TextReq

type TextReq struct {
	BaseReq

	Text Text `json:"text"`

	Safe          int `json:"safe"`
	EnableIdTrans int `json:"enable_id_trans"`
}

func NewTextReq

func NewTextReq(toUser, toParty, toTag, content string, agentId int) TextReq

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL