bot

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

群机器人webhook

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Title  string `json:"title"`                 // 标题,不超过128个字节,超过会自动截断
	Desc   string `json:"description,omitempty"` // 描述,不超过512个字节,超过会自动截断
	Url    string `json:"url"`                   // 点击后跳转的链接
	PicUrl string `json:"picurl,omitempty"`      // 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150
}

type Image

type Image struct {
	Base64 string `json:"base64"` // 图片内容的base64编码
	Md5    string `json:"md5"`    // 图片内容(base64编码前)的md5值
}

消息类型,此时固定为image

type Markdown

type Markdown struct {
	Content string `json:"content"` // markdown内容,最长不超过4096个字节,必须是utf8编码
}

消息类型,此时固定为markdown

type Message

type Message struct {
	Type     MessageType `json:"msgtype"`
	Text     *Text       `json:"text,omitempty"`
	Markdown *Markdown   `json:"markdown,omitempty"`
	Image    *Image      `json:"image,omitempty"`
	News     *News       `json:"news,omitempty"`
}

通用消息结构体

func NewImage

func NewImage(data []byte) *Message

func NewImageFromReader

func NewImageFromReader(r io.Reader) (*Message, error)

func NewImageFromURL

func NewImageFromURL(link string) (*Message, error)

func NewMarkdown

func NewMarkdown(content string) *Message

func NewNews

func NewNews(articles []Article) *Message

func NewText

func NewText(content string, mentionedList []string, mentionedMobileList []string) *Message

func (*Message) Send

func (this *Message) Send(webhook string) error

type MessageType

type MessageType = string
const (
	TEXT     MessageType = "text"
	MARKDOWN MessageType = "markdown"
	IMAGE    MessageType = "image"
	NEWS     MessageType = "news"
)

type News

type News struct {
	Articles []Article `json:"articles"` // 图文消息,一个图文消息支持1到8条图文
}

消息类型,此时固定为news

type Text

type Text struct {
	Content             string   `json:"content"`                        // 文本内容,最长不超过2048个字节,必须是utf8编码
	MentionedList       []string `json:"mentioned_list,omitempty"`       // userid的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userid,可以使用mentioned_mobile_list
	MentionedMobileList []string `json:"metioned_mobile_list,omitempty"` // 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人
}

消息类型,此时固定为text

Jump to

Keyboard shortcuts

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