feishu_bot_api

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 14 Imported by: 0

README

feishu-bot-api

飞书-群机器人-API

安装

go get github.com/electricbubble/feishu-bot-api/v2

使用

bot_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TextAtEveryone

func TextAtEveryone() string

TextAtEveryone @所有人

必须满足所在群开启 @ 所有人功能

func TextAtPerson

func TextAtPerson(id, name string) string

TextAtPerson @指定人

可填入用户的 Open ID 或 User ID,且必须是有效值(仅支持 @ 自定义机器人所在群的群成员),否则取名字展示,并不产生实际的 @ 效果

https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#756b882f https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#272b1dee

Types

type Bot

type Bot interface {
	// SendText 发送文本消息
	//
	// https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#756b882f
	//
	// @指定人: TextAtPerson
	// @所有人: TextAtEveryone
	SendText(content string) error

	// SendRichText 发送富文本消息
	//
	// https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#f62e72d5
	SendRichText(rt *RichTextBuilder, multiLanguage ...*RichTextBuilder) error

	// SendGroupBusinessCard 发送群名片
	//
	// https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#897b5321
	//
	// 群 ID 获取方式: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-id-description
	SendGroupBusinessCard(chatID string) error

	// SendImage 发送图片
	//
	// https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#132a114c
	//
	// image_key 获取方式: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/create
	SendImage(imgKey string) error

	// SendCard 发送消息卡片
	//
	// https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#4996824a
	SendCard(globalConf *CardGlobalConfig, card *CardBuilder, multiLanguage ...*CardBuilder) error

	// SendCardViaTemplate 使用卡片 ID 发送消息
	//
	// https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/send-message-card/send-message-using-card-id
	SendCardViaTemplate(id string, variables any) error

	SendMessage(msg Message) error
}

func NewBot

func NewBot(webhook string, opts *BotOptions) Bot

type BotOptions

type BotOptions struct {
	BaseURL                            string
	LimiterPerSecond, LimiterPerMinute int
	SecretKey                          string

	HookAfterMessageApply func(body *MessageBody) error
}

func NewBotOptions

func NewBotOptions() *BotOptions

func (*BotOptions) SetBaseURL

func (opts *BotOptions) SetBaseURL(s string) *BotOptions

func (*BotOptions) SetHookAfterMessageApply added in v2.1.0

func (opts *BotOptions) SetHookAfterMessageApply(f func(body *MessageBody) error) *BotOptions

func (*BotOptions) SetLimiterPerMinute

func (opts *BotOptions) SetLimiterPerMinute(n int) *BotOptions

func (*BotOptions) SetLimiterPerSecond

func (opts *BotOptions) SetLimiterPerSecond(n int) *BotOptions

func (*BotOptions) SetSecretKey

func (opts *BotOptions) SetSecretKey(s string) *BotOptions

type CardBuilder

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

func NewCard

func NewCard(language Language, title string) *CardBuilder

func (*CardBuilder) Elements

func (cb *CardBuilder) Elements(elements []CardElement) *CardBuilder

Elements 卡片的正文内容

func (*CardBuilder) HeaderSubtitle

func (cb *CardBuilder) HeaderSubtitle(subtitle string) *CardBuilder

HeaderSubtitle 卡片的副标题信息

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-header#3827dadd

func (*CardBuilder) HeaderTextTags

func (cb *CardBuilder) HeaderTextTags(tags []CardHeaderTextTag) *CardBuilder

HeaderTextTags 标题的标签属性

最多可配置 3 个标签内容,如果配置的标签数量超过 3 个,则取前 3 个标签进行展示。 标签展示顺序与数组顺序一致

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-header#3827dadd

type CardElement

type CardElement interface {
	Entity() any
}

func NewCardElementHorizontalRule

func NewCardElementHorizontalRule() CardElement

type CardElementAction

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

CardElementAction 交互模块(action)

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#60ddc64e

func NewCardElementAction

func NewCardElementAction() *CardElementAction

func (*CardElementAction) Actions

func (*CardElementAction) Entity

func (e *CardElementAction) Entity() any

func (*CardElementAction) Layout

Layout 设置窄屏自适应布局方式

  • bisected:二等分布局,每行两列交互元素
  • trisection:三等分布局,每行三列交互元素
  • flow:流式布局,元素会按自身大小横向排列并在空间不够的时候折行

type CardElementActionButton

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

CardElementActionButton

https://open.feishu.cn/document/common-capabilities/message-card/add-card-interaction/interactive-components/button

