Documentation
¶
Index ¶
- Constants
- Variables
- func BuildOutcomingMessageReq(om OutcomingMessage) map[string]interface{}
- func Decrypt(encryptedKey []byte, data string) ([]byte, error)
- func DownloadFile(path, url string) error
- func EncryptKey(key string) []byte
- func PostEvent(client *http.Client, hookURL string, message EventMessage) (*http.Response, error)
- type AddBotToGroupResponse
- type AddChatMemberRequest
- type AddChatMemberResponse
- type AddGroupMemberResponse
- type AudioContent
- type AuthTokenInternalResponse
- type BaseResponse
- type Bot
- func (bot Bot) AccessToken() string
- func (bot *Bot) AddBotToGroup(openChatID string) (*AddBotToGroupResponse, error)
- func (bot Bot) AddChatMember(chatID string, idList []string) (*AddChatMemberResponse, error)
- func (bot *Bot) AddGroupMember(openChatID string, openID []string) (*AddGroupMemberResponse, error)
- func (bot *Bot) AddGroupMemberByUserID(openChatID string, userID []string) (*AddGroupMemberResponse, error)
- func (bot Bot) AppID() string
- func (bot Bot) BotType() int
- func (bot Bot) CreateChat(req CreateChatRequest) (*CreateChatResponse, error)
- func (bot *Bot) CreateGroup(name, description string, openID []string) (*CreateGroupResponse, error)
- func (bot Bot) DeleteAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error
- func (bot Bot) DeleteChat(chatID string) (*DeleteChatResponse, error)
- func (bot Bot) DeleteEphemeralMessage(messageID string) (*DeleteEphemeralMessageResponse, error)
- func (bot *Bot) DeleteGroupMember(openChatID string, openID []string) (*DeleteGroupMemberResponse, error)
- func (bot *Bot) DisbandGroup(openChatID string) (*DisbandGroupResponse, error)
- func (bot Bot) DoAPIRequest(method string, prefix, urlPath string, header http.Header, auth bool, ...) error
- func (bot Bot) Domain() string
- func (bot Bot) ExpandURL(urlPath string) string
- func (bot Bot) GetAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error
- func (bot *Bot) GetAccessTokenInternal(updateToken bool) (*AuthTokenInternalResponse, error)
- func (bot *Bot) GetBotInfo() (*GetBotInfoResponse, error)
- func (bot Bot) GetChat(chatID string) (*GetChatResponse, error)
- func (bot Bot) GetChatMembers(chatID string, pageToken string, pageSize int) (*GetChatMembersResponse, error)
- func (bot *Bot) GetGroupInfo(openChatID string) (*GroupInfoResponse, error)
- func (bot *Bot) GetGroupList(pageNum, pageSize int) (*GroupListResponse, error)
- func (bot Bot) GetMessage(messageID string) (*GetMessageResponse, error)
- func (bot *Bot) GetTenantAccessTokenInternal(updateToken bool) (*TenantAuthTokenInternalResponse, error)
- func (bot Bot) IsInChat(chatID string) (*IsInChatResponse, error)
- func (bot Bot) JoinChat(chatID string) (*JoinChatResponse, error)
- func (bot Bot) Logger() LogWrapper
- func (bot Bot) MessageReadReceipt(messageID string) (*MessageReceiptResponse, error)
- func (bot Bot) PatchAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error
- func (bot Bot) PostAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error
- func (bot Bot) PostEphemeralMessage(om OutcomingMessage) (*PostEphemeralMessageResponse, error)
- func (bot Bot) PostImage(imageKey string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostMessage(om OutcomingMessage) (*PostMessageResponse, error)
- func (bot *Bot) PostNotification(title, text string) (*PostNotificationResp, error)
- func (bot *Bot) PostNotificationV2(om OutcomingMessage) (*PostNotificationV2Resp, error)
- func (bot Bot) PostRichText(postContent *PostContent, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostShareChat(chatID string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostShareUser(openID string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostText(text string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostTextMention(text string, atUserID string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostTextMentionAll(text string, userID *OptionalUserID) (*PostMessageResponse, error)
- func (bot Bot) PostTextMentionAndReply(text string, atUserID string, userID *OptionalUserID, replyID string) (*PostMessageResponse, error)
- func (bot Bot) PutAPIRequest(prefix, urlPath string, auth bool, params interface{}, output interface{}) error
- func (bot Bot) RecallMessage(messageID string) (*RecallMessageResponse, error)
- func (bot *Bot) RemoveBotFromGroup(openChatID string) (*RemoveBotFromGroupResponse, error)
- func (bot Bot) RemoveChatMember(chatID string, idList []string) (*RemoveChatMemberResponse, error)
- func (bot Bot) ReplyMessage(om OutcomingMessage) (*PostMessageResponse, error)
- func (bot *Bot) SetClient(c *http.Client)
- func (bot *Bot) SetCustomClient(c HTTPWrapper)
- func (bot *Bot) SetDomain(domain string)
- func (bot *Bot) SetLogger(logger LogWrapper)
- func (bot *Bot) StartHeartbeat()
- func (bot *Bot) StopHeartbeat()
- func (bot Bot) TenantAccessToken() string
- func (bot *Bot) UnsetCustomClient()
- func (bot Bot) UpdateChat(chatID string, req UpdateChatRequest) (*UpdateChatResponse, error)
- func (bot *Bot) UpdateGroupInfo(params *UpdateGroupInfoReq) (*UpdateGroupInfoResponse, error)
- func (bot Bot) UpdateMessage(messageID string, om OutcomingMessage) (*UpdateMessageResponse, error)
- func (bot Bot) UploadFile(req UploadFileRequest) (*UploadFileResponse, error)
- func (bot Bot) UploadImage(path string) (*UploadImageResponse, error)
- func (bot Bot) UploadImageObject(img image.Image) (*UploadImageResponse, error)
- func (bot *Bot) WithContext(ctx context.Context) *Bot
- func (bot *Bot) WithUserIDType(userIDType string) *Bot
- type CardBlock
- type CardBuilder
- type CardContent
- type ChatInfo
- type ChatMember
- type CreateChatRequest
- type CreateChatResponse
- type CreateGroupResponse
- type DeleteChatResponse
- type DeleteEphemeralMessageResponse
- type DeleteGroupMemberResponse
- type DisbandGroupResponse
- type EncryptedReq
- type EventBody
- type EventChallengeReq
- type EventMessage
- type EventV2
- type EventV2ChatDisbanded
- type EventV2Header
- type EventV2MessageReceived
- type EventV2UserID
- type FileContent
- type GetBotInfoResponse
- type GetChatMembersResponse
- type GetChatResponse
- type GetMessageResponse
- type GroupInfoResponse
- type GroupListResponse
- type HTTPWrapper
- type I18NNames
- type IMBody
- type IMMention
- type IMMessage
- type IMMessageRequest
- type IMSendor
- type ImageContent
- type IsInChatResponse
- type JoinChatResponse
- type LogLevel
- type LogWrapper
- type MediaContent
- type MessageContent
- type MessageReceiptResponse
- type MsgBuffer
- func (m *MsgBuffer) Audio(fileKey string) *MsgBuffer
- func (m *MsgBuffer) BindChatID(chatID string) *MsgBuffer
- func (m *MsgBuffer) BindEmail(email string) *MsgBuffer
- func (m *MsgBuffer) BindOpenChatID(openChatID string) *MsgBuffer
- func (m *MsgBuffer) BindOpenID(openID string) *MsgBuffer
- func (m *MsgBuffer) BindReply(rootID string) *MsgBuffer
- func (m *MsgBuffer) BindUnionID(unionID string) *MsgBuffer
- func (m *MsgBuffer) BindUserID(userID string) *MsgBuffer
- func (m *MsgBuffer) Build() OutcomingMessage
- func (m *MsgBuffer) Card(cardContent string) *MsgBuffer
- func (m *MsgBuffer) Clear() *MsgBuffer
- func (m *MsgBuffer) Error() error
- func (m *MsgBuffer) File(fileKey string) *MsgBuffer
- func (m *MsgBuffer) Image(imageKey string) *MsgBuffer
- func (m *MsgBuffer) Media(fileKey, imageKey string) *MsgBuffer
- func (m *MsgBuffer) Post(postContent *PostContent) *MsgBuffer
- func (m *MsgBuffer) ShareChat(chatID string) *MsgBuffer
- func (m *MsgBuffer) ShareUser(userID string) *MsgBuffer
- func (m *MsgBuffer) Sticker(fileKey string) *MsgBuffer
- func (m *MsgBuffer) Text(text string) *MsgBuffer
- func (m *MsgBuffer) UpdateMulti(flag bool) *MsgBuffer
- type MsgPostBuilder
- func (pb *MsgPostBuilder) AtTag(text, userID string) *MsgPostBuilder
- func (pb *MsgPostBuilder) Clear()
- func (pb *MsgPostBuilder) CurLocale() *PostBuf
- func (pb *MsgPostBuilder) ImageTag(imageKey string, imageWidth, imageHeight int) *MsgPostBuilder
- func (pb MsgPostBuilder) Len() int
- func (pb *MsgPostBuilder) LinkTag(text, href string) *MsgPostBuilder
- func (pb *MsgPostBuilder) Locale(locale string) *MsgPostBuilder
- func (pb *MsgPostBuilder) Render() *PostContent
- func (pb *MsgPostBuilder) TextTag(text string, lines int, unescape bool) *MsgPostBuilder
- func (pb *MsgPostBuilder) Title(title string) *MsgPostBuilder
- func (pb *MsgPostBuilder) WithLocale(locale string) *MsgPostBuilder
- type MsgTextBuilder
- func (tb *MsgTextBuilder) Clear()
- func (tb MsgTextBuilder) Len() int
- func (tb *MsgTextBuilder) Mention(userID string) *MsgTextBuilder
- func (tb *MsgTextBuilder) MentionAll() *MsgTextBuilder
- func (tb *MsgTextBuilder) Render() string
- func (tb *MsgTextBuilder) Text(text ...interface{}) *MsgTextBuilder
- func (tb *MsgTextBuilder) Textf(textFmt string, text ...interface{}) *MsgTextBuilder
- func (tb *MsgTextBuilder) Textln(text ...interface{}) *MsgTextBuilder
- type OptionalUserID
- type OutcomingMessage
- type PostBody
- type PostBuf
- type PostContent
- type PostElem
- type PostEphemeralMessageResponse
- type PostMessageResponse
- type PostNotificationResp
- type PostNotificationV2Resp
- type RecallMessageResponse
- type RemoveBotFromGroupResponse
- type RemoveChatMemberRequest
- type RemoveChatMemberResponse
- type ShareChatContent
- type ShareUserContent
- type StickerContent
- type TenantAuthTokenInternalResponse
- type TextContent
- type UpdateChatRequest
- type UpdateChatResponse
- type UpdateGroupInfoReq
- type UpdateGroupInfoResponse
- type UpdateMessageResponse
- type UploadFileRequest
- type UploadFileResponse
- type UploadImageResponse
Constants ¶
const ( EventTypeMessageReceived = "im.message.receive_v1" EventTypeChatDisbanded = "im.chat.disbanded_v1" // not supported yet EventTypeMessageRead = "im.message.message_read_v1" EventTypeChatUpdated = "im.chat.updated_v1" EventTypeBotAdded = "im.chat.member.bot.added_v1" EventTypeBotDeleted = "im.chat.member.bot.deleted_v1" EventTypeUserAdded = "im.chat.member.user.added_v1" EventTypeUserWithdrawn = "im.chat.member.user.withdrawn_v1" EventTypeUserDeleted = "im.chat.member.user.deleted_v1" )
EventType definitions
const ( // ChatBot should call 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 )
const ( DomainFeishu = "https://open.feishu.cn" DomainLark = "https://open.larksuite.com" )
Domains
const ( LocaleZhCN = "zh_cn" LocaleEnUS = "en_us" LocaleJaJP = "ja_jp" )
Supported Lark locales
const ( LogLevelTrace = iota + 1 LogLevelDebug LogLevelInfo LogLevelWarn LogLevelError )
LogLevels
const ( MsgText = "text" MsgPost = "post" MsgInteractive = "interactive" MsgImage = "image" MsgAudio = "audio" MsgMedia = "media" MsgFile = "file" MsgSticker = "sticker" )
Msg Types
const ( UIDEmail = "email" UIDUserID = "user_id" UIDOpenID = "open_id" UIDChatID = "chat_id" UIDUnionID = "union_id" )
UID types
const (
// EventGetMessage .
EventGetMessage = 1
)
See https://open.feishu.cn/document/uYjL24iN/uUTNz4SN1MjL1UzM
Variables ¶
var ( ErrBotTypeError = errors.New("Bot type error") ErrParamUserID = errors.New("Param error: UserID") ErrParamMessageID = errors.New("Param error: Message ID") 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 DownloadFile ¶
DownloadFile downloads from a URL to local path
Types ¶
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
BaseResponse of an API
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot definition
func (Bot) AccessToken ¶
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) 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) 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) 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 posts message with im/v1
func (*Bot) GetTenantAccessTokenInternal ¶
func (bot *Bot) GetTenantAccessTokenInternal(updateToken bool) (*TenantAuthTokenInternalResponse, error)
GetTenantAccessTokenInternal gets AppAccessToken for internal use
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) 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) 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 message
func (*Bot) PostNotification ¶
func (bot *Bot) PostNotification(title, text string) (*PostNotificationResp, error)
PostNotification send message to a webhook
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 messages
func (*Bot) SetCustomClient ¶ added in v1.2.0
func (bot *Bot) SetCustomClient(c HTTPWrapper)
SetCustomClient .
func (*Bot) SetDomain ¶
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) StartHeartbeat ¶
func (bot *Bot) StartHeartbeat()
StartHeartbeat renew auth token periodically
func (Bot) TenantAccessToken ¶
TenantAccessToken returns bot.tenantAccessToken for external use
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 update message card
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
WithContext .
func (*Bot) WithUserIDType ¶ added in v1.7.0
WithUserIDType .
type CardBuilder ¶ added in v1.5.0
type CardBuilder interface { Card(elements ...card.Element) *CardBlock Action(actions ...card.Element) *card.ActionBlock Button(text *card.TextBlock) *card.ButtonBlock Confirm(title, text string) *card.ConfirmBlock DatePicker() *card.DatePickerBlock TimePicker() *card.TimePickerBlock DatetimePicker() *card.DatetimePickerBlock Div(fields ...*card.FieldBlock) *card.DivBlock Field(text *card.TextBlock) *card.FieldBlock Hr() *card.HrBlock Img(key string) *card.ImgBlock Note() *card.NoteBlock Option(value string) *card.OptionBlock Overflow(options ...*card.OptionBlock) *card.OverflowBlock SelectMenu(options ...*card.OptionBlock) *card.SelectMenuBlock Text(s string) *card.TextBlock Markdown(s string) *card.MarkdownBlock URL() *card.URLBlock }
CardBuilder 卡片构造方法
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"` 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 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 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 EncryptedReq ¶
type EncryptedReq struct {
Encrypt string `json:"encrypt,omitempty"`
}
EncryptedReq request of encrypted challagen
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 EventChallengeReq ¶
type EventChallengeReq struct { Token string `json:"token,omitempty"` Challenge string `json:"challenge,omitempty"` Type string `json:"type,omitempty"` }
EventChallengeReq request of add event hook
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) GetMessageReceived ¶ added in v1.7.0
func (e EventV2) GetMessageReceived() (*EventV2MessageReceived, error)
GetMessageReceived .
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 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 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 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 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 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"` 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"` Sendor IMSendor Mentions []IMMention Body IMBody }
IMMessage .
type IMMessageRequest ¶ added in v1.7.0
type IMMessageRequest struct { ReceiveID string `json:"receive_id"` Content string `json:"content"` MsgType string `json:"msg_type"` }
IMMessageRequest .
func BuildMessage ¶ added in v1.7.0
func BuildMessage(om OutcomingMessage) (*IMMessageRequest, error)
BuildMessage .
type IMSendor ¶ added in v1.7.0
type IMSendor struct { ID string `json:"id"` IDType string `json:"id_type"` SendorType string `json:"sendor_type"` TenantKey string `json:"tenant_key"` }
IMSendor .
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 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"` 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 ¶
NewMsgBuffer create a message buffer
func (*MsgBuffer) BindChatID ¶
BindChatID binds chat_id
func (*MsgBuffer) BindOpenChatID ¶
BindOpenChatID binds open_chat_id
func (*MsgBuffer) BindOpenID ¶
BindOpenID binds open_id
func (*MsgBuffer) BindReply ¶
BindReply binds root id for reply rootID is OpenMessageID of the message you reply
func (*MsgBuffer) BindUnionID ¶ added in v1.7.0
BindUnionID binds union_id
func (*MsgBuffer) BindUserID ¶
BindUserID binds open_id
func (*MsgBuffer) Build ¶
func (m *MsgBuffer) Build() OutcomingMessage
Build message and return message body
func (*MsgBuffer) Post ¶
func (m *MsgBuffer) Post(postContent *PostContent) *MsgBuffer
Post sets raw post content
func (*MsgBuffer) UpdateMulti ¶
UpdateMulti deprecated in the latest version, please use card.UpdateMulti instead set multi for shared card. Default false, not share
type MsgPostBuilder ¶
type MsgPostBuilder struct {
// contains filtered or unexported fields
}
MsgPostBuilder for build text buf
func (*MsgPostBuilder) AtTag ¶
func (pb *MsgPostBuilder) AtTag(text, userID string) *MsgPostBuilder
AtTag creates an at tag
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) 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) 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 (*MsgTextBuilder) Mention ¶
func (tb *MsgTextBuilder) Mention(userID string) *MsgTextBuilder
Mention @somebody
func (*MsgTextBuilder) MentionAll ¶
func (tb *MsgTextBuilder) MentionAll() *MsgTextBuilder
MentionAll @all
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 ¶
OptionalUserID to contain openID, chatID, userID, email
func WithUnionID ¶ added in v1.7.0
func WithUnionID(unionID string) *OptionalUserID
WithUnionID uses chatID 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"` // UpdateMulti card UpdateMulti bool `json:"update_multi"` }
OutcomingMessage struct of an outcoming message
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 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 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 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"` 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:"-"` }
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 .
Source Files
¶
- api.go
- api_auth.go
- api_bot.go
- api_chat.go
- api_group.go
- api_message.go
- api_notification.go
- api_upload.go
- crypto.go
- error.go
- event.go
- event_v2.go
- http.go
- http_wrapper.go
- lark.go
- locale.go
- logger.go
- message.go
- message_v1.go
- message_v2.go
- msg_buf.go
- msg_card_builder.go
- msg_post_builder.go
- msg_text_builder.go
- user.go
- util.go