lark

package module
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 24 Imported by: 22

README

go-lark

build codecov Go Report Card Go Module Go Reference Mentioned in Awesome Go

简体中文

go-lark is an easy-to-use SDK for Feishu and Lark Open Platform, which implements messaging APIs, with full-fledged supports on building Chat Bot and Notification Bot.

It is widely used and tested by ~650 ByteDance in-house developers with over 3k Go packages.

Features

  • Notification bot & chat bot supported
  • Send messages (Group, Private, Rich Text, and Card)
  • Quick to build message with MsgBuffer
  • Easy to create incoming message hook
  • Encryption and token verification supported
  • Middleware support for Gin & Hertz web framework
  • Highly extensible
  • Documentation & tests

Installation

go get github.com/go-lark/lark

Quick Start

Prerequisite

There are two types of bot that is supported by go-lark. We need to create a bot manually.

Chat Bot:

Notification Bot:

  • Create from group chat.
  • Web Hook URL is required.
Sending Message

Chat Bot:

import "github.com/go-lark/lark"

func main() {
    bot := lark.NewChatBot("<App ID>", "<App Secret>")
    bot.StartHeartbeat()
    bot.PostText("hello, world", lark.WithEmail("someone@example.com"))
}

Notification Bot:

import "github.com/go-lark/lark"

func main() {
    bot := lark.NewNotificationBot("<WEB HOOK URL>")
    bot.PostNotificationV2(lark.NewMsgBuffer(lark.MsgText).Text("hello, wolrd").Build())
}

Feishu/Lark API offers more features, please refers to Usage for further documentation.

Limits

  • go-lark is tested on Feishu endpoints, which literally compats Lark endpoints, because Feishu and Lark basically shares the same API specification. We do not guarantee all of the APIs work well with Lark, until we have tested it on Lark.
  • go-lark only supports Custom App. Marketplace App is not supported yet.
  • go-lark implements messaging, group chat, and bot API, other APIs such as Lark Doc, Calendar and so on are not supported.
Switch to Lark Endpoints

The default API endpoints are for Feishu, in order to switch to Lark, we should use SetDomain:

bot := lark.NewChatBot("<App ID>", "<App Secret>")
bot.SetDomain(lark.DomainLark)

Usage

Auth

Auto-renewable authentication:

// initialize a chat bot with appID and appSecret
bot := lark.NewChatBot(appID, appSecret)
// Renew access token periodically
bot.StartHeartbeat()
// Stop renewal
bot.StopHeartbeat()

Single-pass authentication:

bot := lark.NewChatBot(appID, appSecret)
resp, err := bot.GetTenantAccessTokenInternal(true)
// and we can now access the token value with `bot.TenantAccessToken()`

Example: examples/auth

Messaging

For Chat Bot, we can send simple messages with the following method:

  • PostText
  • PostTextMention
  • PostTextMentionAll
  • PostImage
  • PostShareChatCard
  • ReplyMessage
  • AddReaction
  • DeleteReaction

Basic message examples: examples/basic-message

To build rich messages, we may use Message Buffer (or simply MsgBuffer), which builds message conveniently with chaining methods.

Examples

Apart from the general auth and messaging chapter, there are comprehensive examples for almost all APIs. Here is a collection of ready-to-run examples for each part of go-lark:

Message Buffer

We can build message body with MsgBuffer and send with PostMessage, which supports the following message types:

  • MsgText: Text
  • MsgPost: Rich Text
  • MsgInteractive: Interactive Card
  • MsgShareCard: Group Share Card
  • MsgShareUser: User Share Card
  • MsgImage: Image
  • MsgFile: File
  • MsgAudio: Audio
  • MsgMedia: Media
  • MsgSticker: Sticker

MsgBuffer provides binding functions and content functions.

Binding functions:

Function Usage Comment
BindChatID Bind a chat ID Either OpenID, UserID, Email, ChatID or UnionID should be present
BindOpenID Bind a user open ID
BindUserID Bind a user ID
BindUnionID Bind a union ID
BindEmail Bind a user email
BindReply Bind a reply ID Required when reply a message

Content functions pair with message content types. If it mismatched, it would not have sent successfully. Content functions:

Function Message Type Usage Comment
Text MsgText Append plain text May build with TextBuilder
Post MsgPost Append rich text May build with PostBuilder
Card MsgInteractive Append interactive card May build with CardBuilder
ShareChat MsgShareCard Append group share card
ShareUser MsgShareUser Append user share card
Image MsgImage Append image Required to upload to Lark server in advance
File MsgFile Append file Required to upload to Lark server in advance
Audio MsgAudio Append audio Required to upload to Lark server in advance
Media MsgMedia Append media Required to upload to Lark server in advance
Sticker MsgSticker Append sticker Required to upload to Lark server in advance
Error Handling

Each go-lark API function returns response and err. err is the error from HTTP client, when it was not nil, HTTP might have gone wrong.

While response is HTTP response from Lark API server, in which Code and OK represent whether it succeeds. The meaning of Code is defined here.

Event

Lark provides a number of events and they are in two different schema (1.0/2.0). go-lark now only implements a few of them, which are needed for interacting between bot and Lark server:

  • URL Challenge
  • Receiving Messages

We recommend HTTP middlewares to handle these events.

Middlewares

We have already implemented HTTP middlewares to support event handling:

Example: examples/gin-middleware examples/hertz-middleware

URL Challenge
r := gin.Default()
middleware := larkgin.NewLarkMiddleware()
middleware.BindURLPrefix("/handle") // supposed URL is http://your.domain.com/handle
r.Use(middleware.LarkChallengeHandler())
Event V2

Lark has provided event v2 and it applied automatically to newly created bots.

r := gin.Default()
middleware := larkgin.NewLarkMiddleware()
r.Use(middleware.LarkEventHandler())

Get the event (e.g. Message):

r.POST("/", func(c *gin.Context) {
    if evt, ok := middleware.GetEvent(c); ok { // => GetEvent instead of GetMessage
        if evt.Header.EventType == lark.EventTypeMessageReceived {
            if msg, err := evt.GetMessageReceived(); err == nil {
                fmt.Println(msg.Message.Content)
            }
        }
    }
})
Card Callback

We may also setup callback for card actions (e.g. button). The URL challenge part is the same.

We may use LarkCardHandler to handle the actions:

r.Use(middleware.LarkCardHandler())
r.POST("/callback", func(c *gin.Context) {
    if card, ok := middleware.GetCardCallback(c); ok {
    }
})
Receiving Message (Event V1)

For older bots, please use v1:

r := gin.Default()
middleware := larkgin.NewLarkMiddleware()
middleware.BindURLPrefix("/handle") // supposed URL is http://your.domain.com/handle
r.POST("/handle", func(c *gin.Context) {
    if msg, ok := middleware.GetMessage(c); ok && msg != nil {
        text := msg.Event.Text
        // your awesome logic
    }
})
Security & Encryption

Lark Open Platform offers AES encryption and token verification to ensure security for events.

  • AES Encryption: when switch on, all traffic will be encrypted with AES.
  • Token Verification: simple token verification for incoming messages.

We recommend you to enable token verification. If HTTPS is not available on your host, then enable AES encryption.

middleware.WithTokenVerfication("<verification-token>")
middleware.WithEncryption("<encryption-key>")
Debugging

Lark does not provide messaging API debugger officially. Thus, we have to debug with real Lark conversation. We recommend ngrok to debug events.

And we add PostEvent to simulate message sending to make it even easier. PostEvent can also be used to redirect events, which acts like a reverse proxy.

Development

Test
  1. Dotenv Setup

    go-lark uses godotenv test locally. You may have to create a .env file in repo directory, which contains environmental variables:

    LARK_APP_ID
    LARK_APP_SECRET
    LARK_USER_EMAIL
    LARK_USER_ID
    LARK_UNION_ID
    LARK_OPEN_ID
    LARK_CHAT_ID
    LARK_WEBHOOK_V2
    LARK_WEBHOOK_V2_SIGNED
    

    LARK_APP_ID and LARK_APP_SECRET are mandatory. Others are required only by specific API tests.

  2. Run Test

    GO_LARK_TEST_MODE=local ./scripts/test.sh
    
Extensions

go-lark's dev utilities (authentication, HTTP handling, and etc.) are capable for easily implementing most of APIs provided by Lark Open Platform. And we may use that as an extension for go-lark.

Here is an example that implementing a Lark Doc API with go-lark:

package lark

import "github.com/go-lark/lark"

const copyFileAPIPattern = "/open-apis/drive/explorer/v2/file/copy/files/%s"

// CopyFileResponse .
type CopyFileResponse struct {
	lark.BaseResponse

	Data CopyFileData `json:"data"`
}

// CopyFileData .
type CopyFileData struct {
	FolderToken string `json:"folderToken"`
	Revision    int64  `json:"revision"`
	Token       string `json:"token"`
	Type        string `json:"type"`
	URL         string `json:"url"`
}

// CopyFile implementation
func CopyFile(bot *lark.Bot, fileToken, dstFolderToken, dstName string) (*CopyFileResponse, error) {
	var respData model.CopyFileResponse
	err := bot.PostAPIRequest(
		"CopyFile",
		fmt.Sprintf(copyFileAPIPattern, fileToken),
		true,
		map[string]interface{}{
			"type":             "doc",
			"dstFolderToken":   dstFolderToken,
			"dstName":          dstName,
			"permissionNeeded": true,
			"CommentNeeded":    false,
		},
		&respData,
	)
	return &respData, err
}

FAQ

  • I got 99991401 when sending messages
    • remove IP Whitelist from dashboard
  • My bot failed sending messages
    1. check authentication.
    2. not invite to the group.
    3. API permission not applied.
  • Does go-lark support interactive message card?
    • Yes, use a CardBuilder.

Contributing

  • If you think you've found a bug with go-lark, please file an issue.
  • Pull Request is welcomed.

License

Copyright (c) David Zhang, 2018-2024. Licensed under MIT License.

Documentation

Overview

Package lark is an easy-to-use SDK for Feishu and Lark Open Platform, which implements messaging APIs, with full-fledged supports on building Chat Bot and Notification Bot.

Index

Constants

View Source
const (
	EventTypeMessageReceived        = "im.message.receive_v1"
	EventTypeMessageRead            = "im.message.message_read_v1"
	EventTypeMessageRecalled        = "im.message.recalled_v1"
	EventTypeMessageReactionCreated = "im.message.reaction.created_v1"
	EventTypeMessageReactionDeleted = "im.message.reaction.deleted_v1"
	EventTypeChatDisbanded          = "im.chat.disbanded_v1"
	EventTypeUserAdded              = "im.chat.member.user.added_v1"
	EventTypeUserDeleted            = "im.chat.member.user.deleted_v1"
	EventTypeBotAdded               = "im.chat.member.bot.added_v1"
	EventTypeBotDeleted             = "im.chat.member.bot.deleted_v1"
	// not supported yet
	EventTypeChatUpdated   = "im.chat.updated_v1"
	EventTypeUserWithdrawn = "im.chat.member.user.withdrawn_v1"
)

