receiver

package
v0.0.0-...-28fc17c Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MText       MsgType = "text"
	MImage      MsgType = "image"
	MMixed      MsgType = "mixed"
	MEvent      MsgType = "event"
	MTCardEvent MsgType = "template_card_event"

	MSingle ChatType = "single"
	MGroup  ChatType = "group"

	PRTText     PassiveReplyType = "text"
	PRTMarkdown PassiveReplyType = "markdown"

	EventAddToChat      EventType = "add_to_chat"
	EventDeleteFromChat EventType = "delete_from_chat"
	EventEnterChat      EventType = "enter_chat"
)
View Source
const (
	ValidateSignatureError int = -40001
	ParseXmlError          int = -40002
	ComputeSignatureError  int = -40003
	IllegalAesKey          int = -40004
	ValidateCorpidError    int = -40005
	EncryptAESError        int = -40006
	DecryptAESError        int = -40007
	IllegalBuffer          int = -40008
	EncodeBase64Error      int = -40009
	DecodeBase64Error      int = -40010
	GenXmlError            int = -40010
	ParseJsonError         int = -40012
	GenJsonError           int = -40013
	IllegalProtocolType    int = -40014
)

Variables

This section is empty.

Functions

func NewCryptError

func NewCryptError(errCode int, errMsg string) error

func RandString

func RandString(n int) string

Types

type AddOrRemoveResp

type AddOrRemoveResp struct {
}

群机器人被添加到或被移除出群聊

type BaseReply

type BaseReply interface {
	Trigger(event *CallEvent) bool

	MsgType() []MsgType

	SupportPassiveReply() bool
	PassiveReply(event *CallEvent) (string, PassiveReplyType)
	Reply(event *CallEvent) error
}

func NewReply

func NewReply(
	msgType []MsgType,
	trigger func(event *CallEvent) bool,
	reply func(event *CallEvent) error,
	passiveReply func(event *CallEvent) (string, PassiveReplyType),
) BaseReply

type CDATA

type CDATA struct {
	Value string `xml:",cdata"`
}

type CallEvent

type CallEvent struct {
	XMLName    xml.Name `xml:"xml"`
	WebhookUrl CDATA    `xml:"WebhookUrl"`
	MsgId      CDATA    `xml:"MsgId"`
	ChatId     CDATA    `xml:"ChatId"`
	ChatType   CDATA    `xml:"ChatType"`
	From       struct {
		UserId CDATA `xml:"UserId"`
	} `xml:"From"`
	MsgType      CDATA `xml:"MsgType"` // text/image/mixed/event
	Text         Text
	Image        Image
	MixedMessage MixedMessage
	Event        struct {
		EventType CDATA `xml:"EventType"`
	} `xml:"Event"`
}

用户群里@机器人或者单聊中向机器人发送文本消息或图文混排消息

func (*CallEvent) ChatID

func (cm *CallEvent) ChatID() string

func (*CallEvent) GetChatType

func (cm *CallEvent) GetChatType() ChatType

func (*CallEvent) GetEventType

func (cm *CallEvent) GetEventType() EventType

func (*CallEvent) GetMsgType

func (cm *CallEvent) GetMsgType() MsgType

func (*CallEvent) ImageURLs

func (cm *CallEvent) ImageURLs() []string

func (*CallEvent) MsgID

func (cm *CallEvent) MsgID() string

func (*CallEvent) Texts

func (cm *CallEvent) Texts() string

func (*CallEvent) UserID

func (cm *CallEvent) UserID() string

type ChatType

type ChatType string

type CryptError

type CryptError struct {
	ErrCode int
	ErrMsg  string
}

func (*CryptError) Error

func (ce *CryptError) Error() string

type EnterPrivateChatResp

type EnterPrivateChatResp struct {
}

用户进入机器人单聊界面

type EventType

type EventType string

type Image

type Image struct {
	ImageUrl CDATA
}

type MentionedList

type MentionedList struct {
	Item []CDATA `xml:"Item"`
}

type MixedMessage

type MixedMessage struct {
	MsgItem []MsgItem `xml:"MsgItem"`
}

type MsgItem

type MsgItem struct {
	MsgType CDATA
	Text    Text
	Image   Image
}

type MsgType

type MsgType string

type PRMarkdown

type PRMarkdown struct {
	Content CDATA
}

type PRText

type PRText struct {
	Content       CDATA
	MentionedList MentionedList
}

type PassiveReplyResp

type PassiveReplyResp struct {
	XMLName  xml.Name `xml:"xml"`
	MsgType  string
	Text     PRText
	Markdown PRMarkdown
}

type PassiveReplyType

type PassiveReplyType string

type PrivateChatPicResp

type PrivateChatPicResp struct {
}

用户在单聊界面中给机器人发送图片消息

type ProtocolProcessor

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

type ProtocolType

type ProtocolType int
const (
	XmlType ProtocolType = 1
)

type Receiver

type Receiver interface {
	Verify(msgSign, timestamp, nonce, echoStr string) ([]byte, error)
	DecryptMsg(msgSign, timestamp, nonce string, data []byte) ([]byte, error)
	Register(reply BaseReply)
	Reply(event *CallEvent) ([]byte, error)

	SetGroupEvent(e EventType, f func(event *CallEvent) error)
	SetSingleEvent(f func(event *CallEvent) (string, PassiveReplyType))
}

func NewReceiver

func NewReceiver(ctx context.Context, token, encodingAESKey string) Receiver

type TemplateCarReactResp

type TemplateCarReactResp struct {
}

用户点击模版卡片中的交互控件

type Text

type Text struct {
	Content CDATA
}

type WXBizMsg4Recv

type WXBizMsg4Recv struct {
	Tousername string `xml:"ToUserName"`
	Encrypt    string `xml:"Encrypt"`
	Agentid    string `xml:"AgentID"`
}

type WXBizMsg4Send

type WXBizMsg4Send struct {
	XMLName   xml.Name `xml:"xml"`
	Encrypt   CDATA    `xml:"Encrypt"`
	Signature CDATA    `xml:"MsgSignature"`
	Timestamp string   `xml:"TimeStamp"`
	Nonce     CDATA    `xml:"Nonce"`
}

func NewWXBizMsg4Send

func NewWXBizMsg4Send(encrypt, signature, timestamp, nonce string) *WXBizMsg4Send

type WXBizMsgCrypt

type WXBizMsgCrypt struct {
	// contains filtered or unexported fields
}

func NewWXBizMsgCrypt

func NewWXBizMsgCrypt(token, encodingAeskey, receiverId string, protocolType ProtocolType) *WXBizMsgCrypt

func (*WXBizMsgCrypt) DecryptMsg

func (mc *WXBizMsgCrypt) DecryptMsg(msgSignature, timestamp, nonce string, postData []byte) ([]byte, error)

func (*WXBizMsgCrypt) EncryptMsg

func (mc *WXBizMsgCrypt) EncryptMsg(replyMsg, timestamp, nonce string) ([]byte, error)

func (*WXBizMsgCrypt) ParsePlainText

func (mc *WXBizMsgCrypt) ParsePlainText(plaintext []byte) ([]byte, uint32, []byte, []byte, error)

func (*WXBizMsgCrypt) VerifyURL

func (mc *WXBizMsgCrypt) VerifyURL(msgSignature, timestamp, nonce, echostr string) ([]byte, error)

type XmlProcessor

type XmlProcessor struct {
}

Jump to

Keyboard shortcuts

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