qyweixin

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//VERSION is SDK version
	VERSION = "0.1"

	//ROOT is the root url
	ROOT = "https://qyapi.weixin.qq.com/cgi-bin/webhook/"
)
View Source
const (
	MsgTypeTmpl = `{"msgtype":"%s",%s}`
)

Variables

This section is empty.

Functions

func Format

func Format(msg MessageType) string

func MarkdownMessage

func MarkdownMessage(text string) string

func RobotSendMarkDownMessage

func RobotSendMarkDownMessage(key string, content string) error

RobotSendMarkDownMessage can send a text message to a group chat

func RobotSendMessage

func RobotSendMessage(key string, msg MessageType) error

func RobotSendTextMessage

func RobotSendTextMessage(key, content string, mobiles []string, user ...string) error

func RobotUrl

func RobotUrl(key string) (string, error)

func Upload

func Upload()

Types

type CardAction

type CardAction struct {
	Type     int    `json:"type"`
	Url      string `json:"url"`
	Appid    string `json:"appid"`
	Pagepath string `json:"pagepath"`
}

type EmphasisContent

type EmphasisContent struct {
	Title string `json:"title"`
	Desc  string `json:"desc"`
}

type File

type File struct {
	MediaId string `json:"media_id"`
}

func (File) MessageType

func (File) MessageType() MsgType

type HorizontalContentList

type HorizontalContentList struct {
	Keyname string `json:"keyname"`
	Value   string `json:"value"`
	Type    int    `json:"type,omitempty"`
	Url     string `json:"url,omitempty"`
	MediaId string `json:"media_id,omitempty"`
}

type Image

type Image struct {
	Base64 string `json:"base64"`
	Md5    string `json:"md5"`
}

func (Image) MessageType

func (Image) MessageType() MsgType

type Jump

type Jump struct {
	Type     int    `json:"type"`
	Url      string `json:"url,omitempty"`
	Title    string `json:"title"`
	Appid    string `json:"appid,omitempty"`
	Pagepath string `json:"pagepath,omitempty"`
}

type MainTitle

type MainTitle struct {
	Title string `json:"title"`
	Desc  string `json:"desc"`
}

type Markdown

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

func (*Markdown) MessageType

func (*Markdown) MessageType() MsgType

type MessageType

type MessageType interface {
	MessageType() MsgType
}

type MsgType

type MsgType int
const (
	MsgTypeText MsgType
	MsgTypeMarkdown
	MsgTypeImage
	MsgTypeFile
	MsgTypeNews
	MsgTypeVoice
	MsgTypeTemplateCard
)

func (MsgType) String

func (c MsgType) String() string

type News

type News struct {
	Articles []struct {
		Title       string `json:"title"`
		Description string `json:"description"`
		Url         string `json:"url"`
		Picurl      string `json:"picurl"`
	} `json:"articles"`
}

func (*News) MessageType

func (*News) MessageType() MsgType

type QuoteArea

type QuoteArea struct {
	Type      int    `json:"type"`
	Url       string `json:"url"`
	Appid     string `json:"appid"`
	Pagepath  string `json:"pagepath"`
	Title     string `json:"title"`
	QuoteText string `json:"quote_text"`
}

type Robot

type Robot struct {
	Key string
}

func (*Robot) SendMessage

func (r *Robot) SendMessage(msg MessageType) error

type Source

type Source struct {
	IconUrl   string `json:"icon_url"`
	Desc      string `json:"desc"`
	DescColor int    `json:"desc_color"`
}

type TemplateCard

type TemplateCard struct {
	CardType              string                `json:"card_type"`
	Source                Source                `json:"source"`
	MainTitle             MainTitle             `json:"main_title"`
	EmphasisContent       EmphasisContent       `json:"emphasis_content"`
	QuoteArea             QuoteArea             `json:"quote_area"`
	SubTitleText          string                `json:"sub_title_text"`
	HorizontalContentList HorizontalContentList `json:"horizontal_content_list"`
	JumpList              Jump                  `json:"jump_list"`
	CardAction            CardAction            `json:"card_action"`
}

func (*TemplateCard) MessageType

func (*TemplateCard) MessageType() MsgType

type Text

type Text struct {
	Content             string   `json:"content"`
	MentionedList       []string `json:"mentioned_list"`
	MentionedMobileList []string `json:"mentioned_mobile_list"`
}

func (*Text) MessageType

func (*Text) MessageType() MsgType

type UploadRes

type UploadRes struct {
	Errcode   int    `json:"errcode"`
	Errmsg    string `json:"errmsg"`
	Type      string `json:"type"`
	MediaId   string `json:"media_id"`
	CreatedAt string `json:"created_at"`
}

type Voice

type Voice struct {
	MediaId string `json:"media_id"`
}

func (Voice) MessageType

func (Voice) MessageType() MsgType

Jump to

Keyboard shortcuts

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