EventType definitions

View Source
const (
	// ChatBot should be created with NewChatBot
	// Create from https://open.feishu.cn/ or https://open.larksuite.com/
	ChatBot = iota
	// NotificationBot for webhook, behave as a simpler notification bot
	// Create from Lark group
	NotificationBot
)
View Source
const (
	DomainFeishu = "https://open.feishu.cn"
	DomainLark   = "https://open.larksuite.com"
)

Domains

View Source
const (
	LocaleZhCN = "zh_cn"
	LocaleZhHK = "zh_hk"
	LocaleZhTW = "zh_tw"
	LocaleEnUS = "en_us"
	LocaleJaJP = "ja_jp"
)

Supported Lark locales

View Source
const (
	LogLevelTrace = iota + 1
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
)

LogLevels

View Source
const (
	MsgText        = "text"
	MsgPost        = "post"
	MsgInteractive = "interactive"
	MsgImage       = "image"
	MsgShareCard   = "share_chat"
	MsgShareUser   = "share_user"
	MsgAudio       = "audio"
	MsgMedia       = "media"
	MsgFile        = "file"
	MsgSticker     = "sticker"
)

Msg Types

View Source
const (
	UIDEmail   = "email"
	UIDUserID  = "user_id"
	UIDOpenID  = "open_id"
	UIDChatID  = "chat_id"
	UIDUnionID = "union_id"
)

UID types

Variables

View Source
var (
	ErrBotTypeError           = errors.New("Bot type error")
	ErrParamUserID            = errors.New("Param error: UserID")
	ErrParamMessageID         = errors.New("Param error: Message ID")
	ErrParamExceedInputLimit  = errors.New("Param error: Exceed input limit")
	ErrMessageTypeNotSuppored = errors.New("Message type not supported")
	ErrEncryptionNotEnabled   = errors.New("Encryption is not enabled")
	ErrCustomHTTPClientNotSet = errors.New("Custom HTTP client not set")
	ErrMessageNotBuild        = errors.New("Message not build")
	ErrUnsupportedUIDType     = errors.New("Unsupported UID type")
	ErrInvalidReceiveID       = errors.New("Invalid receive ID")
	ErrEventTypeNotMatch      = errors.New("Event type not match")
	ErrMessageType            = errors.New("Message type error")
)

Errors

Functions

func BuildOutcomingMessageReq

func BuildOutcomingMessageReq(om OutcomingMessage) map[string]interface{}

BuildOutcomingMessageReq for msg builder

func Decrypt

func Decrypt(encryptedKey []byte, data string) ([]byte, error)

Decrypt with AES Cipher

func DownloadFile

func DownloadFile(path, url string) error

DownloadFile downloads from a URL to local path

func EncryptKey

func EncryptKey(key string) []byte

EncryptKey .

func GenSign added in v1.7.3

func GenSign(secret string, timestamp int64) (string, error)

GenSign generate sign for notification bot

func PostEvent

func PostEvent(client *http.Client, hookURL string, message EventMessage) (*http.Response, error)

PostEvent posts event 1. help to develop and test ServeEvent callback func much easier 2. otherwise, you may use it to forward event

Types

type AddBotToGroupResponse

type AddBotToGroupResponse = BaseResponse

AddBotToGroupResponse .

type AddChatMemberRequest added in v1.7.0

type AddChatMemberRequest struct {
	IDList []string `json:"id_list"`
}

AddChatMemberRequest .

type AddChatMemberResponse added in v1.7.0

type AddChatMemberResponse struct {
	BaseResponse

	Data struct {
		InvalidIDList    []string `json:"invalid_id_list"`
		NotExistedIDList []string `json:"not_existed_id_list"`
	} `json:"data"`
}

AddChatMemberResponse .

type AddGroupMemberResponse

type AddGroupMemberResponse struct {
	BaseResponse
	InvalidOpenID []string `json:"invalid_open_ids"`
}

AddGroupMemberResponse .

type AudioContent added in v1.7.0

type AudioContent struct {
	FileKey string `json:"file_key"`
}

AudioContent .

type AuthTokenInternalResponse

type AuthTokenInternalResponse struct {
	BaseResponse
	AppAccessToken string `json:"app_access_token"`
	Expire         int    `json:"expire"`
}

AuthTokenInternalResponse .

type BaseResponse added in v1.6.0

type BaseResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

BaseResponse of an API

type BatchGetUserInfoResponse added in v1.13.0

type BatchGetUserInfoResponse struct {
	BaseResponse
	Data struct {
		Items []UserInfo
	}
}

BatchGetUserInfoResponse .

type Bot

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

Bot definition

func NewChatBot

func NewChatBot(appID, appSecret string) *Bot

NewChatBot with appID and appSecret

func NewNotificationBot

func NewNotificationBot(hookURL string) *Bot

NewNotificationBot with URL

func (Bot) AccessToken

func (bot Bot) AccessToken() string

AccessToken returns bot.accessToken for external use

func (*Bot) AddBotToGroup

func (bot *Bot) AddBotToGroup(openChatID string) (*AddBotToGroupResponse, error)

AddBotToGroup .

func (Bot) AddChatMember added in v1.7.0

func (bot Bot) AddChatMember(chatID string, idList []string) (*AddChatMemberResponse, error)

AddChatMember .

func (*Bot) AddGroupMember

func (bot *Bot) AddGroupMember(openChatID string, openID []string) (*AddGroupMemberResponse, error)

AddGroupMember adds a group member

func (*Bot) AddGroupMemberByUserID

func (bot *Bot) AddGroupMemberByUserID(openChatID string, userID []string) (*AddGroupMemberResponse, error)

AddGroupMemberByUserID adds a group member

func (Bot) AddReaction added in v1.12.0

func (bot Bot) AddReaction(messageID string, emojiType EmojiType) (*ReactionResponse, error)

AddReaction adds reaction to a message

func (Bot) AppID

func (bot Bot) AppID() string

AppID returns bot.appID for external use

func (Bot) BatchGetUserInfo added in v1.13.0

func (bot Bot) BatchGetUserInfo(userIDType string, userIDs ...string) (*BatchGetUserInfoResponse, error)

BatchGetUserInfo gets contact info in batch

func (Bot) BotType

func (bot Bot) BotType() int

BotType returns bot.botType for external use

func (Bot) CreateChat added in v1.7.0

func (bot Bot) CreateChat(req CreateChatRequest) (*CreateChatResponse, error)

CreateChat .

func (*Bot) CreateGroup

func (bot *Bot) CreateGroup(name, description string, openID []string) (*CreateGroupResponse, error)

CreateGroup creates a group

func (Bot) DeleteAPIRequest added in v1.7.0

func (bot Bot) DeleteAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error

DeleteAPIRequest call Lark API

func (Bot) DeleteChat added in v1.7.0

func (bot Bot) DeleteChat(chatID string) (*DeleteChatResponse, error)

DeleteChat .

func (Bot) DeleteEphemeralMessage added in v1.6.0

func (bot Bot) DeleteEphemeralMessage(messageID string) (*DeleteEphemeralMessageResponse, error)

DeleteEphemeralMessage deletes an ephemeral message

func (*Bot) DeleteGroupMember

func (bot *Bot) DeleteGroupMember(openChatID string, openID []string) (*DeleteGroupMemberResponse, error)

DeleteGroupMember deletes a group member

func (Bot) DeleteReaction added in v1.12.0

func (bot Bot) DeleteReaction(messageID string, reactionID string) (*ReactionResponse, error)

DeleteReaction deletes reaction of a message

func (Bot) DeleteTopNotice added in v1.8.0

func (bot Bot) DeleteTopNotice(chatID string) (*DeleteChatResponse, error)

DeleteTopNotice .

func (*Bot) DisbandGroup

func (bot *Bot) DisbandGroup(openChatID string) (*DisbandGroupResponse, error)

DisbandGroup .

func (Bot) DoAPIRequest added in v1.2.0

func (bot Bot) DoAPIRequest(
	method string,
	prefix, urlPath string,
	header http.Header, auth bool,
	body io.Reader,
	output interface{},
) error

DoAPIRequest builds http request

func (Bot) Domain added in v1.4.2

func (bot Bot) Domain() string

Domain returns current domain

func (Bot) ExpandURL added in v1.1.0

func (bot Bot) ExpandURL(urlPath string) string

ExpandURL expands url path to full url

func (Bot) ForwardMessage added in v1.12.0

func (bot Bot) ForwardMessage(messageID string, receiveID *OptionalUserID) (*ForwardMessageResponse, error)

ForwardMessage forwards a message

func (Bot) GetAPIRequest added in v1.7.0

func (bot Bot) GetAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error

GetAPIRequest call Lark API

func (*Bot) GetAccessTokenInternal

func (bot *Bot) GetAccessTokenInternal(updateToken bool) (*AuthTokenInternalResponse, error)

GetAccessTokenInternal gets AppAccessToken for internal use

func (*Bot) GetBotInfo

func (bot *Bot) GetBotInfo() (*GetBotInfoResponse, error)

GetBotInfo returns bot info

func (Bot) GetChat added in v1.7.0

func (bot Bot) GetChat(chatID string) (*GetChatResponse, error)

GetChat .

func (Bot) GetChatMembers added in v1.7.0

func (bot Bot) GetChatMembers(chatID string, pageToken string, pageSize int) (*GetChatMembersResponse, error)

GetChatMembers . NOTICE: pageSize must be larger than 10, e.g. if you present pageSize=1, it returns the same pageToken as pageSize=10. So we recommend you just pass pageSize=10.

func (*Bot) GetGroupInfo

func (bot *Bot) GetGroupInfo(openChatID string) (*GroupInfoResponse, error)

GetGroupInfo returns group info

func (*Bot) GetGroupList

func (bot *Bot) GetGroupList(pageNum, pageSize int) (*GroupListResponse, error)

GetGroupList returns group list

func (Bot) GetMessage added in v1.7.0

func (bot Bot) GetMessage(messageID string) (*GetMessageResponse, error)

GetMessage gets a message with im/v1

func (*Bot) GetTenantAccessTokenInternal

func (bot *Bot) GetTenantAccessTokenInternal(updateToken bool) (*TenantAuthTokenInternalResponse, error)

GetTenantAccessTokenInternal gets AppAccessToken for internal use

func (Bot) GetUserInfo

func (bot Bot) GetUserInfo(userID *OptionalUserID) (*GetUserInfoResponse, error)

GetUserInfo gets contact info

func (Bot) IsInChat added in v1.7.0

