bot

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TenantAccessTokenURL = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
)

APIPath

Functions

func GetTenantAccessToken

func GetTenantAccessToken(ctx context.Context, conf *config.MRChLogConfig) (string, error)

GetTenantAccessToken get tenant access token for app Refer to: https://open.feishu.cn/document/ukTMukTMukTM/ukDNz4SO0MjL5QzM/auth-v3/auth/tenant_access_token_internal

func SendAlertMessage

func SendAlertMessage(ctx context.Context, token, chatID string, title, text string) error

Types

type CardActionBlock

type CardActionBlock struct {
	Tag     string        `json:"tag,omitempty"`
	Layout  string        `json:"layout,omitempty"`
	Actions []interface{} `json:"actions,omitempty"`
}

type CardButton

type CardButton struct {
	Tag     string            `json:"tag,omitempty"`  // 类型 button
	Text    *CardText         `json:"text,omitempty"` // 按钮描述
	Type    string            `json:"type,omitempty"` // 按钮类型 primary default danger
	Value   map[string]string `json:"value,omitempty"`
	Confirm *CardConfirm      `json:"confirm,omitempty"`
}

type CardConfig

type CardConfig struct {
	WideScreenMode bool `json:"wide_screen_mode,omitempty"`
	EnableForward  bool `json:"enable_forward,omitempty"`
}

type CardConfirm

type CardConfirm struct {
	Title *CardText `json:"title,omitempty"`
	Text  *CardText `json:"text,omitempty"`
}

type CardContent

type CardContent struct {
	Config   *CardConfig    `json:"config,omitempty"`
	Header   *CardHeader    `json:"header,omitempty"`
	Elements []*CardElement `json:"elements,omitempty"`
}

Message card

type CardElement

type CardElement struct {
	Tag          string       `json:"tag"`
	Text         *CardText    `json:"text,omitempty"`
	Fields       []*CardField `json:"fields,omitempty"`
	ImgKey       string       `json:"img_key,omitempty"`
	Mode         string       `json:"mode,omitempty"`
	Alt          *CardText    `json:"alt,omitempty"`
	CustomWidth  int          `json:"custom_width,omitempty"`
	CompactWidth int          `json:"compact_width,omitempty"`
	Preview      bool         `json:"preview,omitempty"`
	Title        *CardText    `json:"title,omitempty"`
}

type CardField

type CardField struct {
	IsShort bool      `json:"is_short,omitempty"` // 是否是短信息
	Text    *CardText `json:"text,omitempty"`
}

type CardHeader

type CardHeader struct {
	Title    *CardText `json:"title,omitempty"`
	Template string    `json:"template,omitempty"`
}

type CardNote

type CardNote struct {
	Tag      string        `json:"tag,omitempty"`
	Elements []interface{} `json:"elements,omitempty"`
}

type CardOption

type CardOption struct {
	Text     *CardText `json:"text,omitempty"`
	Value    string    `json:"value"`
	URL      string    `json:"url,omitempty"`
	MultiURL *CardURL  `json:"multi_url,omitempty"`
}

type CardSelectMenu

type CardSelectMenu struct {
	Tag           string            `json:"tag"`
	PlaceHolder   *CardText         `json:"placeholder,omitempty"`
	InitialOption string            `json:"initial_option,omitempty"`
	Options       []*CardOption     `json:"options,omitempty"`
	Value         map[string]string `json:"value,omitempty"`
	Confirm       []*CardConfirm    `json:"confirm,omitempty"`
}

type CardSplitLine

type CardSplitLine struct {
	Tag string `json:"tag"`
}

type CardText

type CardText struct {
	Tag     string `json:"tag,omitempty"`     // 文本类型  lark_md plain_text
	Content string `json:"content,omitempty"` // 具体参见文档: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-card/overview#39ee4e65
	Lines   int    `json:"lines,omitempty"`   // 行数
}

type CardURL

type CardURL struct {
	URL        string `json:"url"`
	AndroidURL string `json:"android_url"`
	IosURL     string `json:"ios_url"`
	PcURL      string `json:"pc_url"`
}

type ChatMembersInviteRequest

type ChatMembersInviteRequest struct {
	IdList []string `json:"id_list,omitempty"`
}

type ChatMembersInviteRespBody

type ChatMembersInviteRespBody struct {
	InvalidIDList []string `json:"invalid_id_list"`
}

