feishu

package
v0.0.0-...-c01aa29 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ElementType_Content = "content"
	ElementType_Hr      = "hr"
	ElementType_Image   = "image"
	ElementType_Action  = "action"
	ElementType_Note    = "note"
)
View Source
const (
	CardMessage = "interactive"
)
View Source
const (
	URL_PREFIX = "https://open.feishu.cn/open-apis/bot"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Config   *CardConfig   `json:"config"`
	Header   *CardHeader   `json:"header"`
	Elements []interface{} `json:"elements"`
}

card说明: https://open.feishu.cn/document/ukTMukTMukTM/ugTNwUjL4UDM14CO1ATN card可视化工具: https://open.feishu.cn/tool/cardbuilder?from=custom_bot_doc

type CardConfig

type CardConfig struct {
	WideScreenMode bool `json:"wide_screen_mode"`
	EnableForward  bool `json:"enable_forward"`
}

card config说明: https://open.feishu.cn/document/ukTMukTMukTM/uAjNwUjLwYDM14CM2ATN

type CardHeader

type CardHeader struct {
	Title    map[string]string `json:"title"`
	Template string            `json:"template"`
}

card header说明: https://open.feishu.cn/document/ukTMukTMukTM/ukTNwUjL5UDM14SO1ATN

type Color

type Color string
const (
	COLOR_BLUE      Color = "blue"
	COLOR_WATHET    Color = "wathet"
	COLOR_TURQUOISE Color = "turquoise"
	COLOR_GREEN     Color = "green"
	COLOR_YELLOW    Color = "yellow"
	COLOR_ORANGE    Color = "orange"
	COLOR_RED       Color = "red"
	COLOR_CARMINE   Color = "carmine"
	COLOR_VIOLET    Color = "violet"
	COLOR_PURPLE    Color = "purple"
	COLOR_INDIGO    Color = "indigo"
	COLOR_GREY      Color = "grey"
)

func (Color) String

func (c Color) String() string

type ContentElement

type ContentElement struct {
	Tag    string   `json:"tag"`
	Text   *Text    `json:"text"`
	Fields []*Field `json:"fields"`
}

car element说明: https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN

func NewFiledMarkdownContent

func NewFiledMarkdownContent(fileds []*NotifyFiled) *ContentElement

func NewMarkdownContent

func NewMarkdownContent(content string) *ContentElement

type ElementType

type ElementType string

type Field

type Field struct {
	IsShort bool `json:"is_short"`
	Text    Text `json:"text"`
}

说明文档 https://open.feishu.cn/document/ukTMukTMukTM/uYzNwUjL2cDM14iN3ATN

func NewField

func NewField(isShort bool, content string) *Field

type FiledGroup

type FiledGroup struct {
	EndType FiledGroupEndType
	Items   []*NotifyFiled
}

func NewEndHrGroup

func NewEndHrGroup(fileds []*NotifyFiled) *FiledGroup

func NewEndNoneGroup

func NewEndNoneGroup() *FiledGroup

func (*FiledGroup) Add

func (g *FiledGroup) Add(f *NotifyFiled)

type FiledGroupEndType

type FiledGroupEndType string
const (
	FiledGroupEndType_None FiledGroupEndType = "none"
	FiledGroupEndType_Hr   FiledGroupEndType = "hr"
	FiledGroupEndType_Line FiledGroupEndType = "line"
)

type HrElement

type HrElement struct {
	Tag string `json:"tag"`
}

func NewHrElement

func NewHrElement() *HrElement

type Message

type Message struct {
	MsgType MessageType `json:"msg_type"`
	Card    Card        `json:"card"`
}

https://www.feishu.cn/hc/zh-CN/articles/360024984973 默认使用飞书的card数据模式

func NewCardMessage

func NewCardMessage(m *NotifyMessage) *Message

如何寻找emoji字符: https://emojipedia.org/light-bulb/

type MessageType

type MessageType string

type NoteElement

type NoteElement struct {
	Tag      string  `json:"tag"`
	Elements []*Text `json:"elements"`
}

https://open.feishu.cn/document/ukTMukTMukTM/ucjNwUjL3YDM14yN2ATN

func NewNoteContent

func NewNoteContent(fileds []string) *NoteElement

type NotifyFiled

type NotifyFiled struct {
	IsShort bool
	Key     string
	Value   string
}

func NewNotifyFiled

func NewNotifyFiled(key, value string, short bool) *NotifyFiled

func (*NotifyFiled) FiledFormat

func (f *NotifyFiled) FiledFormat() string

type NotifyMessage

type NotifyMessage struct {
	Title      string
	Content    string
	RobotURL   string
	FiledGroup []*FiledGroup
	Note       []string
	Color      Color
}

func NewFiledMarkdownMessage

func NewFiledMarkdownMessage(robotURL, title string, color Color, groups ...*FiledGroup) *NotifyMessage

func NewMarkdownNotifyMessage

func NewMarkdownNotifyMessage(robotURL, title, content string) *NotifyMessage

func (*NotifyMessage) AddFiledGroup

func (m *NotifyMessage) AddFiledGroup(group *FiledGroup)

func (*NotifyMessage) AddNote

func (m *NotifyMessage) AddNote(n string)

func (*NotifyMessage) HasFiledGroup

func (m *NotifyMessage) HasFiledGroup() bool

func (*NotifyMessage) HasNote

func (m *NotifyMessage) HasNote() bool

type Text

type Text struct {
	Tag     string `json:"tag"`
	Content string `json:"content"`
	Lines   int    `json:"lines"`
}

说明文档: https://open.feishu.cn/document/ukTMukTMukTM/uUzNwUjL1cDM14SN3ATN

Jump to

Keyboard shortcuts

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