func (bot Bot) IsInChat(chatID string) (*IsInChatResponse, error)

IsInChat .

func (Bot) JoinChat added in v1.7.0

func (bot Bot) JoinChat(chatID string) (*JoinChatResponse, error)

JoinChat .

func (Bot) ListChat added in v1.10.1

func (bot Bot) ListChat(sortType string, pageToken string, pageSize int) (*ListChatResponse, error)

ListChat list chats sortType: ByCreateTimeAsc/ByActiveTimeDesc

func (Bot) Logger added in v1.1.0

func (bot Bot) Logger() LogWrapper

Logger returns current logger

func (Bot) MessageReadReceipt

func (bot Bot) MessageReadReceipt(messageID string) (*MessageReceiptResponse, error)

MessageReadReceipt queries message read receipt

func (Bot) PatchAPIRequest added in v1.7.0

func (bot Bot) PatchAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error

PatchAPIRequest call Lark API

func (Bot) PinMessage added in v1.8.0

func (bot Bot) PinMessage(messageID string) (*PinMessageResponse, error)

PinMessage pins a message

func (Bot) PostAPIRequest

func (bot Bot) PostAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error

PostAPIRequest call Lark API

func (Bot) PostEphemeralMessage added in v1.6.0

func (bot Bot) PostEphemeralMessage(om OutcomingMessage) (*PostEphemeralMessageResponse, error)

PostEphemeralMessage posts an ephemeral message

func (Bot) PostImage

func (bot Bot) PostImage(imageKey string, userID *OptionalUserID) (*PostMessageResponse, error)

PostImage is a simple way to send image

func (Bot) PostMessage

func (bot Bot) PostMessage(om OutcomingMessage) (*PostMessageResponse, error)

PostMessage posts a message

func (*Bot) PostNotification

func (bot *Bot) PostNotification(title, text string) (*PostNotificationResp, error)

PostNotification send message to a webhook deprecated: legacy version, please use PostNotificationV2 instead

func (*Bot) PostNotificationV2

func (bot *Bot) PostNotificationV2(om OutcomingMessage) (*PostNotificationV2Resp, error)

PostNotificationV2 support v2 format

func (Bot) PostRichText

func (bot Bot) PostRichText(postContent *PostContent, userID *OptionalUserID) (*PostMessageResponse, error)

PostRichText is a simple way to send rich text messages

func (Bot) PostShareChat

func (bot Bot) PostShareChat(chatID string, userID *OptionalUserID) (*PostMessageResponse, error)

PostShareChat is a simple way to share chat

func (Bot) PostShareUser added in v1.7.0

func (bot Bot) PostShareUser(openID string, userID *OptionalUserID) (*PostMessageResponse, error)

PostShareUser is a simple way to share user

func (Bot) PostText

func (bot Bot) PostText(text string, userID *OptionalUserID) (*PostMessageResponse, error)

PostText is a simple way to send text messages

func (Bot) PostTextMention

func (bot Bot) PostTextMention(text string, atUserID string, userID *OptionalUserID) (*PostMessageResponse, error)

PostTextMention is a simple way to send text messages with @user

func (Bot) PostTextMentionAll

func (bot Bot) PostTextMentionAll(text string, userID *OptionalUserID) (*PostMessageResponse, error)

PostTextMentionAll is a simple way to send text messages with @all

func (Bot) PostTextMentionAndReply

func (bot Bot) PostTextMentionAndReply(text string, atUserID string, userID *OptionalUserID, replyID string) (*PostMessageResponse, error)

PostTextMentionAndReply is a simple way to send text messages with @user and reply a message

func (Bot) PutAPIRequest added in v1.7.0

func (bot Bot) PutAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error

PutAPIRequest call Lark API

func (Bot) RecallMessage

func (bot Bot) RecallMessage(messageID string) (*RecallMessageResponse, error)

RecallMessage recalls a message with ID

func (*Bot) RemoveBotFromGroup

func (bot *Bot) RemoveBotFromGroup(openChatID string) (*RemoveBotFromGroupResponse, error)

RemoveBotFromGroup .

func (Bot) RemoveChatMember added in v1.7.0

func (bot Bot) RemoveChatMember(chatID string, idList []string) (*RemoveChatMemberResponse, error)

RemoveChatMember .

func (Bot) ReplyMessage added in v1.7.0

func (bot Bot) ReplyMessage(om OutcomingMessage) (*PostMessageResponse, error)

ReplyMessage replies a message

func (Bot) SearchChat added in v1.10.1

func (bot Bot) SearchChat(query string, pageToken string, pageSize int) (*ListChatResponse, error)

SearchChat search chat

func (*Bot) SetClient

func (bot *Bot) SetClient(c *http.Client)

SetClient assigns a new client to bot.client

func (*Bot) SetCustomClient added in v1.2.0

func (bot *Bot) SetCustomClient(c HTTPWrapper)

SetCustomClient .

func (*Bot) SetDomain

func (bot *Bot) SetDomain(domain string)

SetDomain set domain of endpoint, so we could call Feishu/Lark go-lark does not check your host, just use the right one or fail.

func (*Bot) SetLogger

func (bot *Bot) SetLogger(logger LogWrapper)

SetLogger set a new logger

func (Bot) SetTopNotice added in v1.8.0

func (bot Bot) SetTopNotice(chatID, actionType, messageID string) (*SetTopNoticeResponse, error)

SetTopNotice .

func (*Bot) SetWebhook added in v1.7.2

func (bot *Bot) SetWebhook(url string)

SetWebhook updates webhook URL

func (*Bot) StartHeartbeat

func (bot *Bot) StartHeartbeat() error

StartHeartbeat renew auth token periodically

func (*Bot) StopHeartbeat

func (bot *Bot) StopHeartbeat()

StopHeartbeat stop auto-renew

func (Bot) TenantAccessToken

func (bot Bot) TenantAccessToken() string

TenantAccessToken returns bot.tenantAccessToken for external use

func (Bot) UnpinMessage added in v1.8.0

func (bot Bot) UnpinMessage(messageID string) (*UnpinMessageResponse, error)

UnpinMessage unpins a message

func (*Bot) UnsetCustomClient added in v1.2.0

func (bot *Bot) UnsetCustomClient()

UnsetCustomClient .

func (Bot) UpdateChat added in v1.7.0

func (bot Bot) UpdateChat(chatID string, req UpdateChatRequest) (*UpdateChatResponse, error)

UpdateChat .

func (*Bot) UpdateGroupInfo

func (bot *Bot) UpdateGroupInfo(params *UpdateGroupInfoReq) (*UpdateGroupInfoResponse, error)

UpdateGroupInfo update lark group info

func (Bot) UpdateMessage added in v1.7.0

func (bot Bot) UpdateMessage(messageID string, om OutcomingMessage) (*UpdateMessageResponse, error)

UpdateMessage updates a message

func (Bot) UploadFile added in v1.7.0

func (bot Bot) UploadFile(req UploadFileRequest) (*UploadFileResponse, error)

UploadFile uploads file to Lark server

func (Bot) UploadImage

func (bot Bot) UploadImage(path string) (*UploadImageResponse, error)

UploadImage uploads image to Lark server

func (Bot) UploadImageObject

func (bot Bot) UploadImageObject(img image.Image) (*UploadImageResponse, error)

UploadImageObject uploads image to Lark server

func (*Bot) WithContext added in v1.4.0

func (bot *Bot) WithContext(ctx context.Context) *Bot

WithContext .

func (*Bot) WithUserIDType added in v1.7.0

func (bot *Bot) WithUserIDType(userIDType string) *Bot

WithUserIDType .

type CardBuilder added in v1.5.0

type CardBuilder struct {
	I18N *i18nCardBuilder
}

CardBuilder .

func NewCardBuilder added in v1.5.0

func NewCardBuilder() *CardBuilder

NewCardBuilder 新建卡片构造器

func (CardBuilder) Action added in v1.5.0

func (CardBuilder) Action(actions ...card.Element) *card.ActionBlock

Action 交互元素,可添加 Button, SelectMenu, Overflow, DatePicker, TimePicker, DatetimePicker

func (CardBuilder) Button added in v1.5.0

func (CardBuilder) Button(text *card.TextBlock) *card.ButtonBlock

Button 按钮交互元素

func (CardBuilder) Card added in v1.5.0

func (CardBuilder) Card(elements ...card.Element) *card.Block

Card 包裹了最外层的卡片结构

func (CardBuilder) Column added in v1.9.0

func (CardBuilder) Column(elements ...card.Element) *card.ColumnBlock

Column column module

func (CardBuilder) ColumnSet added in v1.9.0

func (CardBuilder) ColumnSet(columns ...*card.ColumnBlock) *card.ColumnSetBlock

ColumnSet column set module

func (CardBuilder) ColumnSetAction added in v1.9.0

func (CardBuilder) ColumnSetAction(url *card.URLBlock) *card.ColumnSetActionBlock

ColumnSetAction column action module

func (CardBuilder) Confirm added in v1.5.0

func (CardBuilder) Confirm(title, text string) *card.ConfirmBlock

Confirm 用于交互元素的二次确认

func (CardBuilder) DatePicker added in v1.5.0

func (CardBuilder) DatePicker() *card.DatePickerBlock

DatePicker 日期选择器

func (CardBuilder) DatetimePicker added in v1.5.0

func (CardBuilder) DatetimePicker() *card.DatetimePickerBlock

DatetimePicker 日期时间选择器

func (CardBuilder) Div added in v1.5.0

func (CardBuilder) Div(fields ...*card.FieldBlock) *card.DivBlock

Div 内容模块

func (CardBuilder) Field added in v1.5.0

func (CardBuilder) Field(text *card.TextBlock) *card.FieldBlock

Field 内容模块的排版元素

func (CardBuilder) Hr added in v1.5.0

func (CardBuilder) Hr() *card.HrBlock

Hr 分割线模块

func (CardBuilder) Img added in v1.5.0

func (CardBuilder) Img(key string) *card.ImgBlock

Img 图片展示模块

func (CardBuilder) Markdown added in v1.5.0

func (CardBuilder) Markdown(s string) *card.MarkdownBlock

Markdown 单独使用的 Markdown 文本模块

func (CardBuilder) Note added in v1.5.0

func (CardBuilder) Note() *card.NoteBlock

Note 备注模块

func (CardBuilder) Option added in v1.5.0

func (CardBuilder) Option(value string) *card.OptionBlock

Option 选项模块,可用于 SelectMenu 和 Overflow

func (CardBuilder) Overflow added in v1.5.0

func (CardBuilder) Overflow(options ...*card.OptionBlock) *card.OverflowBlock

Overflow 折叠按钮菜单组件

func (CardBuilder) SelectMenu added in v1.5.0