type ChatMembersInviteResponse

type ChatMembersInviteResponse struct {
	Code    int                        `json:"code"`
	Message string                     `json:"message"`
	Data    *ChatMembersInviteRespBody `json:"data"`
}

type CreateChatRequest

type CreateChatRequest struct {
	Avatar                 string     `json:"avatar,omitempty"`
	Name                   string     `json:"name,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"`
	External               bool       `json:"external,omitempty"`
	JoinMessageVisibility  string     `json:"join_message_visibility,omitempty"`
	LeaveMessageVisibility string     `json:"leave_message_visibility,omitempty"`
	MembershipApproval     string     `json:"membership_approval,omitempty"`
}

type CreateChatRespBody

type CreateChatRespBody struct {
	ChatId                 string     `json:"chat_id,omitempty"`
	Avatar                 string     `json:"avatar,omitempty"`
	Name                   string     `json:"name,omitempty"`
	Description            string     `json:"description,omitempty"`
	I18nNames              *I18nNames `json:"i18n_names,omitempty"`
	OwnerId                string     `json:"owner_id,omitempty"`
	OwnerIdType            string     `json:"owner_id_type,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"`
	ChatMode               string     `json:"chat_mode,omitempty"`
	ChatType               string     `json:"chat_type,omitempty"`
	ChatTag                string     `json:"chat_tag,omitempty"`
	External               bool       `json:"external,omitempty"`
	TenantKey              string     `json:"tenant_key,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"`
}

type CreateChatResponse

type CreateChatResponse struct {
	Code    int                 `json:"code"`
	Message string              `json:"message"`
	Data    *CreateChatRespBody `json:"data"`
}

type CreateMessageRequest

type CreateMessageRequest struct {
	ReceiveID string `json:"receive_id"`
	Content   string `json:"content"`
	MsgType   string `json:"msg_type"`
}

type CreateMessageResponse

type CreateMessageResponse struct {
	Code    int          `json:"code"`
	Message string       `json:"message"`
	Data    *MessageItem `json:"data"`
}

type DecryptToken

type DecryptToken struct {
	Challenge string `json:"challenge"`
	Token     string `json:"token"`
	Type      string `json:"type"`
}

type Event

type Event struct {
	Schema string      `json:"schema"`
	Header Header      `json:"header"`
	Event  interface{} `json:"event"`
}

type GetChatInfoResponse

type GetChatInfoResponse struct {
	Code    int                      `json:"code"`
	Message string                   `json:"message"`
	Data    *GetChatInfoResponseBody `json:"data"`
}

type GetChatInfoResponseBody

type GetChatInfoResponseBody struct {
	Avatar                 string     `json:"avatar,omitempty"`
	Name                   string     `json:"name,omitempty"`
	Description            string     `json:"description,omitempty"`
	I18nNames              *I18nNames `json:"i18n_names,omitempty"`
	OwnerId                string     `json:"owner_id,omitempty"`
	OwnerIdType            string     `json:"owner_id_type,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"`
	ChatMode               string     `json:"chat_mode,omitempty"`
	ChatType               string     `json:"chat_type,omitempty"`
	ChatTag                string     `json:"chat_tag,omitempty"`
	External               bool       `json:"external,omitempty"`
	TenantKey              string     `json:"tenant_key,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"`
}

type GetMessageHistoryBody

type GetMessageHistoryBody struct {
	HasMore   bool                            `json:"has_more"`
	PageToken string                          `json:"page_token,omitempty"`
	Items     []*GetMessageHistoryMessageItem `json:"items,omitempty"`
}

type GetMessageHistoryMessageItem

type GetMessageHistoryMessageItem struct {
	MessageID      string         `json:"message_id,omitempty"`
	RootID         string         `json:"root_id,omitempty"`
	ParentID       string         `json:"parent_id,omitempty"`
	MsgType        string         `json:"msg_type,omitempty"`
	CreateTime     string         `json:"create_time,omitempty"`
	UpdateTime     string         `json:"update_time,omitempty"`
	Deleted        bool           `json:"deleted,omitempty"`
	ChatID         string         `json:"chat_id,omitempty"`
	Sender         *MessageSender `json:"sender,omitempty"`
	Body           *MessageBody   `json:"body,omitempty"`
	Mentions       []*MentionV1   `json:"mentions,omitempty"`
	UpperMessageID string         `json:"upper_message_id,omitempty"`
}