func NewCardElementActionButton

func NewCardElementActionButton(mode CardElementDivTextMode, content string) *CardElementActionButton

func (*CardElementActionButton) ActionEntity

func (e *CardElementActionButton) ActionEntity() any

func (*CardElementActionButton) MultiURL

func (e *CardElementActionButton) MultiURL(defaultURL, pc, ios, android string) *CardElementActionButton

MultiURL 基于 url 元素配置多端跳转链接,不可与 URL 同时设置

https://open.feishu.cn/document/common-capabilities/message-card/add-card-interaction/interactive-components/button#3827dadd

func (*CardElementActionButton) Type

Type 配置按钮样式

  • default:默认样式
  • primary:强调样式
  • danger:警示样式

https://open.feishu.cn/document/common-capabilities/message-card/add-card-interaction/interactive-components/button#3827dadd

func (*CardElementActionButton) URL

URL 点击按钮后的跳转链接。不可与 MultiURL 同时设置

https://open.feishu.cn/document/common-capabilities/message-card/add-card-interaction/interactive-components/button#3827dadd

type CardElementActionButtonType

type CardElementActionButtonType string
const (
	CardElementActionButtonTypeDefault CardElementActionButtonType = "default"
	CardElementActionButtonTypePrimary CardElementActionButtonType = "primary"
	CardElementActionButtonTypeDanger  CardElementActionButtonType = "danger"
)

type CardElementActionComponent

type CardElementActionComponent interface {
	ActionEntity() any
}

type CardElementActionLayout

type CardElementActionLayout string
const (
	CardElementActionLayoutBisected   CardElementActionLayout = "bisected"
	CardElementActionLayoutTrisection CardElementActionLayout = "trisection"
	CardElementActionLayoutFlow       CardElementActionLayout = "flow"
)

type CardElementActionOverflow

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

CardElementActionOverflow 折叠按钮组(overflow)

https://open.feishu.cn/document/common-capabilities/message-card/add-card-interaction/interactive-components/overflow

func NewCardElementActionOverflow

func NewCardElementActionOverflow() *CardElementActionOverflow

func (*CardElementActionOverflow) ActionEntity

func (e *CardElementActionOverflow) ActionEntity() any

func (*CardElementActionOverflow) AddOptionWithMultiURL

func (e *CardElementActionOverflow) AddOptionWithMultiURL(text, defaultURL, pc, ios, android string) *CardElementActionOverflow

AddOptionWithMultiURL 添加多端跳转链接的选项

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#9fa21514

func (*CardElementActionOverflow) AddOptionWithURL

func (e *CardElementActionOverflow) AddOptionWithURL(text, defaultURL string) *CardElementActionOverflow

AddOptionWithURL 添加跳转链接的选项

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#9fa21514

type CardElementColumnSet

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

CardElementColumnSet 多列布局

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set

func NewCardElementColumnSet

func NewCardElementColumnSet() *CardElementColumnSet

func (*CardElementColumnSet) ActionMultiURL

func (e *CardElementColumnSet) ActionMultiURL(defaultURL, pc, ios, android string) *CardElementColumnSet

ActionMultiURL 设置点击布局容器时的交互配置。当前仅支持跳转交互。如果布局容器内有交互组件,则优先响应交互组件定义的交互

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#3827dadd

func (*CardElementColumnSet) BackgroundStyle

BackgroundStyle 多列布局的背景色样式

  • default:默认的白底样式,dark mode 下为黑底
  • grey:灰底样式

当存在多列布局的嵌套时,上层多列布局的颜色覆盖下层多列布局的颜色

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#3827dadd

func (*CardElementColumnSet) Columns

Columns 多列布局容器内,各个列容器的配置信息

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#3827dadd

func (*CardElementColumnSet) Entity

func (e *CardElementColumnSet) Entity() any

func (*CardElementColumnSet) FlexMode

FlexMode 移动端和 PC 端的窄屏幕下,各列的自适应方式

  • none:不做布局上的自适应,在窄屏幕下按比例压缩列宽度
  • stretch:列布局变为行布局,且每列(行)宽度强制拉伸为 100%,所有列自适应为上下堆叠排布
  • flow:列流式排布(自动换行),当一行展示不下一列时,自动换至下一行展示
  • bisect:两列等分布局
  • trisect:三列等分布局

默认值:none

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#3827dadd

func (*CardElementColumnSet) HorizontalSpacing