func (CardBuilder) SelectMenu(options ...*card.OptionBlock) *card.SelectMenuBlock

SelectMenu 菜单组件

func (CardBuilder) Text added in v1.5.0

func (CardBuilder) Text(s string) *card.TextBlock

Text 文本模块

func (CardBuilder) TimePicker added in v1.5.0

func (CardBuilder) TimePicker() *card.TimePickerBlock

TimePicker 时间选择器

func (CardBuilder) URL added in v1.5.0

func (CardBuilder) URL() *card.URLBlock

URL 链接模块

type CardContent

type CardContent map[string]interface{}

CardContent struct of card content

type ChatInfo added in v1.7.0

type ChatInfo struct {
	ChatID                 string    `json:"chat_id,omitempty"`
	Name                   string    `json:"name,omitempty"`
	Avatar                 string    `json:"avatar,omitempty"`
	Description            string    `json:"description,omitempty"`
	I18NNames              I18NNames `json:"i18n_names,omitempty"`
	AddMemberPermission    string    `json:"add_member_permission,omitempty"`
	ShareCardPermission    string    `json:"share_card_permission,omitempty"`
	AtAllPermission        string    `json:"at_all_permission,omitempty"`
	EditPermission         string    `json:"edit_permission,omitempty"`
	OwnerIDType            string    `json:"owner_id_type,omitempty"`
	OwnerID                string    `json:"owner_id,omitempty"`
	ChatMode               string    `json:"chat_mode,omitempty"`
	ChatType               string    `json:"chat_type,omitempty"`
	ChatTag                string    `json:"chat_tag,omitempty"`
	JoinMessageVisibility  string    `json:"join_message_visibility,omitempty"`
	LeaveMessageVisibility string    `json:"leave_message_visibility,omitempty"`
	MembershipApproval     string    `json:"membership_approval,omitempty"`
	ModerationPermission   string    `json:"moderation_permission,omitempty"`
	External               bool      `json:"external,omitempty"`
}

ChatInfo entity of a chat, not every field is available for every API.

type ChatListInfo added in v1.10.1

type ChatListInfo struct {
	ChatID      string `json:"chat_id,omitempty"`
	Name        string `json:"name,omitempty"`
	Avatar      string `json:"avatar,omitempty"`
	Description string `json:"description,omitempty"`
	OwnerIDType string `json:"owner_id_type,omitempty"`
	OwnerID     string `json:"owner_id,omitempty"`
	External    bool   `json:"external,omitempty"`
	TenantKey   string `json:"tenant_key"`
}

ChatListInfo .

type ChatMember added in v1.7.0

type ChatMember struct {
	MemberIDType string `json:"member_id_type"`
	MemberID     string `json:"member_id"`
	Name         string `json:"name"`
	TenantKey    string `json:"tenant_key"`
}

ChatMember .

type ChatTopNoticeAction added in v1.8.0

type ChatTopNoticeAction struct {
	ActionType string `json:"action_type"`
	MessageID  string `json:"message_id"`
}

ChatTopNoticeAction .

type CreateChatRequest added in v1.7.0

type CreateChatRequest struct {
	Name                   string    `json:"name,omitempty"`
	Avatar                 string    `json:"avatar,omitempty"`
	Description            string    `json:"description,omitempty"`
	I18NNames              I18NNames `json:"i18n_names,omitempty"`
	OwnerID                string    `json:"owner_id,omitempty"`
	ChatMode               string    `json:"chat_mode,omitempty"`
	ChatType               string    `json:"chat_type,omitempty"`
	JoinMessageVisibility  string    `json:"join_message_visibility,omitempty"`
	LeaveMessageVisibility string    `json:"leave_message_visibility,omitempty"`
	MembershipApproval     string    `json:"membership_approval,omitempty"`
	External               bool      `json:"external,omitempty"`
}

CreateChatRequest .

type CreateChatResponse added in v1.7.0

type CreateChatResponse struct {
	BaseResponse

	Data ChatInfo `json:"data"`
}

CreateChatResponse .

type CreateGroupResponse

type CreateGroupResponse struct {
	BaseResponse
	OpenChatID    string   `json:"open_chat_id"`
	InvalidOpenID []string `json:"invalid_open_ids"`
}

CreateGroupResponse .

type DeleteChatResponse added in v1.7.0

type DeleteChatResponse struct {
	BaseResponse
}

DeleteChatResponse .

type DeleteEphemeralMessageResponse added in v1.6.0

type DeleteEphemeralMessageResponse = BaseResponse

DeleteEphemeralMessageResponse .

type DeleteGroupMemberResponse

type DeleteGroupMemberResponse AddGroupMemberResponse

DeleteGroupMemberResponse .

type DeleteTopNoticeResponse added in v1.8.0

type DeleteTopNoticeResponse = BaseResponse

DeleteTopNoticeResponse .

type DisbandGroupResponse

type DisbandGroupResponse = BaseResponse

DisbandGroupResponse .

type EmojiType added in v1.11.0

type EmojiType string

EmojiType .

