wechat

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: GPL-3.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ValidateSignatureError int = -40001
	ParseJsonError         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
	GenJsonError           int = -40011
	IllegalProtocolType    int = -40012
)

Variables

This section is empty.

Functions

func IsAccessTokenError

func IsAccessTokenError(res []byte) error

func Send

func Send(messages string, articles []Article, ctx context.Context) error

Types

type Article

type Article struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	Picurl      string `json:"picurl"`
	Appid       string `json:"appid"`
	Pagepath    string `json:"pagepath"`
}

type CryptError

type CryptError struct {
	ErrCode int
	ErrMsg  string
}

func NewCryptError

func NewCryptError(err_code int, err_msg string) *CryptError

type JsonProcessor

type JsonProcessor struct {
}

type Message

type Message struct {
	Touser  string `json:"touser"`
	Toparty string `json:"toparty,omitempty"`
	Totag   string `json:"totag,omitempty"`
	Msgtype string `json:"msgtype"`
	Agentid string `json:"agentid"`
	News    News   `json:"news,omitempty"`
	Text    struct {
		Content string `json:"content"`
	} `json:"text,omitempty"`
}

type Messager

type Messager interface {
	Send(string, []Article, context.Context) error
}

func GetMessager

func GetMessager() Messager

func NewMessager

func NewMessager(conf *config.BotConfig) Messager

type News

type News struct {
	Articles []Article `json:"articles"`
}

type ProtocolProcessor

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

ProtocolProcessor 协议处理器, 目前只有Json 处理

type ProtocolType

type ProtocolType int
const (
	JsonType ProtocolType = 1
)

type Token

type Token struct {
	Errcode     int    `json:"errcode"`
	Errmsg      string `json:"errmsg"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	// contains filtered or unexported fields
}

type WXBizJsonMsg4Recv

type WXBizJsonMsg4Recv struct {
	Tousername string `json:"tousername"`
	Encrypt    string `json:"encrypt"`
	Agentid    string `json:"agentid"`
}

type WXBizJsonMsg4Send

type WXBizJsonMsg4Send struct {
	Encrypt   string `json:"encrypt"`
	Signature string `json:"msgsignature"`
	Timestamp string `json:"timestamp"`
	Nonce     string `json:"nonce"`
}

func NewWXBizJsonMsg4Send

func NewWXBizJsonMsg4Send(encrypt, signature, timestamp, nonce string) *WXBizJsonMsg4Send

type WXBizMsgCrypt

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

WXBizMsgCrypt 一个加密工具

func NewWXBizMsgCrypt

func NewWXBizMsgCrypt(token, encoding_aeskey, receiver_id string, protocol_type ProtocolType) *WXBizMsgCrypt

NewWXBizMsgCrypt 初始化一个加密工具

func (*WXBizMsgCrypt) DecryptMsg

func (self *WXBizMsgCrypt) DecryptMsg(msg_signature, timestamp, nonce string, post_data []byte) ([]byte, *CryptError)

func (*WXBizMsgCrypt) EncryptMsg

func (self *WXBizMsgCrypt) EncryptMsg(reply_msg, timestamp, nonce string) ([]byte, *CryptError)

func (*WXBizMsgCrypt) ParsePlainText

func (self *WXBizMsgCrypt) ParsePlainText(plaintext []byte) ([]byte, uint32, []byte, []byte, *CryptError)

func (*WXBizMsgCrypt) VerifyURL

func (self *WXBizMsgCrypt) VerifyURL(msg_signature, timestamp, nonce, echostr string) ([]byte, *CryptError)

VerifyURL 验证请求

Jump to

Keyboard shortcuts

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