type GetMessageHistoryResponse

type GetMessageHistoryResponse struct {
	Code    int                    `json:"code"`
	Message string                 `json:"message"`
	Data    *GetMessageHistoryBody `json:"data"`
}
type Header struct {
	EventID    string `json:"event_id"`
	EventType  string `json:"event_type"`
	CreateTime string `json:"create_time"`
	Token      string `json:"token"`
	AppID      string `json:"app_id"`
	TenantKey  string `json:"tenant_key"`
}

General Model

type I18nNames

type I18nNames struct {
	ZhCn string `json:"zh_cn,omitempty"`
	EnUs string `json:"en_us,omitempty"`
	JaJp string `json:"ja_jp,omitempty"`
}

type Mention

type Mention struct {
	Key       string  `json:"key,omitempty"`
	ID        *UserID `json:"id,omitempty"`
	Name      string  `json:"name,omitempty"`
	TenantKey string  `json:"tenant_key,omitempty"`
}

type MentionV1

type MentionV1 struct {
	Key       string `json:"key,omitempty"`
	ID        string `json:"id,omitempty"`
	IDType    string `json:"id_type,omitempty"`
	Name      string `json:"name,omitempty"`
	TenantKey string `json:"tenant_key,omitempty"`
}

type Message

type Message struct {
	MessageID   string     `json:"message_id"`
	RootID      string     `json:"root_id"`
	ParentID    string     `json:"parent_id"`
	CreateTime  string     `json:"create_time"`
	ChatID      string     `json:"chat_id"`
	ChatType    string     `json:"chat_type"`
	MessageType string     `json:"message_type"`
	Content     string     `json:"content"`
	Mentions    []*Mention `json:"mentions,omitempty"`
}

type MessageBody

type MessageBody struct {
	Content string `json:"content,omitempty"`
}

type MessageEvent

type MessageEvent struct {
	Sender  Sender  `json:"sender"`
	Message Message `json:"message"`
}

type MessageItem

type MessageItem struct {
	MessageID  string         `json:"message_id,omitempty"`
	RootID     string         `json:"root_id,omitempty"`
	ParentID   string         `json:"parent_id,omitempty"`
	MsgType    string         `json:"msg_type,omitempty"`
	CreateTime string         `json:"create_time,omitempty"`
	UpdateTime string         `json:"update_time,omitempty"`
	Deleted    bool           `json:"deleted,omitempty"`
	ChatID     string         `json:"chat_id,omitempty"`
	Sender     *MessageSender `json:"sender,omitempty"`
	Body       *MessageBody   `json:"body,omitempty"`
}

type MessageSender

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

type PinMessageRequest

type PinMessageRequest struct {
	MessageID string `json:"message_id"`
}

type PinMessageResponse

type PinMessageResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Pin *MessageItem `json:"pin"`
	} `json:"data"`
}

type ReceiveEventEncrypt

type ReceiveEventEncrypt struct {
	Encrypt string `json:"encrypt" form:"encrypt"`
}

type ReceiveMessageEvent

type ReceiveMessageEvent struct {
	Schema string       `json:"schema"`
	Header Header       `json:"header"`
	Event  MessageEvent `json:"event"`
}

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type Sender

type Sender struct {
	SenderID   map[string]string `json:"sender_id"`
	SenderType string            `json:"sender_type"`
	TenantKey  string            `json:"tenant_key"`
}

type TenantAccessTokenRequest

type TenantAccessTokenRequest struct {
	APPID     string `json:"app_id"`
	APPSecret string `json:"app_secret"`
}

type TenantAccessTokenResponse

type TenantAccessTokenResponse struct {
	Code              int    `json:"code"`
	Msg               string `json:"msg"`
	Expire            int    `json:"expire"`
	TenantAccessToken string `json:"tenant_access_token"`
}

type UpdateChatRequest

type UpdateChatRequest struct {
	Avatar                 string     `json:"avatar,omitempty"`
	Name                   string     `json:"name,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"`
}

type UpdateChatResponse

type UpdateChatResponse struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Data    struct{} `json:"data"`
}

type UploadImageResponse

type UploadImageResponse struct {
	Code    int                      `json:"code"`
	Message string                   `json:"message"`
	Data    *UploadImageResponseBody `json:"data,omitempty"`
}

type UploadImageResponseBody

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

type UserID

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

Jump to

Keyboard shortcuts

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