const (
	EmojiTypeOK                       EmojiType = "OK"
	EmojiTypeTHUMBSUP                 EmojiType = "THUMBSUP"
	EmojiTypeTHANKS                   EmojiType = "THANKS"
	EmojiTypeMUSCLE                   EmojiType = "MUSCLE"
	EmojiTypeFINGERHEART              EmojiType = "FINGERHEART"
	EmojiTypeAPPLAUSE                 EmojiType = "APPLAUSE"
	EmojiTypeFISTBUMP                 EmojiType = "FISTBUMP"
	EmojiTypeJIAYI                    EmojiType = "JIAYI"
	EmojiTypeDONE                     EmojiType = "DONE"
	EmojiTypeSMILE                    EmojiType = "SMILE"
	EmojiTypeBLUSH                    EmojiType = "BLUSH"
	EmojiTypeLAUGH                    EmojiType = "LAUGH"
	EmojiTypeSMIRK                    EmojiType = "SMIRK"
	EmojiTypeLOL                      EmojiType = "LOL"
	EmojiTypeFACEPALM                 EmojiType = "FACEPALM"
	EmojiTypeLOVE                     EmojiType = "LOVE"
	EmojiTypeWINK                     EmojiType = "WINK"
	EmojiTypePROUD                    EmojiType = "PROUD"
	EmojiTypeWITTY                    EmojiType = "WITTY"
	EmojiTypeSMART                    EmojiType = "SMART"
	EmojiTypeSCOWL                    EmojiType = "SCOWL"
	EmojiTypeTHINKING                 EmojiType = "THINKING"
	EmojiTypeSOB                      EmojiType = "SOB"
	EmojiTypeCRY                      EmojiType = "CRY"
	EmojiTypeERROR                    EmojiType = "ERROR"
	EmojiTypeNOSEPICK                 EmojiType = "NOSEPICK"
	EmojiTypeHAUGHTY                  EmojiType = "HAUGHTY"
	EmojiTypeSLAP                     EmojiType = "SLAP"
	EmojiTypeSPITBLOOD                EmojiType = "SPITBLOOD"
	EmojiTypeTOASTED                  EmojiType = "TOASTED"
	EmojiTypeGLANCE                   EmojiType = "GLANCE"
	EmojiTypeDULL                     EmojiType = "DULL"
	EmojiTypeINNOCENTSMILE            EmojiType = "INNOCENTSMILE"
	EmojiTypeJOYFUL                   EmojiType = "JOYFUL"
	EmojiTypeWOW                      EmojiType = "WOW"
	EmojiTypeTRICK                    EmojiType = "TRICK"
	EmojiTypeYEAH                     EmojiType = "YEAH"
	EmojiTypeENOUGH                   EmojiType = "ENOUGH"
	EmojiTypeTEARS                    EmojiType = "TEARS"
	EmojiTypeEMBARRASSED              EmojiType = "EMBARRASSED"
	EmojiTypeKISS                     EmojiType = "KISS"
	EmojiTypeSMOOCH                   EmojiType = "SMOOCH"
	EmojiTypeDROOL                    EmojiType = "DROOL"
	EmojiTypeOBSESSED                 EmojiType = "OBSESSED"
	EmojiTypeMONEY                    EmojiType = "MONEY"
	EmojiTypeTEASE                    EmojiType = "TEASE"
	EmojiTypeSHOWOFF                  EmojiType = "SHOWOFF"
	EmojiTypeCOMFORT                  EmojiType = "COMFORT"
	EmojiTypeCLAP                     EmojiType = "CLAP"
	EmojiTypePRAISE                   EmojiType = "PRAISE"
	EmojiTypeSTRIVE                   EmojiType = "STRIVE"
	EmojiTypeXBLUSH                   EmojiType = "XBLUSH"
	EmojiTypeSILENT                   EmojiType = "SILENT"
	EmojiTypeWAVE                     EmojiType = "WAVE"
	EmojiTypeWHAT                     EmojiType = "WHAT"
	EmojiTypeFROWN                    EmojiType = "FROWN"
	EmojiTypeSHY                      EmojiType = "SHY"
	EmojiTypeDIZZY                    EmojiType = "DIZZY"
	EmojiTypeLOOKDOWN                 EmojiType = "LOOKDOWN"
	EmojiTypeCHUCKLE                  EmojiType = "CHUCKLE"
	EmojiTypeWAIL                     EmojiType = "WAIL"
	EmojiTypeCRAZY                    EmojiType = "CRAZY"
	EmojiTypeWHIMPER                  EmojiType = "WHIMPER"
	EmojiTypeHUG                      EmojiType = "HUG"
	EmojiTypeBLUBBER                  EmojiType = "BLUBBER"
	EmojiTypeWRONGED                  EmojiType = "WRONGED"
	EmojiTypeHUSKY                    EmojiType = "HUSKY"
	EmojiTypeSHHH                     EmojiType = "SHHH"
	EmojiTypeSMUG                     EmojiType = "SMUG"
	EmojiTypeANGRY                    EmojiType = "ANGRY"
	EmojiTypeHAMMER                   EmojiType = "HAMMER"
	EmojiTypeSHOCKED                  EmojiType = "SHOCKED"
	EmojiTypeTERROR                   EmojiType = "TERROR"
	EmojiTypePETRIFIED                EmojiType = "PETRIFIED"
	EmojiTypeSKULL                    EmojiType = "SKULL"
	EmojiTypeSWEAT                    EmojiType = "SWEAT"
	EmojiTypeSPEECHLESS               EmojiType = "SPEECHLESS"
	EmojiTypeSLEEP                    EmojiType = "SLEEP"
	EmojiTypeDROWSY                   EmojiType = "DROWSY"
	EmojiTypeYAWN                     EmojiType = "YAWN"
	EmojiTypeSICK                     EmojiType = "SICK"
	EmojiTypePUKE                     EmojiType = "PUKE"
	EmojiTypeBETRAYED                 EmojiType = "BETRAYED"
	EmojiTypeHEADSET                  EmojiType = "HEADSET"
	EmojiTypeEatingFood               EmojiType = "EatingFood"
	EmojiTypeMeMeMe                   EmojiType = "MeMeMe"
	EmojiTypeSigh                     EmojiType = "Sigh"
	EmojiTypeTyping                   EmojiType = "Typing"
	EmojiTypeLemon                    EmojiType = "Lemon"
	EmojiTypeGet                      EmojiType = "Get"
	EmojiTypeLGTM                     EmojiType = "LGTM"
	EmojiTypeOnIt                     EmojiType = "OnIt"
	EmojiTypeOneSecond                EmojiType = "OneSecond"
	EmojiTypeVRHeadset                EmojiType = "VRHeadset"
	EmojiTypeYouAreTheBest            EmojiType = "YouAreTheBest"
	EmojiTypeSALUTE                   EmojiType = "SALUTE"
	EmojiTypeSHAKE                    EmojiType = "SHAKE"
	EmojiTypeHIGHFIVE                 EmojiType = "HIGHFIVE"
	EmojiTypeUPPERLEFT                EmojiType = "UPPERLEFT"
	EmojiTypeThumbsDown               EmojiType = "ThumbsDown"
	EmojiTypeSLIGHT                   EmojiType = "SLIGHT"
	EmojiTypeTONGUE                   EmojiType = "TONGUE"
	EmojiTypeEYESCLOSED               EmojiType = "EYESCLOSED"
	EmojiTypeRoarForYou               EmojiType = "RoarForYou"
	EmojiTypeCALF                     EmojiType = "CALF"
	EmojiTypeBEAR                     EmojiType = "BEAR"
	EmojiTypeBULL                     EmojiType = "BULL"
	EmojiTypeRAINBOWPUKE              EmojiType = "RAINBOWPUKE"
	EmojiTypeROSE                     EmojiType = "ROSE"
	EmojiTypeHEART                    EmojiType = "HEART"
	EmojiTypePARTY                    EmojiType = "PARTY"
	EmojiTypeLIPS                     EmojiType = "LIPS"
	EmojiTypeBEER                     EmojiType = "BEER"
	EmojiTypeCAKE                     EmojiType = "CAKE"
	EmojiTypeGIFT                     EmojiType = "GIFT"
	EmojiTypeCUCUMBER                 EmojiType = "CUCUMBER"
	EmojiTypeDrumstick                EmojiType = "Drumstick"
	EmojiTypePepper                   EmojiType = "Pepper"
	EmojiTypeCANDIEDHAWS              EmojiType = "CANDIEDHAWS"
	EmojiTypeBubbleTea                EmojiType = "BubbleTea"
	EmojiTypeCoffee                   EmojiType = "Coffee"
	EmojiTypeYes                      EmojiType = "Yes"
	EmojiTypeNo                       EmojiType = "No"
	EmojiTypeOKR                      EmojiType = "OKR"
	EmojiTypeCheckMark                EmojiType = "CheckMark"
	EmojiTypeCrossMark                EmojiType = "CrossMark"
	EmojiTypeMinusOne                 EmojiType = "MinusOne"
	EmojiTypeHundred                  EmojiType = "Hundred"
	EmojiTypeAWESOMEN                 EmojiType = "AWESOMEN"
	EmojiTypePin                      EmojiType = "Pin"
	EmojiTypeAlarm                    EmojiType = "Alarm"
	EmojiTypeLoudspeaker              EmojiType = "Loudspeaker"
	EmojiTypeTrophy                   EmojiType = "Trophy"
	EmojiTypeFire                     EmojiType = "Fire"
	EmojiTypeBOMB                     EmojiType = "BOMB"
	EmojiTypeMusic                    EmojiType = "Music"
	EmojiTypeXmasTree                 EmojiType = "XmasTree"
	EmojiTypeSnowman                  EmojiType = "Snowman"
	EmojiTypeXmasHat                  EmojiType = "XmasHat"
	EmojiTypeFIREWORKS                EmojiType = "FIREWORKS"
	EmojiType2022                     EmojiType = "2022"
	EmojiTypeREDPACKET                EmojiType = "REDPACKET"
	EmojiTypeFORTUNE                  EmojiType = "FORTUNE"
	EmojiTypeLUCK                     EmojiType = "LUCK"
	EmojiTypeFIRECRACKER              EmojiType = "FIRECRACKER"
	EmojiTypeStickyRiceBalls          EmojiType = "StickyRiceBalls"
	EmojiTypeHEARTBROKEN              EmojiType = "HEARTBROKEN"
	EmojiTypePOOP                     EmojiType = "POOP"
	EmojiTypeStatusFlashOfInspiration EmojiType = "StatusFlashOfInspiration"
	EmojiType18X                      EmojiType = "18X"
	EmojiTypeCLEAVER                  EmojiType = "CLEAVER"
	EmojiTypeSoccer                   EmojiType = "Soccer"
	EmojiTypeBasketball               EmojiType = "Basketball"
	EmojiTypeGeneralDoNotDisturb      EmojiType = "GeneralDoNotDisturb"
	EmojiTypeStatusPrivateMessage     EmojiType = "Status_PrivateMessage"
	EmojiTypeGeneralInMeetingBusy     EmojiType = "GeneralInMeetingBusy"
	EmojiTypeStatusReading            EmojiType = "StatusReading"
	EmojiTypeStatusInFlight           EmojiType = "StatusInFlight"
	EmojiTypeGeneralBusinessTrip      EmojiType = "GeneralBusinessTrip"
	EmojiTypeGeneralWorkFromHome      EmojiType = "GeneralWorkFromHome"
	EmojiTypeStatusEnjoyLife          EmojiType = "StatusEnjoyLife"
	EmojiTypeGeneralTravellingCar     EmojiType = "GeneralTravellingCar"
	EmojiTypeStatusBus                EmojiType = "StatusBus"
	EmojiTypeGeneralSun               EmojiType = "GeneralSun"
	EmojiTypeGeneralMoonRest          EmojiType = "GeneralMoonRest"
	EmojiTypePursueUltimate           EmojiType = "PursueUltimate"
	EmojiTypePatient                  EmojiType = "Patient"
	EmojiTypeAmbitious                EmojiType = "Ambitious"
	EmojiTypeCustomerSuccess          EmojiType = "CustomerSuccess"
	EmojiTypeResponsible              EmojiType = "Responsible"
	EmojiTypeReliable                 EmojiType = "Reliable"
)

Emoji types

type EncryptedReq

type EncryptedReq struct {
	Encrypt string `json:"encrypt,omitempty"`
}

EncryptedReq request of encrypted challenge

type EventBody

type EventBody struct {
	Type          string `json:"type"`
	AppID         string `json:"app_id"`
	TenantKey     string `json:"tenant_key"`
	ChatType      string `json:"chat_type"`
	MsgType       string `json:"msg_type"`
	RootID        string `json:"root_id,omitempty"`
	ParentID      string `json:"parent_id,omitempty"`
	OpenID        string `json:"open_id,omitempty"`
	OpenChatID    string `json:"open_chat_id,omitempty"`
	OpenMessageID string `json:"open_message_id,omitempty"`
	IsMention     bool   `json:"is_mention,omitempty"`
	Title         string `json:"title,omitempty"`
	Text          string `json:"text,omitempty"`
	RealText      string `json:"text_without_at_bot,omitempty"`
	ImageKey      string `json:"image_key,omitempty"`
	ImageURL      string `json:"image_url,omitempty"`
	FileKey       string `json:"file_key,omitempty"`
}

EventBody .

type EventCardAction added in v1.13.1

type EventCardAction struct {
	Tag      string          `json:"tag,omitempty"`      // button, overflow, select_static, select_person, &datepicker
	Option   string          `json:"option,omitempty"`   // only for Overflow and SelectMenu
	Timezone string          `json:"timezone,omitempty"` // only for DatePicker
	Value    json.RawMessage `json:"value,omitempty"`    // for any elements with value
}

EventCardAction .

type EventCardCallback added in v1.13.1

type EventCardCallback struct {
	AppID     string          `json:"app_id,omitempty"`
	TenantKey string          `json:"tenant_key,omitempty"`
	Token     string          `json:"token,omitempty"`
	OpenID    string          `json:"open_id,omitempty"`
	UserID    string          `json:"user_id,omitempty"`
	MessageID string          `json:"open_message_id,omitempty"`
	ChatID    string          `json:"open_chat_id,omitempty"`
	Action    EventCardAction `json:"action,omitempty"`
}

EventCardCallback request of card

type EventChallenge added in v1.13.1

type EventChallenge struct {
	Token     string `json:"token,omitempty"`
	Challenge string `json:"challenge,omitempty"`
	Type      string `json:"type,omitempty"`
}

EventChallenge request of add event hook

type EventChallengeReq

type EventChallengeReq = EventChallenge

EventChallengeReq is deprecated. Keep for legacy versions.

type EventMessage

type EventMessage struct {
	UUID      string `json:"uuid"`
	Timestamp string `json:"ts"`
	// Token is shown by Lark to indicate it is not a fake message, check at your own need
	Token     string    `json:"token"`
	EventType string    `json:"type"`
	Event     EventBody `json:"event"`
}

EventMessage .

type EventV2 added in v1.7.0

type EventV2 struct {
	Schema string        `json:"schema,omitempty"`
	Header EventV2Header `json:"header,omitempty"`

	EventRaw json.RawMessage `json:"event,omitempty"`
	Event    interface{}     `json:"-"`
}

EventV2 handles events with v2 schema

func (EventV2) GetBotAdded added in v1.8.0

func (e EventV2) GetBotAdded() (*EventV2BotAdded, error)

GetBotAdded .

func (EventV2) GetBotDeleted added in v1.8.0

func (e EventV2) GetBotDeleted() (*EventV2BotDeleted, error)

GetBotDeleted .

func (EventV2) GetChatDisbanded added in v1.8.0

func (e EventV2) GetChatDisbanded() (*EventV2ChatDisbanded, error)

GetChatDisbanded .

func (EventV2) GetEvent added in v1.8.0

func (e EventV2) GetEvent(eventType string, body interface{}) error

GetEvent .

func (EventV2) GetMessageReactionCreated added in v1.13.3

func (e EventV2) GetMessageReactionCreated() (*EventV2MessageReactionCreated, error)

GetMessageReactionCreated .

func (EventV2) GetMessageReactionDeleted added in v1.13.3

func (e EventV2) GetMessageReactionDeleted() (*EventV2MessageReactionDeleted, error)

GetMessageReactionDeleted .

func (EventV2) GetMessageRead added in v1.8.0

func (e EventV2) GetMessageRead() (*EventV2MessageRead, error)

GetMessageRead .

