bot

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeContent

type CodeContent struct {
	Lang string
	Code string
}

代码类型:

func (*CodeContent) ToString

func (c *CodeContent) ToString(lang string, code string, templateFmt string) (html string)

type ImageContent

type ImageContent struct {
	Base64 string `json:"base64"`
	MD5    string `json:"md5"`
}

图片:

type MarkdownContent

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

markdown:

type MessageMeta

type MessageMeta struct {
	MsgType  string           `json:"msgtype"`
	Text     *TextContent     `json:"text,omitempty"`
	Markdown *MarkdownContent `json:"markdown,omitempty"`
	Image    *ImageContent    `json:"image,omitempty"`
	News     *NewsContent     `json:"news,omitempty"`
}

消息:

func (*MessageMeta) FromMarkdown

func (m *MessageMeta) FromMarkdown(content string)

FromMarkdown markdown类型

func (*MessageMeta) FromText

func (m *MessageMeta) FromText(content string, atMobileList []string, atNameList []string)

FromText 文本类型

func (*MessageMeta) ToBytes

func (m *MessageMeta) ToBytes() (payload []byte)

type NewsContent

type NewsContent struct {
	Articles []struct {
		Title       string `json:"title"`
		Description string `json:"description"`
		URL         string `json:"url"`
		PicURL      string `json:"picurl"`
	} `json:"articles"`
}

新闻:

type TextContent

type TextContent struct {
	Content             string   `json:"content"`
	MentionedList       []string `json:"mentioned_list"`        // at 用户名
	MentionedMobileList []string `json:"mentioned_mobile_list"` // 手机号
}

text 消息内容:

type WeChatBot

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

func NewWeChatBot

func NewWeChatBot(conf *WeChatBotConfig) (bot *WeChatBot)

func (*WeChatBot) Alarm

func (b *WeChatBot) Alarm(conf *WebChatBotConfigItem, atMe bool, format string, args ...interface{}) (err error)

func (*WeChatBot) Debug

func (b *WeChatBot) Debug(atMe bool, format string, args ...interface{}) (err error)

Debug debug 级别: 后续加开关,控制 prod 不报

func (*WeChatBot) Default

func (b *WeChatBot) Default(atMe bool, format string, args ...interface{}) (err error)

func (*WeChatBot) Error

func (b *WeChatBot) Error(atMe bool, format string, args ...interface{}) (err error)

Error error 级别:

func (*WeChatBot) Info

func (b *WeChatBot) Info(atMe bool, format string, args ...interface{}) (err error)

Info 普通

func (*WeChatBot) Task

func (b *WeChatBot) Task(atMe bool, format string, args ...interface{}) (err error)

Task 任务类:

func (*WeChatBot) Warn

func (b *WeChatBot) Warn(atMe bool, format string, args ...interface{}) (err error)

type WeChatBotConfig

type WeChatBotConfig struct {
	Default *WebChatBotConfigItem
	Debug   *WebChatBotConfigItem
	Info    *WebChatBotConfigItem
	Warn    *WebChatBotConfigItem
	Error   *WebChatBotConfigItem // error bot
	Task    *WebChatBotConfigItem // 定时任务 bot
}

type WebChatBotConfigItem

type WebChatBotConfigItem struct {
	HookAddr     string
	AtNameList   []string // @用户名列表
	AtMobileList []string // @指定用户手机号列表
	Switch       bool     // 启用开关
}

Jump to

Keyboard shortcuts

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