HorizontalSpacing 多列布局内,各列之间的水平分栏间距

  • default:默认间距
  • small:窄间距

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#3827dadd

type CardElementColumnSetBackgroundStyle

type CardElementColumnSetBackgroundStyle string
const (
	CardElementColumnSetBackgroundStyleDefault CardElementColumnSetBackgroundStyle = "default"
	CardElementColumnSetBackgroundStyleGrey    CardElementColumnSetBackgroundStyle = "grey"
)

type CardElementColumnSetColumn

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

func NewCardElementColumnSetColumn

func NewCardElementColumnSetColumn() *CardElementColumnSetColumn

func (*CardElementColumnSetColumn) Elements

func (*CardElementColumnSetColumn) VerticalAlign

VerticalAlign 列内成员垂直对齐方式

  • top:顶对齐
  • center:居中对齐
  • bottom:底部对齐

func (*CardElementColumnSetColumn) Weight

Weight 当 width 取值 weighted 时生效,表示当前列的宽度占比。取值范围:1 ~ 5

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#1cf15c63

func (*CardElementColumnSetColumn) Width

Width 列宽度属性

  • auto:列宽度与列内元素宽度一致
  • weighted:列宽度按 weight 参数定义的权重分布

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/column-set#1cf15c63

type CardElementColumnSetColumnVerticalAlign

type CardElementColumnSetColumnVerticalAlign string
const (
	CardElementColumnSetColumnVerticalAlignTop    CardElementColumnSetColumnVerticalAlign = "top"
	CardElementColumnSetColumnVerticalAlignCenter CardElementColumnSetColumnVerticalAlign = "center"
	CardElementColumnSetColumnVerticalAlignBottom CardElementColumnSetColumnVerticalAlign = "bottom"
)

type CardElementColumnSetColumnWidth

type CardElementColumnSetColumnWidth string
const (
	CardElementColumnSetColumnWidthAuto     CardElementColumnSetColumnWidth = "auto"
	CardElementColumnSetColumnWidthWeighted CardElementColumnSetColumnWidth = "weighted"
)

type CardElementColumnSetFlexMode

type CardElementColumnSetFlexMode string
const (
	CardElementColumnSetFlexModeNone    CardElementColumnSetFlexMode = "none"
	CardElementColumnSetFlexModeStretch CardElementColumnSetFlexMode = "stretch"
	CardElementColumnSetFlexModeFlow    CardElementColumnSetFlexMode = "flow"
	CardElementColumnSetFlexModeBisect  CardElementColumnSetFlexMode = "bisect"
	CardElementColumnSetFlexModeTrisect CardElementColumnSetFlexMode = "trisect"
)

type CardElementColumnSetHorizontalSpacing

type CardElementColumnSetHorizontalSpacing string
const (
	CardElementColumnSetHorizontalSpacingDefault CardElementColumnSetHorizontalSpacing = "default"
	CardElementColumnSetHorizontalSpacingSmall   CardElementColumnSetHorizontalSpacing = "small"
)

type CardElementDiv

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

CardElementDiv

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#6bdb3f37

func NewCardElementDiv

func NewCardElementDiv() *CardElementDiv

func (*CardElementDiv) Entity

func (e *CardElementDiv) Entity() any

func (*CardElementDiv) ExtraAction

func (e *CardElementDiv) ExtraAction(component CardElementActionComponent) *CardElementDiv

ExtraAction 在文本右侧附加交互组件

  • NewCardElementActionButton
  • NewCardElementActionOverflow

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#6bdb3f37

func (*CardElementDiv) ExtraImage

func (e *CardElementDiv) ExtraImage(imgKey string, preview bool, altContent string) *CardElementDiv

ExtraImage 在文本右侧附加图片元素

preview: 点击后是否放大图片。在配置 card_link 后可设置为false,使用户点击卡片上的图片也能响应card_link链接跳转 altContent: 图片hover说明

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/embedded-non-interactive-elements/image

func (*CardElementDiv) LarkMarkdown

func (e *CardElementDiv) LarkMarkdown(content string) *CardElementDiv

LarkMarkdown 单个文本内容(支持部分 Markdown 语法的文本内容)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/using-markdown-tags

func (*CardElementDiv) PlainText

func (e *CardElementDiv) PlainText(content string, lines int) *CardElementDiv

PlainText 单个文本内容(普通文本内容)

lines: 内容显示行数

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/embedded-non-interactive-elements/text#3827dadd

type CardElementDivFieldText