func (EventV2) GetMessageRecalled added in v1.13.3

func (e EventV2) GetMessageRecalled() (*EventV2MessageRecalled, error)

GetMessageRecalled .

func (EventV2) GetMessageReceived added in v1.7.0

func (e EventV2) GetMessageReceived() (*EventV2MessageReceived, error)

GetMessageReceived .

func (EventV2) GetUserAdded added in v1.8.0

func (e EventV2) GetUserAdded() (*EventV2UserAdded, error)

GetUserAdded .

func (EventV2) GetUserDeleted added in v1.8.0

func (e EventV2) GetUserDeleted() (*EventV2UserDeleted, error)

GetUserDeleted .

func (EventV2) PostEvent added in v1.7.0

func (e EventV2) PostEvent(client *http.Client, hookURL string) (*http.Response, error)

PostEvent with event v2 format and it's part of EventV2 instead of package method

type EventV2BotAdded added in v1.8.0

type EventV2BotAdded struct {
	ChatID            string        `json:"chat_id,omitempty"`
	OperatorID        EventV2UserID `json:"operator_id,omitempty"`
	External          bool          `json:"external,omitempty"`
	OperatorTenantKey string        `json:"operator_tenant_key,omitempty"`
}

EventV2BotAdded .

type EventV2BotDeleted added in v1.8.0

type EventV2BotDeleted = EventV2BotAdded

EventV2BotDeleted .

type EventV2ChatDisbanded added in v1.7.0

type EventV2ChatDisbanded struct {
	ChatID            string        `json:"chat_id,omitempty"`
	OperatorID        EventV2UserID `json:"operator_id,omitempty"`
	External          bool          `json:"external,omitempty"`
	OperatorTenantKey string        `json:"operator_tenant_key,omitempty"`
}

EventV2ChatDisbanded .

type EventV2Header added in v1.7.0

type EventV2Header struct {
	EventID    string `json:"event_id,omitempty"`
	EventType  string `json:"event_type,omitempty"`
	CreateTime string `json:"create_time,omitempty"`
	Token      string `json:"token,omitempty"`
	AppID      string `json:"app_id,omitempty"`
	TenantKey  string `json:"tenant_key,omitempty"`
}

EventV2Header .

type EventV2MessageReactionCreated added in v1.13.3

type EventV2MessageReactionCreated struct {
	MessageID    string        `json:"message_id,omitempty"`
	OperatorType string        `json:"operator_type,omitempty"`
	UserID       EventV2UserID `json:"user_id,omitempty"`
	AppID        string        `json:"app_id,omitempty"`
	ActionTime   string        `json:"action_time,omitempty"`
	ReactionType struct {
		EmojiType string `json:"emoji_type,omitempty"`
	} `json:"reaction_type,omitempty"`
}

EventV2MessageReactionCreated .

type EventV2MessageReactionDeleted added in v1.13.3

type EventV2MessageReactionDeleted struct {
	MessageID    string        `json:"message_id,omitempty"`
	OperatorType string        `json:"operator_type,omitempty"`
	UserID       EventV2UserID `json:"user_id,omitempty"`
	AppID        string        `json:"app_id,omitempty"`
	ActionTime   string        `json:"action_time,omitempty"`
	ReactionType struct {
		EmojiType string `json:"emoji_type,omitempty"`
	} `json:"reaction_type,omitempty"`
}

EventV2MessageReactionDeleted .

type EventV2MessageRead added in v1.8.0

type EventV2MessageRead struct {
	Reader struct {
		ReaderID  EventV2UserID `json:"reader_id,omitempty"`
		ReadTime  string        `json:"read_time,omitempty"`
		TenantKey string        `json:"tenant_key,omitempty"`
	} `json:"reader,omitempty"`
	MessageIDList []string `json:"message_id_list,omitempty"`
}

EventV2MessageRead .

type EventV2MessageRecalled added in v1.13.3

type EventV2MessageRecalled struct {
	MessageID  string `json:"message_id,omitempty"`
	ChatID     string `json:"chat_id,omitempty"`
	RecallTime string `json:"recall_time,omitempty"`
	RecallType string `json:"recall_type,omitempty"`
}

EventV2MessageRecalled .

type EventV2MessageReceived added in v1.7.0

type EventV2MessageReceived struct {
	Sender struct {
		SenderID   EventV2UserID `json:"sender_id,omitempty"`
		SenderType string        `json:"sender_type,omitempty"`
		TenantKey  string        `json:"tenant_key,omitempty"`
	} `json:"sender,omitempty"`
	Message struct {
		MessageID   string `json:"message_id,omitempty"`
		RootID      string `json:"root_id,omitempty"`
		ParentID    string `json:"parent_id,omitempty"`
		CreateTime  string `json:"create_time,omitempty"`
		ChatID      string `json:"chat_id,omitempty"`
		ChatType    string `json:"chat_type,omitempty"`
		MessageType string `json:"message_type,omitempty"`
		Content     string `json:"content,omitempty"`
		Mentions    []struct {
			Key       string        `json:"key,omitempty"`
			ID        EventV2UserID `json:"id,omitempty"`
			Name      string        `json:"name,omitempty"`
			TenantKey string        `json:"tenant_key,omitempty"`
		} `json:"mentions,omitempty"`
	} `json:"message,omitempty"`
}

EventV2MessageReceived .

type EventV2UserAdded added in v1.8.0

type EventV2UserAdded struct {
	ChatID            string        `json:"chat_id,omitempty"`
	OperatorID        EventV2UserID `json:"operator_id,omitempty"`
	External          bool          `json:"external,omitempty"`
	OperatorTenantKey string        `json:"operator_tenant_key,omitempty"`
	Users             []struct {
		Name      string        `json:"name,omitempty"`
		TenantKey string        `json:"tenant_key,omitempty"`
		UserID    EventV2UserID `json:"user_id,omitempty"`
	} `json:"users,omitempty"`
}

EventV2UserAdded .

type EventV2UserDeleted added in v1.8.0

type EventV2UserDeleted = EventV2UserAdded

EventV2UserDeleted .

type EventV2UserID added in v1.7.0

type EventV2UserID struct {
	UnionID string `json:"union_id,omitempty"`
	UserID  string `json:"user_id,omitempty"`
	OpenID  string `json:"open_id,omitempty"`
}

EventV2UserID .

type FileContent added in v1.7.0

type FileContent struct {
	FileName string `json:"file_name,omitempty"`
	FileKey  string `json:"file_key"`
}

FileContent .

type ForwardMessageResponse added in v1.12.0

type ForwardMessageResponse = PostMessageResponse

ForwardMessageResponse .

type GetBotInfoResponse

type GetBotInfoResponse struct {
	BaseResponse
	Bot struct {
		ActivateStatus int      `json:"activate_status"`
		AppName        string   `json:"app_name"`
		AvatarURL      string   `json:"avatar_url"`
		IPWhiteList    []string `json:"ip_white_list"`
		OpenID         string   `json:"open_id"`
	} `json:"bot"`
}

GetBotInfoResponse .

type GetChatMembersResponse added in v1.7.0

type GetChatMembersResponse struct {
	BaseResponse

	Data struct {
		Items       []ChatMember `json:"items"`
		PageToken   string       `json:"page_token"`
		HasMore     bool         `json:"has_more"`
		MemberTotal int          `json:"member_total"`
	} `json:"data"`
}

GetChatMembersResponse .

type GetChatResponse added in v1.7.0

type GetChatResponse struct {
	BaseResponse

	Data ChatInfo `json:"data"`
}

GetChatResponse .

type GetMessageResponse added in v1.7.0

type GetMessageResponse struct {
	BaseResponse

	Data struct {
		Items []IMMessage `json:"items"`
	} `json:"data"`
}

GetMessageResponse .

type GetUserInfoResponse

type GetUserInfoResponse struct {
	BaseResponse
	Data struct {
		User UserInfo
	}
}

GetUserInfoResponse .

type GroupInfoResponse

type GroupInfoResponse struct {
	BaseResponse
	Data struct {
		AddMemberVerify        bool   `json:"add_member_verify"`
		Avatar                 string `json:"avatar"`
		ChatID                 string `json:"chat_id"`
		Description            string `json:"description"`
		GroupEmailEnabled      bool   `json:"group_email_enabled"`
		JoinMessageVisibility  string `json:"join_message_visibility"`
		LeaveMessageVisibility string `json:"leave_message_visibility"`
		Members                []struct {
			OpenID string `json:"open_id"`
		} `json:"members"`
		Name                     string `json:"name"`
		OnlyOwnerAdd             bool   `json:"only_owner_add"`
		OnlyOwnerAtAll           bool   `json:"only_owner_at_all"`
		OnlyOwnerEdit            bool   `json:"only_owner_edit"`
		OwnerOpenID              string `json:"owner_open_id"`
		SendGroupEmailPermission string `json:"send_group_email_permission"`
		SendMessagePermission    string `json:"send_message_permission"`
		ShareAllowed             bool   `json:"share_allowed"`
		Type                     string `json:"type"`
	} `json:"data"`
}

GroupInfoResponse .

type GroupListResponse

type GroupListResponse struct {
	BaseResponse
	HasMore bool `json:"has_more"`
	Chats   []struct {
		ID      string `json:"id"`
		Name    string `json:"name"`
		OwnerID string `json:"owner_id"`
	} `json:"chats"`
}

GroupListResponse .

type HTTPWrapper added in v1.2.0

type HTTPWrapper interface {
	Do(
		ctx context.Context,
		method, url string,
		header http.Header,
		body io.Reader) (io.ReadCloser, error)
}

HTTPWrapper is a wrapper interface, which enables extension on HTTP part. Typicall, we do not need this because default client is sufficient.

type I18NNames added in v1.7.0

type I18NNames struct {
	ZhCN string `json:"zh_cn,omitempty"`
	EnUS string `json:"en_us,omitempty"`
	JaJP string `json:"ja_jp,omitempty"`
}

I18NNames .

type IMBody added in v1.7.0

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

IMBody .

type IMMention added in v1.7.0

type IMMention struct {
	ID     string `json:"id"`
	IDType string `json:"id_type"`
	Key    string `json:"key"`
	Name   string `json:"name"`
}

IMMention .

type IMMessage added in v1.7.0

type IMMessage struct {
	MessageID      string      `json:"message_id"`
	UpperMessageID string      `json:"upper_message_id"`
	RootID         string      `json:"root_id"`
	ParentID       string      `json:"parent_id"`
	ThreadID       string      `json:"thread_id"`
	ChatID         string      `json:"chat_id"`
	MsgType        string      `json:"msg_type"`
	CreateTime     string      `json:"create_time"`
	UpdateTime     string      `json:"update_time"`
	Deleted        bool        `json:"deleted"`
	Updated        bool        `json:"updated"`
	Sender         IMSender    `json:"sender"`
	Mentions       []IMMention `json:"mentions"`
	Body           IMBody      `json:"body"`
}

