qywechat

package
v0.0.0-...-dfd69a5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReceiversPartialInvalid = "partial receivers invalid"
	ReceiversAllInvalid     = "all receivers invalid"
	Name                    = "qywechat"
)

内置变量

Variables

This section is empty.

Functions

func New

func New(setting map[string]string) (sender.Sender, error)

New 创建一个微信消息发送器

Types

type Message

type Message struct {
	ToUser  string `json:"touser"`
	MsgType string `json:"msgtype"`
	AgentID int    `json:"agentid"`
	Text    struct {
		Content string `json:"content"`
	} `json:"text,omitempty"`
	TextCard struct {
		Title       string `json:"title"`
		Description string `json:"description"`
		URL         string `json:"url"`
		BtnTxt      string `json:"btntxt"`
	} `json:"textcard,omitempty"`
}

Message entity post to wechat api

type Sender

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

Sender can send message to wechat

func (*Sender) CheckSignature

func (sender *Sender) CheckSignature(timestamp, nonce, msgEnctypt, signature string) bool

CheckSignature check if the message is safe

func (*Sender) DecryptMessage

func (sender *Sender) DecryptMessage(msgEncrypt string) ([]byte, error)

DecryptMessage decrypt the message

func (*Sender) Send

func (sender *Sender) Send(title, msg string, from string, receivers []string) (int, error)

Send 是对 Sender 的实现

func (*Sender) SendGroupChat

func (sender *Sender) SendGroupChat(chatid, data string) error

SendGroupChat sends msg to group chat

type Token

type Token struct {
	Token  string `json:"access_token"`
	Expire int    `json:"expires_in"`
	// contains filtered or unexported fields
}

Token is the access token used to send message to wechat

type WeMessage

type WeMessage struct {
	ToUser     string `xml:"ToUserName"`
	FromUser   string `xml:"FromUserName"`
	CreateTime int    `xml:"CreateTime"`
	MsgType    string `xml:"MsgType"`
	Content    string `xml:"Content"`
	MsgID      string `xml:"MsgId"`
	AgentID    int
}

WeMessage represent the message from the wechat reply

Jump to

Keyboard shortcuts

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