type CardElementDivFieldText struct {
	// 是否并排布局
	//  - true:并排
	//  - false:不并排
	//
	// https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/embedded-non-interactive-elements/field#3827dadd
	IsShort bool

	// Mode
	//  - CardElementDivTextModePlainText
	//  - CardElementDivTextModeLarkMarkdown
	//
	// https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/embedded-non-interactive-elements/text#3827dadd
	Mode CardElementDivTextMode

	Content string

	// 内容显示行数
	//
	// 该字段仅支持 plain_text 模式,不支持 lark_md 模式
	//
	// https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/embedded-non-interactive-elements/text#3827dadd
	Lines int
}

type CardElementDivTextMode

type CardElementDivTextMode string
const (
	CardElementDivTextModePlainText    CardElementDivTextMode = "plain_text"
	CardElementDivTextModeLarkMarkdown CardElementDivTextMode = "lark_md"
)

type CardElementHorizontalRule

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

CardElementHorizontalRule 分割线

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/divider-line-module

func (*CardElementHorizontalRule) Entity

func (e *CardElementHorizontalRule) Entity() any

type CardElementImage

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

CardElementImage

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/image-module#3827dadd

func NewCardElementImage

func NewCardElementImage(imgKey, altContent string) *CardElementImage

func (*CardElementImage) CompactWidth

func (e *CardElementImage) CompactWidth(b bool) *CardElementImage

CompactWidth 是否展示为紧凑型的图片

默认值为 false。如果配置为 true,则展示最大宽度为 278px 的紧凑型图片

func (*CardElementImage) CustomWidth

func (e *CardElementImage) CustomWidth(px int) *CardElementImage

CustomWidth 自定义图片的最大展示宽度,支持在 278px ~ 580px 范围内指定最大展示宽度

默认情况下图片宽度与图片组件所占区域的宽度一致

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/image-module#3827dadd

func (*CardElementImage) Entity

func (e *CardElementImage) Entity() any

func (*CardElementImage) Mode

Mode 图片显示模式

  • crop_center:居中裁剪模式,对长图会限高,并居中裁剪后展示
  • fit_horizontal:平铺模式,宽度撑满卡片完整展示上传的图片
  • stretch:自适应。图片宽度撑满卡片宽度,当图片 高:宽 小于 16:9 时,完整展示原图。当图片 高:宽 大于 16:9 时,顶部对齐裁剪图片,并在图片底部展示 长图 脚标
  • large:大图,尺寸为 160 × 160,适用于多图混排
  • medium:中图,尺寸为 80 × 80,适用于图文混排的封面图
  • small:小图,尺寸为 40 × 40,适用于人员头像
  • tiny:超小图,尺寸为 16 × 16,适用于图标、备注

注意:设置该参数后,会覆盖 custom_width 参数。更多信息参见 消息卡片设计规范 https://open.feishu.cn/document/tools-and-resources/design-specification/message-card-design-specifications

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/image-module#3827dadd

func (*CardElementImage) Preview

func (e *CardElementImage) Preview(b bool) *CardElementImage

Preview 点击后是否放大图片

默认值为 true,即点击后放大图片

如果你为卡片配置了 消息卡片跳转链接, 可将该参数设置为 false,后续用户点击卡片上的图片也能响应 card_link 链接跳转

func (*CardElementImage) TitleWithLarkMarkdown

func (e *CardElementImage) TitleWithLarkMarkdown(title string) *CardElementImage

TitleWithLarkMarkdown 图片标题(lark_md)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/image-module#3827dadd

func (*CardElementImage) TitleWithPlainText

func (e *CardElementImage) TitleWithPlainText(title string) *CardElementImage

TitleWithPlainText 图片标题(plain_text)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/image-module#3827dadd

type CardElementImageMode

type CardElementImageMode string
const (
	CardElementImageModeCropCenter    CardElementImageMode = "crop_center"
	CardElementImageModeFitHorizontal CardElementImageMode = "fit_horizontal"
	CardElementImageModeStretch       CardElementImageMode = "stretch"
	CardElementImageModeLarge         CardElementImageMode = "large"
	CardElementImageModeMedium        CardElementImageMode = "medium"
	CardElementImageModeSmall         CardElementImageMode = "small"
	CardElementImageModeTiny          CardElementImageMode = "tiny"
)

type CardElementMarkdown

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

CardElementMarkdown

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/using-markdown-tags

func NewCardElementMarkdown

func NewCardElementMarkdown(content string) *CardElementMarkdown

func (*CardElementMarkdown) Content

