Documentation ¶
Index ¶
- Variables
- func Bold(s string) string
- func HorizontalRule() string
- func Image(hoverText, imageKey string) string
- func Italics(s string) string
- func Link(url string) string
- func MentionByOpenID(id string) string
- func StrMentionAll() string
- func StrMentionByOpenID(id string, name ...string) string
- func Strikethrough(s string) string
- func TextLink(text, url string) string
- type App
- type AppAccessTokenInternal
- type AppOption
- 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 EventHandler
- type EventHandlerV1
- type EventHeaderV1
- type EventHeaderV2
- type EventMention
- type EventMessage
- type EventMessageReceived
- type EventSender
- type EventSenderID
- type EventType
- type EventUserID
- type GetAllGroupChatsOption
- func WithGetAllGroupChatsNextPage(lastResp GroupChatsResponse) GetAllGroupChatsOption
- func WithGetAllGroupChatsOwnerIDType(idType IDType) GetAllGroupChatsOption
- func WithGetAllGroupChatsPageSize(pageSize int) GetAllGroupChatsOption
- func WithGetAllGroupChatsPageToken(pageToken string) GetAllGroupChatsOption
- type GroupChat
- type GroupChatsResponse
- type IDType
- type ImageMode
- type Language
- type Logger
- type Mention
- type Message
- func NewMessageAudio(fileKey string) *Message
- func NewMessageCard(bgColor CardTitleBgColor, cfg CardConfig, c Card, more ...Card) *Message
- func NewMessageFile(fileKey string) *Message
- func NewMessageImage(imageKey string) *Message
- func NewMessageMedia(fileKey, imageKey string) *Message
- func NewMessagePost(p Post, more ...Post) *Message
- func NewMessageShareChat(chatID string) *Message
- func NewMessageShareUser(openID string) *Message
- func NewMessageSticker(fileKey string) *Message
- func NewMessageText(content string) *Message
- type MessageBody
- type MessageDetail
- type MessageReceiver
- type Post
- type PostElement
- type Sender
- type TenantAccessTokenInternal
- type UploadImageOption
Constants ¶
This section is empty.
Variables ¶
var DefaultHTTPClient = &http.Client{}
Functions ¶
func HorizontalRule ¶
func HorizontalRule() string
func MentionByOpenID ¶
func Strikethrough ¶
Types ¶
type App ¶
type App interface { GetAppAccessTokenInternal() (AppAccessTokenInternal, error) GetAppAccessTokenInternalWithContext(ctx context.Context) (AppAccessTokenInternal, error) GetTenantAccessTokenInternal() (TenantAccessTokenInternal, error) GetTenantAccessTokenInternalWithContext(ctx context.Context) (TenantAccessTokenInternal, error) SendMessage(receiver MessageReceiver, msg *Message) (MessageDetail, error) SendMessageWithContext(ctx context.Context, receiver MessageReceiver, msg *Message) (MessageDetail, error) ReplyMessage(messageID string, msg *Message) (MessageDetail, error) ReplyMessageWithContext(ctx context.Context, messageID string, msg *Message) (MessageDetail, error) UploadImage(src UploadImageOption) (imageKey string, err error) UploadImageWithContext(ctx context.Context, src UploadImageOption) (imageKey string, err error) GetAllGroupChats(opts ...GetAllGroupChatsOption) (GroupChatsResponse, error) GetAllGroupChatsWithContext(ctx context.Context, opts ...GetAllGroupChatsOption) (GroupChatsResponse, error) ListenEventCallback(w http.ResponseWriter, r *http.Request) RegisterEventCallback(eventType EventType, handler EventHandler) RegisterEventCallbackV1(eventType EventType, handler EventHandlerV1) }
func NewCustomApp ¶
type AppAccessTokenInternal ¶
type AppOption ¶
type AppOption func(*app)
func WithAppDebug ¶
func WithAppDebugLogger ¶
func WithAppEventEncryptKey ¶
func WithAppOpenBaseURL ¶
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 EventHandler ¶
type EventHandler func(header EventHeaderV2, event json.RawMessage)
type EventHandlerV1 ¶
type EventHandlerV1 func(header EventHeaderV1, event json.RawMessage)
type EventHeaderV1 ¶
type EventHeaderV2 ¶
type EventHeaderV2 struct { EventID string `json:"event_id,omitempty"` // 事件 ID EventType EventType `json:"event_type,omitempty"` // 事件类型 CreateTime string `json:"create_time,omitempty"` // 事件创建时间戳(单位:毫秒) Token string `json:"token,omitempty"` // 事件 Token AppID string `json:"app_id,omitempty"` // 应用 ID TenantKey string `json:"tenant_key,omitempty"` // 租户 Key }
type EventMention ¶
type EventMention struct { Key string `json:"key"` // mention key ID EventUserID `json:"id"` // 用户 ID Name string `json:"name"` // 用户姓名 TenantKey string `json:"tenant_key"` // tenant key }
type EventMessage ¶
type EventMessage struct { MessageID string `json:"message_id"` // 消息的 open_message_id RootID string `json:"root_id"` // 回复消息 根 id ParentID string `json:"parent_id"` // 回复消息 父 id CreateTime string `json:"create_time"` // 消息发送时间 毫秒 ChatID string `json:"chat_id"` // 消息所在的群组 id ChatType string `json:"chat_type"` // 消息所在的群组类型,单聊(p2p)或群聊(group) MessageType string `json:"message_type"` // 消息类型 Content string `json:"content"` // 消息内容, json 格式各类型消息Content Mentions []EventMention `json:"mentions"` // 被提及用户的信息 }
type EventMessageReceived ¶
type EventMessageReceived struct { Sender EventSender `json:"sender"` // 事件的发送者 Message EventMessage `json:"message"` // 事件中包含的消息内容 }
type EventSender ¶
type EventSender struct { SenderID EventSenderID `json:"sender_id"` // 用户 ID SenderType string `json:"sender_type"` // 消息发送者类型。目前只支持用户(user)发送的消息。 TenantKey string `json:"tenant_key"` // tenant key }
type EventSenderID ¶
type EventUserID ¶
type GetAllGroupChatsOption ¶
type GetAllGroupChatsOption = doOption
func WithGetAllGroupChatsNextPage ¶
func WithGetAllGroupChatsNextPage(lastResp GroupChatsResponse) GetAllGroupChatsOption
func WithGetAllGroupChatsOwnerIDType ¶
func WithGetAllGroupChatsOwnerIDType(idType IDType) GetAllGroupChatsOption
WithGetAllGroupChatsOwnerIDType 控制 GroupChat.OwnerIDType, GroupChat.OwnerID 的值
仅支持 OpenID, UnionID, UserID
func WithGetAllGroupChatsPageSize ¶
func WithGetAllGroupChatsPageSize(pageSize int) GetAllGroupChatsOption
func WithGetAllGroupChatsPageToken ¶
func WithGetAllGroupChatsPageToken(pageToken string) GetAllGroupChatsOption
type GroupChat ¶
type GroupChat struct { ChatID string `json:"chat_id"` // 群组 ID Avatar string `json:"avatar"` // 群头像 URL Name string `json:"name"` // 群名称 Description string `json:"description"` // 群描述 OwnerID string `json:"owner_id"` // 群主 ID (查询参数 user_id_type 将影响该值的类型) OwnerIDType string `json:"owner_id_type"` // 群主 ID 类型 External bool `json:"external"` // 是否是外部群 TenantKey string `json:"tenant_key"` // tenant key }
type GroupChatsResponse ¶
type Mention ¶
type Mention struct { Key string `json:"key"` // 被@的用户或机器人的序号。例如,第3个被@到的成员,值为“@_user_3” ID string `json:"id"` // 被@的用户或者机器人的open_id IDType string `json:"id_type"` // 被@的用户或机器人 id 类型,目前仅支持 open_id Name string `json:"name"` // 被@的用户或机器人的姓名 TenantKey string `json:"tenant_key"` // 为租户在飞书上的唯一标识,用来换取对应的tenant_access_token,也可以用作租户在应用里面的唯一标识 }
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewMessageAudio ¶
func NewMessageCard ¶
func NewMessageCard(bgColor CardTitleBgColor, cfg CardConfig, c Card, more ...Card) *Message
func NewMessageFile ¶
func NewMessageImage ¶
func NewMessageMedia ¶
func NewMessagePost ¶
func NewMessageShareChat ¶
func NewMessageShareUser ¶
func NewMessageSticker ¶
func NewMessageText ¶
type MessageBody ¶
type MessageBody struct { // json结构序列化后的字符串。不同msg_type对应不同内容。 // // 消息类型 包括:text、post、image、file、audio、media、sticker、interactive、share_chat、share_user等 Content string `json:"content"` }
type MessageDetail ¶
type MessageDetail struct { MessageID string `json:"message_id"` // 消息id RootID string `json:"root_id"` // 根消息id ParentID string `json:"parent_id"` // 父消息的id MsgType string `json:"msg_type"` // 消息类型 包括:text、post、image、file、audio、media、sticker、interactive、share_chat、share_user等 CreateTime string `json:"create_time"` // 消息生成的时间戳(毫秒) UpdateTime string `json:"update_time"` // 消息更新的时间戳(毫秒) Deleted bool `json:"deleted"` // 消息是否被撤回 Updated bool `json:"updated"` // 消息是否被更新 ChatID string `json:"chat_id"` // 所属的群 Sender Sender `json:"sender"` // 发送者,可以是用户或应用 Body MessageBody `json:"body"` // 消息内容 Mentions []Mention `json:"mentions"` // 被@的用户或机器人的id列表 UpperMessageID string `json:"upper_message_id"` // 合并转发消息中,上一层级的消息id message_id }
type MessageReceiver ¶
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)
func WithPostElementText ¶
func WithPostElementText(text string, isUnescape ...bool) PostElement
WithPostElementText 富文本消息的文字元素
isUnescape 表示是不是 unescape 解码,默认为 false ,不用可以不填
type UploadImageOption ¶
type UploadImageOption = doOption
func WithUploadImage ¶
func WithUploadImage(filename string) UploadImageOption
func WithUploadImageViaReader ¶
func WithUploadImageViaReader(filename string, src io.Reader) UploadImageOption