Documentation ¶
Index ¶
- func GenMsgCard(bgColor CardTitleBgColor, cfg CardConfig, c Card, more ...Card) map[string]interface{}
- func TextMentionAll() string
- func TextMentionByOpenID(id string, name ...string) string
- type Bot
- type BotOption
- type Card
- type CardConfig
- type CardConfigOption
- type CardElemImageOption
- func WithCardElementImageCompactWidth(b bool) CardElemImageOption
- func WithCardElementImageCustomWidth(w int) CardElemImageOption
- func WithCardElementImageHover(text string) CardElemImageOption
- func WithCardElementImageMode(mode ImageMode) CardElemImageOption
- func WithCardElementImagePreview(b bool) CardElemImageOption
- func WithCardElementImageTitle(text string, md ...bool) CardElemImageOption
- type CardElement
- func WithCardElementActions(act CardElementAction, actions ...CardElementAction) CardElement
- func WithCardElementFields(f CardElementField, fields ...CardElementField) CardElement
- func WithCardElementHorizontalRule() CardElement
- func WithCardElementImage(imgKey string, opts ...CardElemImageOption) CardElement
- func WithCardElementMarkdown(md string, extra ...CardExtraElement) CardElement
- func WithCardElementNote(elem CardElement, elements ...CardElement) CardElement
- func WithCardElementPlainText(text string, lines ...int) CardElement
- type CardElementAction
- type CardElementActionOption
- type CardElementField
- type CardExtraElement
- type CardTitleBgColor
- type ElementButton
- type ImageMode
- type Language
- type Post
- type PostElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenMsgCard ¶ added in v0.1.1
func GenMsgCard(bgColor CardTitleBgColor, cfg CardConfig, c Card, more ...Card) map[string]interface{}
func TextMentionByOpenID ¶ added in v0.4.0
TextMentionByOpenID @单个用户
如果 Open ID 无效,则取 name 展示
https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#e1cdee9f
Types ¶
type Bot ¶
type BotOption ¶
type BotOption func(*bot)
func WithBodyCodec ¶ added in v0.3.0
func WithBodyCodec(codec xhttpclient.BodyCodec) BotOption
func WithDebugOutput ¶ added in v0.3.0
func WithDebugOutput() BotOption
func WithSecretKey ¶
type Card ¶
type Card func() i18nCard
func WithCard ¶
func WithCard(lang Language, title string, elem CardElement, elements ...CardElement) Card
WithCard 卡片消息, 可指定语言环境
支持元素如下: 普通文本: WithCardElementPlainText MarkDown: WithCardElementMarkdown 可并排字段: WithCardElementFields 按钮: WithCardElementActions 分割线: WithCardElementHorizontalRule 图片: WithCardElementImage 备注: WithCardElementNote
type CardConfig ¶
type CardConfig func() cardConfig
func WithCardConfig ¶
func WithCardConfig(opt CardConfigOption, opts ...CardConfigOption) CardConfig
WithCardConfig 卡片消息的属性配置
- 是否允许卡片消息被转发, 默认值: true WithCardConfigEnableForward
- 是否为共享卡片, 默认值: false WithCardConfigEnableUpdateMulti
- 设置卡片跳转链接 WithCardConfigCardLink
type CardConfigOption ¶
type CardConfigOption func(*cardConfig)
func WithCardConfigCardLink ¶
func WithCardConfigCardLink(url, android, ios, pc string) CardConfigOption
WithCardConfigCardLink 设置卡片的多端跳转链接
func WithCardConfigEnableForward ¶
func WithCardConfigEnableForward(b bool) CardConfigOption
WithCardConfigEnableForward 设置是否允许卡片被转发, 默认允许转发
func WithCardConfigEnableUpdateMulti ¶
func WithCardConfigEnableUpdateMulti(b bool) CardConfigOption
WithCardConfigEnableUpdateMulti 设置是否为共享卡片, 默认不共享
true: 是共享卡片,也即更新卡片的内容对所有收到这张卡片的人员可见。 false: 是独享卡片,仅操作用户可见卡片的更新内容。
type CardElemImageOption ¶
type CardElemImageOption func() (key string, v interface{})
func WithCardElementImageCompactWidth ¶
func WithCardElementImageCompactWidth(b bool) CardElemImageOption
WithCardElementImageCompactWidth 是否展示为紧凑型的图片
默认为 false 若配置为 true,则展示最大宽度为278px的紧凑型图片
func WithCardElementImageCustomWidth ¶
func WithCardElementImageCustomWidth(w int) CardElemImageOption
WithCardElementImageCustomWidth 自定义图片的最大展示宽度
默认展示宽度撑满卡片的通栏图片 可在 278px~580px 范围内指定最大展示宽度 在飞书4.0以上版本生效
func WithCardElementImageHover ¶
func WithCardElementImageHover(text string) CardElemImageOption
WithCardElementImageHover hover 图片时弹出的Tips文案
仅支持普通文本格式
func WithCardElementImageMode ¶
func WithCardElementImageMode(mode ImageMode) CardElemImageOption
WithCardElementImageMode 图片显示模式
默认 居中裁剪模式 ImageModeCropCenter:居中裁剪模式,对长图会限高,并居中裁剪后展示 ImageModeFitHorizontal:平铺模式,宽度撑满卡片完整展示上传的图片。该属性会覆盖custom_width 属性
func WithCardElementImagePreview ¶
func WithCardElementImagePreview(b bool) CardElemImageOption
WithCardElementImagePreview 点击后是否放大图片
缺省为true 在配置 card_link 后可设置为false,使用户点击卡片上的图片也能响应card_link链接跳转
func WithCardElementImageTitle ¶
func WithCardElementImageTitle(text string, md ...bool) CardElemImageOption
WithCardElementImageTitle 图片的标题
默认普通文本格式 `md` 传入 `true`, 可支持 Markdown
type CardElement ¶
type CardElement func(isEmbedded bool) interface{}
func WithCardElementActions ¶
func WithCardElementActions(act CardElementAction, actions ...CardElementAction) CardElement
WithCardElementActions 按钮, 可指定但固定跳转, 或多端跳转
func WithCardElementFields ¶
func WithCardElementFields(f CardElementField, fields ...CardElementField) CardElement
WithCardElementFields 能并排布局的字段元素
支持元素: - WithCardElementPlainText - WithCardElementMarkdown
func WithCardElementHorizontalRule ¶
func WithCardElementHorizontalRule() CardElement
WithCardElementHorizontalRule 分割线
func WithCardElementImage ¶
func WithCardElementImage(imgKey string, opts ...CardElemImageOption) CardElement
func WithCardElementMarkdown ¶
func WithCardElementMarkdown(md string, extra ...CardExtraElement) CardElement
WithCardElementMarkdown MarkDown 语法展示文本内容
语法仅支持部分, 语法详情: https://open.feishu.cn/document/ukTMukTMukTM/uADOwUjLwgDM14CM4ATN
func WithCardElementNote ¶
func WithCardElementNote(elem CardElement, elements ...CardElement) CardElement
WithCardElementNote 卡片的备注信息
支持元素: - WithCardElementPlainText - WithCardElementMarkdown - WithCardElementImage
func WithCardElementPlainText ¶
func WithCardElementPlainText(text string, lines ...int) CardElement
WithCardElementPlainText 普通文本内容
lines: 内容显示行数
type CardElementAction ¶
type CardElementAction func() interface{}
func WithCardElementAction ¶
func WithCardElementAction(elem CardElement, url string, opts ...CardElementActionOption) CardElementAction
type CardElementActionOption ¶
type CardElementActionOption func() (key string, v interface{})
func WithCardElementActionButton ¶
func WithCardElementActionButton(btn ElementButton) CardElementActionOption
func WithCardElementActionMultiURL ¶
func WithCardElementActionMultiURL(url, android, ios, pc string) CardElementActionOption
type CardElementField ¶
type CardElementField func() interface{}
func WithCardElementField ¶
func WithCardElementField(elem CardElement, isShort bool) CardElementField
type CardExtraElement ¶
type CardExtraElement func() (key string, v interface{})
func WithCardExtraElementImage ¶
func WithCardExtraElementImage(imgKey string, opts ...CardElemImageOption) CardExtraElement
type CardTitleBgColor ¶
type CardTitleBgColor string
CardTitleBgColor 标题背景色
最佳实践:https://open.feishu.cn/document/ukTMukTMukTM/ukTNwUjL5UDM14SO1ATN#8239feff - 绿色(Green)代表完成/成功 - 橙色(Orange)代表警告/警示 - 红色(Red)代表错误/异常 - 灰色(Grey)代表失效
const ( BgColorDefault CardTitleBgColor = "" BgColorBlue CardTitleBgColor = "blue" BgColorWathet CardTitleBgColor = "wathet" BgColorTurquoise CardTitleBgColor = "turquoise" BgColorGreen CardTitleBgColor = "green" BgColorYellow CardTitleBgColor = "yellow" BgColorOrange CardTitleBgColor = "orange" BgColorRed CardTitleBgColor = "red" BgColorCarmine CardTitleBgColor = "carmine" BgColorViolet CardTitleBgColor = "violet" BgColorPurple CardTitleBgColor = "purple" BgColorIndigo CardTitleBgColor = "indigo" BgColorGrey CardTitleBgColor = "grey" )
type ElementButton ¶
type ElementButton string
const ( ButtonDefault ElementButton = "default" ButtonPrimary ElementButton = "primary" ButtonDanger ElementButton = "danger" )
type PostElement ¶
type PostElement func() postElement
func WithPostElementImage ¶
func WithPostElementImage(imgKey string) PostElement
WithPostElementImage 富文本消息的图片元素
func WithPostElementLink ¶
func WithPostElementLink(text, href string) PostElement
WithPostElementLink 富文本消息的文字超链接元素
func WithPostElementMentionAll ¶
func WithPostElementMentionAll() PostElement
WithPostElementMentionAll 富文本消息的 @所有人
func WithPostElementMentionByOpenID ¶
func WithPostElementMentionByOpenID(id string, name ...string) PostElement
WithPostElementMentionByOpenID 富文本消息的 @用户
Open ID 必须是有效值,否则仅显示 `@` 符号(实际效果不同于 PushText 时会显示 name)
https://open.feishu.cn/document/ugTN1YjL4UTN24CO1UjN/uUzN1YjL1cTN24SN3UjN?from=mcb#acc98e1b
func WithPostElementText ¶
func WithPostElementText(text string, isUnescape ...bool) PostElement
WithPostElementText 富文本消息的文字元素
isUnescape 表示是不是 unescape 解码,默认为 false ,不用可以不填