IMMessage .

type IMMessageRequest added in v1.7.0

type IMMessageRequest struct {
	Content       string `json:"content"`
	MsgType       string `json:"msg_type,omitempty"`
	ReceiveID     string `json:"receive_id,omitempty"`
	UUID          string `json:"uuid,omitempty"`
	ReplyInThread bool   `json:"reply_in_thread,omitempty"`
}

IMMessageRequest .

func BuildMessage added in v1.7.0

func BuildMessage(om OutcomingMessage) (*IMMessageRequest, error)

BuildMessage .

type IMSender added in v1.8.0

type IMSender struct {
	ID         string `json:"id"`
	IDType     string `json:"id_type"`
	SenderType string `json:"sender_type"`
	TenantKey  string `json:"tenant_key"`
}

IMSender .

type ImageContent added in v1.7.0

type ImageContent struct {
	ImageKey string `json:"image_key"`
}

ImageContent .

type IsInChatResponse added in v1.7.0

type IsInChatResponse struct {
	BaseResponse

	Data struct {
		IsInChat bool `json:"is_in_chat"`
	} `json:"data"`
}

IsInChatResponse .

type JoinChatResponse added in v1.7.0

type JoinChatResponse struct {
	BaseResponse
}

JoinChatResponse .

type ListChatResponse added in v1.10.1

type ListChatResponse struct {
	BaseResponse

	Data struct {
		Items     []ChatListInfo `json:"items"`
		PageToken string         `json:"page_token"`
		HasMore   bool           `json:"has_more"`
	} `json:"data"`
}

ListChatResponse .

type LogLevel added in v1.3.0

type LogLevel int

LogLevel defs

func (LogLevel) String added in v1.3.0

func (ll LogLevel) String() string

String .

type LogWrapper added in v1.3.0

type LogWrapper interface {
	// for log print
	Log(context.Context, LogLevel, string)
	// for test redirection
	SetOutput(io.Writer)
}

LogWrapper interface

type MediaContent added in v1.7.0

type MediaContent struct {
	FileName string `json:"file_name,omitempty"`
	FileKey  string `json:"file_key"`
	ImageKey string `json:"image_key"`
	Duration int    `json:"duration,omitempty"`
}

MediaContent .

type MessageContent

type MessageContent struct {
	Text      *TextContent      `json:"text,omitempty"`
	Image     *ImageContent     `json:"image,omitempty"`
	Post      *PostContent      `json:"post,omitempty"`
	Card      *CardContent      `json:"card,omitempty"`
	ShareChat *ShareChatContent `json:"share_chat,omitempty"`
	ShareUser *ShareUserContent `json:"share_user,omitempty"`
	Audio     *AudioContent     `json:"audio,omitempty"`
	Media     *MediaContent     `json:"media,omitempty"`
	File      *FileContent      `json:"file,omitempty"`
	Sticker   *StickerContent   `json:"sticker,omitempty"`
}

MessageContent struct of message content

type MessageReceiptResponse

type MessageReceiptResponse struct {
	BaseResponse
	Data struct {
		ReadUsers []struct {
			OpenID    string `json:"open_id"`
			UserID    string `json:"user_id"`
			Timestamp string `json:"timestamp"`
		} `json:"read_users"`
	} `json:"data"`
}

MessageReceiptResponse .

type MsgBuffer

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

MsgBuffer stores all the messages attached You can call every function, but some of which is only available for specific condition

func NewMsgBuffer

func NewMsgBuffer(newMsgType string) *MsgBuffer

NewMsgBuffer create a message buffer

func (*MsgBuffer) Audio added in v1.7.0

func (m *MsgBuffer) Audio(fileKey string) *MsgBuffer

Audio attaches audio for MsgAudio only

func (*MsgBuffer) BindChatID

func (m *MsgBuffer) BindChatID(chatID string) *MsgBuffer

BindChatID binds chat_id

func (*MsgBuffer) BindEmail

func (m *MsgBuffer) BindEmail(email string) *MsgBuffer

BindEmail binds email

func (*MsgBuffer) BindOpenChatID

func (m *MsgBuffer) BindOpenChatID(openChatID string) *MsgBuffer

BindOpenChatID binds open_chat_id

func (*MsgBuffer) BindOpenID

func (m *MsgBuffer) BindOpenID(openID string) *MsgBuffer

BindOpenID binds open_id

func (*MsgBuffer) BindReply

func (m *MsgBuffer) BindReply(rootID string) *MsgBuffer

BindReply binds root id for reply rootID is OpenMessageID of the message you reply

func (*MsgBuffer) BindUnionID added in v1.7.0

func (m *MsgBuffer) BindUnionID(unionID string) *MsgBuffer

BindUnionID binds union_id

func (*MsgBuffer) BindUserID

func (m *MsgBuffer) BindUserID(userID string) *MsgBuffer

BindUserID binds open_id

func (*MsgBuffer) Build

func (m *MsgBuffer) Build() OutcomingMessage

Build message and return message body

func (*MsgBuffer) Card

func (m *MsgBuffer) Card(cardContent string) *MsgBuffer

Card binds card content with V4 format

func (*MsgBuffer) Clear

func (m *MsgBuffer) Clear() *MsgBuffer

Clear message in buffer

func (*MsgBuffer) Error added in v1.3.0

func (m *MsgBuffer) Error() error

Error returns last error

func (*MsgBuffer) File added in v1.7.0

func (m *MsgBuffer) File(fileKey string) *MsgBuffer

File attaches file for MsgFile only

func (*MsgBuffer) Image

func (m *MsgBuffer) Image(imageKey string) *MsgBuffer

Image attaches image key for MsgImage only

func (*MsgBuffer) Media added in v1.7.0

func (m *MsgBuffer) Media(fileKey, imageKey string) *MsgBuffer

Media attaches media for MsgMedia only

func (*MsgBuffer) Post

func (m *MsgBuffer) Post(postContent *PostContent) *MsgBuffer

Post sets raw post content

func (*MsgBuffer) ReplyInThread added in v1.14.0

func (m *MsgBuffer) ReplyInThread(replyInThread bool) *MsgBuffer

ReplyInThread replies message in thread

func (*MsgBuffer) ShareChat

func (m *MsgBuffer) ShareChat(chatID string) *MsgBuffer

ShareChat attaches chat id for MsgShareChat only

func (*MsgBuffer) ShareUser added in v1.7.0

func (m *MsgBuffer) ShareUser(userID string) *MsgBuffer

ShareUser attaches user id for MsgShareUser only

func (*MsgBuffer) Sticker added in v1.7.0

func (m *MsgBuffer) Sticker(fileKey string) *MsgBuffer

Sticker attaches sticker for MsgSticker only

func (*MsgBuffer) Text

func (m *MsgBuffer) Text(text string) *MsgBuffer

Text attaches text

func (*MsgBuffer) WithSign added in v1.7.3

func (m *MsgBuffer) WithSign(secret string, ts int64) *MsgBuffer

WithSign generates sign for notification bot check

func (*MsgBuffer) WithUUID added in v1.7.4

func (m *MsgBuffer) WithUUID(uuid string) *MsgBuffer

WithUUID add UUID to message for idempotency

type MsgPostBuilder

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

MsgPostBuilder for build text buf

func NewPostBuilder

func NewPostBuilder() *MsgPostBuilder

NewPostBuilder creates a text builder

func (*MsgPostBuilder) AtTag

func (pb *MsgPostBuilder) AtTag(text, userID string) *MsgPostBuilder

AtTag creates an at tag

func (*MsgPostBuilder) Clear

func (pb *MsgPostBuilder) Clear()

Clear all message

func (*MsgPostBuilder) CurLocale added in v1.1.0

func (pb *MsgPostBuilder) CurLocale() *PostBuf

CurLocale switches to locale and returns the buffer of that locale

func (*MsgPostBuilder) ImageTag

func (pb *MsgPostBuilder) ImageTag(imageKey string, imageWidth, imageHeight int) *MsgPostBuilder

ImageTag creates an image tag

func (MsgPostBuilder) Len

func (pb MsgPostBuilder) Len() int

Len returns buf len

func (*MsgPostBuilder) LinkTag

func (pb *MsgPostBuilder) LinkTag(text, href string) *MsgPostBuilder

LinkTag creates a link tag

func (*MsgPostBuilder) Locale

func (pb *MsgPostBuilder) Locale(locale string) *MsgPostBuilder

Locale renamed to WithLocale but still available

func (*MsgPostBuilder) Render

func (pb *MsgPostBuilder) Render() *PostContent

Render message

func (*MsgPostBuilder) TextTag

func (pb *MsgPostBuilder) TextTag(text string, lines int, unescape bool) *MsgPostBuilder

TextTag creates a text tag

func (*MsgPostBuilder) Title

func (pb *MsgPostBuilder) Title(title string) *MsgPostBuilder

Title sets title

func (*MsgPostBuilder) WithLocale added in v1.1.0

func (pb *MsgPostBuilder) WithLocale(locale string) *MsgPostBuilder

WithLocale switches to locale and returns self

type MsgTextBuilder

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

MsgTextBuilder for build text buf

func NewTextBuilder

func NewTextBuilder() *MsgTextBuilder

NewTextBuilder creates a text builder

func (*MsgTextBuilder) Clear

func (tb *MsgTextBuilder) Clear()

Clear all message

func (MsgTextBuilder) Len

func (tb MsgTextBuilder) Len() int

Len returns buf len

func (*MsgTextBuilder) Mention

func (tb *MsgTextBuilder) Mention(userID string) *MsgTextBuilder

Mention @somebody

func (*MsgTextBuilder) MentionAll

func (tb *MsgTextBuilder) MentionAll() *MsgTextBuilder

MentionAll @all

func (*MsgTextBuilder) Render

func (tb *MsgTextBuilder) Render() string

Render message

func (*MsgTextBuilder) Text

func (tb *MsgTextBuilder) Text(text ...interface{}) *MsgTextBuilder

Text add simple texts

func (*MsgTextBuilder) Textf

func (tb *MsgTextBuilder) Textf(textFmt string, text ...interface{}) *MsgTextBuilder

Textf add texts with format

func (*MsgTextBuilder) Textln

func (tb *MsgTextBuilder) Textln(text ...interface{}) *MsgTextBuilder

Textln add simple texts with a newline

type OptionalUserID

type OptionalUserID struct {
	UIDType string
	RealID  string
}

OptionalUserID to contain openID, chatID, userID, email

func WithChatID

func WithChatID(chatID string) *OptionalUserID

WithChatID uses chatID as userID

func WithEmail

func WithEmail(email string) *OptionalUserID

WithEmail uses email as userID