func (e *CardElementMarkdown) Content(content string) *CardElementMarkdown

func (*CardElementMarkdown) Entity

func (e *CardElementMarkdown) Entity() any

func (*CardElementMarkdown) Href

func (e *CardElementMarkdown) Href(defaultURL, pc, ios, android string) *CardElementMarkdown

Href 差异化跳转。仅在 PC 端、移动端需要跳转不同链接时使用

[差异化跳转]($urlVal)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/using-markdown-tags#3827dadd

type CardElementMarkdownTextAlign

type CardElementMarkdownTextAlign string
const (
	CardElementMarkdownTextAlignLeft   CardElementMarkdownTextAlign = "left"
	CardElementMarkdownTextAlignCenter CardElementMarkdownTextAlign = "center"
	CardElementMarkdownTextAlignRight  CardElementMarkdownTextAlign = "right"
)

type CardElementNote

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

CardElementNote 备注

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/notes-module

func NewCardElementNote

func NewCardElementNote() *CardElementNote

func (*CardElementNote) AddElementWithImage

func (e *CardElementNote) AddElementWithImage(imgKey string, preview bool, altContent string) *CardElementNote

AddElementWithImage 添加图片

preview: 点击后是否放大图片。在配置 card_link 后可设置为false,使用户点击卡片上的图片也能响应card_link链接跳转 altContent: 图片hover说明

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/notes-module#3827dadd

func (*CardElementNote) AddElementWithLarkMarkdown

func (e *CardElementNote) AddElementWithLarkMarkdown(s string) *CardElementNote

AddElementWithLarkMarkdown 添加文本(lark_md)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/notes-module#3827dadd

func (*CardElementNote) AddElementWithPlainText

func (e *CardElementNote) AddElementWithPlainText(s string) *CardElementNote

AddElementWithPlainText 添加文本(plain_text)

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/notes-module#3827dadd

func (*CardElementNote) Entity

func (e *CardElementNote) Entity() any

type CardGlobalConfig

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

func NewCardGlobalConfig

func NewCardGlobalConfig() *CardGlobalConfig
func (gConf *CardGlobalConfig) CardLink(defaultURL, pc, ios, android string) *CardGlobalConfig

CardLink 消息卡片跳转链接

用于指定卡片整体的点击跳转链接,可以配置默认链接,也可以分别为 PC 端、Android 端、iOS 端配置不同的跳转链接

  • 如果未配置 pc、ios、android,则默认跳转至 defaultURL
  • 如果配置了 pc、ios、android,则优先生效各端指定的跳转链接

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/component-list/common-components-and-elements#7bfe6950

func (*CardGlobalConfig) ConfigEnableForward

func (gConf *CardGlobalConfig) ConfigEnableForward(b bool) *CardGlobalConfig

ConfigEnableForward 是否允许转发卡片

  • true:允许
  • false:不允许

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-structure/card-configuration#3827dadd

func (*CardGlobalConfig) ConfigUpdateMulti

func (gConf *CardGlobalConfig) ConfigUpdateMulti(b bool) *CardGlobalConfig

ConfigUpdateMulti 是否为共享卡片

  • true:是共享卡片,更新卡片的内容对所有收到这张卡片的人员可见
  • false:非共享卡片,即独享卡片,仅操作用户可见卡片的更新内容

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-structure/card-configuration#3827dadd

func (*CardGlobalConfig) HeaderTemplate

func (gConf *CardGlobalConfig) HeaderTemplate(template CardHeaderTemplate) *CardGlobalConfig

HeaderTemplate 标题主题颜色

type CardHeaderTemplate

type CardHeaderTemplate string

CardHeaderTemplate 标题样式

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-header#a19af820

样式建议: https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-header#88aad907

const (
	CardHeaderTemplateBlue      CardHeaderTemplate = "blue"
	CardHeaderTemplateWathet    CardHeaderTemplate = "wathet"
	CardHeaderTemplateTurquoise CardHeaderTemplate = "turquoise"
	CardHeaderTemplateGreen     CardHeaderTemplate = "green"
	CardHeaderTemplateYellow    CardHeaderTemplate = "yellow"
	CardHeaderTemplateOrange    CardHeaderTemplate = "orange"
	CardHeaderTemplateRed       CardHeaderTemplate = "red"
	CardHeaderTemplateCarmine   CardHeaderTemplate = "carmine"
	CardHeaderTemplateViolet    CardHeaderTemplate = "violet"
	CardHeaderTemplatePurple    CardHeaderTemplate = "purple"
	CardHeaderTemplateIndigo    CardHeaderTemplate = "indigo"
	CardHeaderTemplateGrey      CardHeaderTemplate = "grey"
	CardHeaderTemplateDefault   CardHeaderTemplate = "default"
)