func WithOpenID

func WithOpenID(openID string) *OptionalUserID

WithOpenID uses openID as userID

func WithUnionID added in v1.7.0

func WithUnionID(unionID string) *OptionalUserID

WithUnionID uses chatID as userID

func WithUserID

func WithUserID(userID string) *OptionalUserID

WithUserID uses userID as userID

type OutcomingMessage

type OutcomingMessage struct {
	MsgType string         `json:"msg_type"`
	Content MessageContent `json:"content"`
	Card    CardContent    `json:"card"`
	// ID for user
	UIDType string `json:"-"`
	OpenID  string `json:"open_id,omitempty"`
	Email   string `json:"email,omitempty"`
	UserID  string `json:"user_id,omitempty"`
	ChatID  string `json:"chat_id,omitempty"`
	UnionID string `json:"-"`
	// For reply
	RootID        string `json:"root_id,omitempty"`
	ReplyInThread bool   `json:"reply_in_thread,omitempty"`
	// Sign for notification bot
	Sign string `json:"sign"`
	// Timestamp for sign
	Timestamp int64 `json:"timestamp"`
	// UUID for idempotency
	UUID string `json:"uuid"`
}

OutcomingMessage struct of an outcoming message

type PinMessageResponse added in v1.8.0

type PinMessageResponse struct {
	BaseResponse
	Data struct {
		Pin struct {
			MessageID      string `json:"message_id"`
			ChatID         string `json:"chat_id"`
			OperatorID     string `json:"operator_id"`
			OperatorIDType string `json:"operator_id_type"`
			CreateTime     string `json:"create_time"`
		} `json:"pin"`
	} `json:"data"`
}

PinMessageResponse .

type PostBody

type PostBody struct {
	Title   string       `json:"title"`
	Content [][]PostElem `json:"content"`
}

PostBody .

type PostBuf added in v1.1.0

type PostBuf struct {
	Title   string     `json:"title"`
	Content []PostElem `json:"content"`
}

PostBuf .

type PostContent

type PostContent map[string]PostBody

PostContent .

type PostElem

type PostElem struct {
	Tag string `json:"tag"`
	// For Text
	UnEscape *bool   `json:"un_escape,omitempty"`
	Text     *string `json:"text,omitempty"`
	Lines    *int    `json:"lines,omitempty"`
	// For Link
	Href *string `json:"href,omitempty"`
	// For At
	UserID *string `json:"user_id,omitempty"`
	// For Image
	ImageKey    *string `json:"image_key,omitempty"`
	ImageWidth  *int    `json:"width,omitempty"`
	ImageHeight *int    `json:"height,omitempty"`
}

PostElem .

type PostEphemeralMessageResponse added in v1.6.0

type PostEphemeralMessageResponse struct {
	BaseResponse
	Data struct {
		MessageID string `json:"message_id"`
	} `json:"data"`
}

PostEphemeralMessageResponse .

type PostMessageResponse

type PostMessageResponse struct {
	BaseResponse

	Data IMMessage `json:"data"`
}

PostMessageResponse .

type PostNotificationResp

type PostNotificationResp struct {
	Ok bool `json:"ok,omitempty"`
}

PostNotificationResp response of PostNotification

type PostNotificationV2Resp

type PostNotificationV2Resp struct {
	BaseResponse
	StatusCode    int    `json:"StatusCode"`
	StatusMessage string `json:"StatusMessage"`
}

PostNotificationV2Resp response of PostNotificationV2

type ReactionResponse added in v1.11.0

type ReactionResponse struct {
	BaseResponse
	Data struct {
		ReactionID string `json:"reaction_id"`
		Operator   struct {
			OperatorID   string `json:"operator_id"`
			OperatorType string `json:"operator_type"`
			ActionTime   string `json:"action_time"`
		} `json:"operator"`
		ReactionType struct {
			EmojiType EmojiType `json:"emoji_type"`
		} `json:"reaction_type"`
	} `json:"data"`
}

ReactionResponse .

type RecallMessageResponse

type RecallMessageResponse = BaseResponse

RecallMessageResponse .

type RemoveBotFromGroupResponse

type RemoveBotFromGroupResponse = BaseResponse

RemoveBotFromGroupResponse .

type RemoveChatMemberRequest added in v1.7.0

type RemoveChatMemberRequest struct {
	IDList []string `json:"id_list"`
}

RemoveChatMemberRequest .

type RemoveChatMemberResponse added in v1.7.0

type RemoveChatMemberResponse struct {
	BaseResponse

	Data struct {
		InvalidIDList []string `json:"invalid_id_list"`
	} `json:"data"`
}

RemoveChatMemberResponse .

type SetTopNoticeRequest added in v1.8.0

type SetTopNoticeRequest struct {
	ChatTopNotice []ChatTopNoticeAction `json:"chat_top_notice"`
}

SetTopNoticeRequest .

type SetTopNoticeResponse added in v1.8.0

type SetTopNoticeResponse = BaseResponse

SetTopNoticeResponse .

type ShareChatContent added in v1.7.0

type ShareChatContent struct {
	ChatID string `json:"chat_id"`
}

ShareChatContent .

type ShareUserContent added in v1.7.0

type ShareUserContent struct {
	UserID string `json:"user_id"`
}

ShareUserContent .

type StickerContent added in v1.7.0

type StickerContent struct {
	FileKey string `json:"file_key"`
}

StickerContent .

type TenantAuthTokenInternalResponse

type TenantAuthTokenInternalResponse struct {
	BaseResponse
	TenantAppAccessToken string `json:"tenant_access_token"`
	Expire               int    `json:"expire"`
}

TenantAuthTokenInternalResponse .

type TextContent added in v1.7.0

type TextContent struct {
	Text string `json:"text"`
}

TextContent .

type UnpinMessageResponse added in v1.8.0

type UnpinMessageResponse = BaseResponse

UnpinMessageResponse .

type UpdateChatRequest added in v1.7.0

type UpdateChatRequest struct {
	Name                   string    `json:"name,omitempty"`
	Avatar                 string    `json:"avatar,omitempty"`
	Description            string    `json:"description,omitempty"`
	I18NNames              I18NNames `json:"i18n_names,omitempty"`
	AddMemberPermission    string    `json:"add_member_permission,omitempty"`
	ShareCardPermission    string    `json:"share_card_permission,omitempty"`
	AtAllPermission        string    `json:"at_all_permission,omitempty"`
	EditPermission         string    `json:"edit_permission,omitempty"`
	OwnerID                string    `json:"owner_id,omitempty"`
	JoinMessageVisibility  string    `json:"join_message_visibility,omitempty"`
	LeaveMessageVisibility string    `json:"leave_message_visibility,omitempty"`
	MembershipApproval     string    `json:"membership_approval,omitempty"`
}

UpdateChatRequest .

type UpdateChatResponse added in v1.7.0

type UpdateChatResponse struct {
	BaseResponse
}

UpdateChatResponse .

type UpdateGroupInfoReq

type UpdateGroupInfoReq struct {
	OpenChatID      string            `json:"open_chat_id"`
	OwnerID         string            `json:"owner_id,omitempty"`
	OwnerEmployeeID string            `json:"owner_employee_id,omitempty"`
	Name            string            `json:"name,omitempty"`
	I18nNames       map[string]string `json:"i18n_names,omitempty"`
}

UpdateGroupInfoReq .

type UpdateGroupInfoResponse

type UpdateGroupInfoResponse struct {
	BaseResponse
	OpenChatID string `json:"open_chat_id"`
}

UpdateGroupInfoResponse .

type UpdateMessageResponse added in v1.7.0

type UpdateMessageResponse = BaseResponse

UpdateMessageResponse .

type UploadFileRequest added in v1.7.0

type UploadFileRequest struct {
	FileType string    `json:"-"`
	FileName string    `json:"-"`
	Duration int       `json:"-"`
	Path     string    `json:"-"`
	Reader   io.Reader `json:"-"`
}

UploadFileRequest .

type UploadFileResponse added in v1.7.0

type UploadFileResponse struct {
	BaseResponse
	Data struct {
		FileKey string `json:"file_key"`
	} `json:"data"`
}

UploadFileResponse .

type UploadImageResponse

type UploadImageResponse struct {
	BaseResponse
	Data struct {
		ImageKey string `json:"image_key"`
	} `json:"data"`
}

UploadImageResponse .

type UserAvatar added in v1.13.0

type UserAvatar struct {
	Avatar72     string `json:"avatar_72,omitempty"`
	Avatar240    string `json:"avatar_240,omitempty"`
	Avatar640    string `json:"avatar_640,omitempty"`
	AvatarOrigin string `json:"avatar_origin,omitempty"`
}

UserAvatar .

type UserInfo added in v1.13.0

type UserInfo struct {
	OpenID          string     `json:"open_id,omitempty"`
	Email           string     `json:"email,omitempty"`
	UserID          string     `json:"user_id,omitempty"`
	ChatID          string     `json:"chat_id,omitempty"`
	UnionID         string     `json:"union_id,omitempty"`
	Name            string     `json:"name,omitempty"`
	EnglishName     string     `json:"en_name,omitempty"`
	NickName        string     `json:"nickname,omitempty"`
	Mobile          string     `json:"mobile,omitempty"`
	MobileVisible   bool       `json:"mobile_visible,omitempty"`
	Gender          int        `json:"gender,omitempty"`
	Avatar          UserAvatar `json:"avatar,omitempty"`
	Status          UserStatus `json:"status,omitempty"`
	City            string     `json:"city,omitempty"`
	Country         string     `json:"country,omitempty"`
	WorkStation     string     `json:"work_station,omitempty"`
	JoinTime        int        `json:"join_time,omitempty"`
	EmployeeNo      string     `json:"employee_no,omitempty"`
	EmployeeType    int        `json:"employee_type,omitempty"`
	EnterpriseEmail string     `json:"enterprise_email,omitempty"`
	Geo             string     `json:"geo,omitempty"`
	JobTitle        string     `json:"job_title,omitempty"`
	JobLevelID      string     `json:"job_level_id,omitempty"`
	JobFamilyID     string     `json:"job_family_id,omitempty"`
	DepartmentIDs   []string   `json:"department_ids,omitempty"`
	LeaderUserID    string     `json:"leader_user_id,omitempty"`
	IsTenantManager bool       `json:"is_tenant_manager,omitempty"`
}

UserInfo .

type UserStatus added in v1.13.0

type UserStatus struct {
	IsFrozen    bool
	IsResigned  bool
	IsActivated bool
	IsExited    bool
	IsUnjoin    bool
}

UserStatus .

Directories

Path Synopsis
Package card provides declarative card builder
Package card provides declarative card builder
i18n
Package i18n internationalization support for card
Package i18n internationalization support for card

Jump to

Keyboard shortcuts

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