type CardHeaderTextTag

type CardHeaderTextTag struct {
	Content string
	Color   CardHeaderTextTagColor
}

type CardHeaderTextTagColor

type CardHeaderTextTagColor string

CardHeaderTextTagColor 标签样式

https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/card-header#616d726a

const (
	CardHeaderTextTagColorNeutral   CardHeaderTextTagColor = "neutral"
	CardHeaderTextTagColorBlue      CardHeaderTextTagColor = "blue"
	CardHeaderTextTagColorTurquoise CardHeaderTextTagColor = "turquoise"
	CardHeaderTextTagColorLime      CardHeaderTextTagColor = "lime"
	CardHeaderTextTagColorOrange    CardHeaderTextTagColor = "orange"
	CardHeaderTextTagColorViolet    CardHeaderTextTagColor = "violet"
	CardHeaderTextTagColorIndigo    CardHeaderTextTagColor = "indigo"
	CardHeaderTextTagColorWathet    CardHeaderTextTagColor = "wathet"
	CardHeaderTextTagColorGreen     CardHeaderTextTagColor = "green"
	CardHeaderTextTagColorYellow    CardHeaderTextTagColor = "yellow"
	CardHeaderTextTagColorRed       CardHeaderTextTagColor = "red"
	CardHeaderTextTagColorPurple    CardHeaderTextTagColor = "purple"
	CardHeaderTextTagColorCarmine   CardHeaderTextTagColor = "carmine"
)

type Language

type Language string
const (
	LanguageChinese  Language = "zh_cn"
	LanguageEnglish  Language = "en_us"
	LanguageJapanese Language = "ja_jp"
)

type Message

type Message interface {
	Apply(body *MessageBody) error
}

type MessageBody

type MessageBody struct {
	MsgType string              `json:"msg_type"`
	Content *MessageBodyContent `json:"content,omitempty"`
	Card    *json.RawMessage    `json:"card,omitempty"`
}

type MessageBodyCard

type MessageBodyCard struct {
	Header       *json.RawMessage `json:"header,omitempty"`
	Elements     *json.RawMessage `json:"elements,omitempty"`
	I18nElements *json.RawMessage `json:"i18n_elements"`
	Config       *json.RawMessage `json:"config,omitempty"`
	CardLink     *json.RawMessage `json:"card_link,omitempty"`
}

type MessageBodyCardTemplate

type MessageBodyCardTemplate struct {
	Type string                      `json:"type"`
	Data MessageBodyCardTemplateData `json:"data"`
}

type MessageBodyCardTemplateData

type MessageBodyCardTemplateData struct {
	TemplateID       string           `json:"template_id"`
	TemplateVariable *json.RawMessage `json:"template_variable,omitempty"`
}

type MessageBodyContent

type MessageBodyContent struct {
	Text        string           `json:"text,omitempty"`
	Post        *json.RawMessage `json:"post,omitempty"`
	ShareChatID string           `json:"share_chat_id,omitempty"`
	ImageKey    string           `json:"image_key,omitempty"`
}

type RichTextBuilder

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

func NewRichText

func NewRichText(language Language, title string) *RichTextBuilder

func (*RichTextBuilder) At

func (rtb *RichTextBuilder) At(id, name string) *RichTextBuilder

At @ 标签

id: 用户的 Open ID 或 User ID

@ 单个用户时,id 字段必须是有效值(仅支持 @ 自定义机器人所在群的群成员)
@ 所有人时,填 all (也可以使用 RichTextBuilder.AtEveryone)

func (*RichTextBuilder) AtEveryone

func (rtb *RichTextBuilder) AtEveryone() *RichTextBuilder
func (rtb *RichTextBuilder) Hyperlink(text, href string) *RichTextBuilder

Hyperlink 超链接标签

func (*RichTextBuilder) Image

func (rtb *RichTextBuilder) Image(imgKey string) *RichTextBuilder

Image 图片标签

图片的唯一标识。可通过 上传图片 接口获取 https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/create

func (*RichTextBuilder) Text

func (rtb *RichTextBuilder) Text(text string, unEscape bool) *RichTextBuilder

Text 文本标签

unEscape 表示是否 unescape 解码,未用到 unescape 时传入 false

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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