larkslim

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Examples

Constants

View Source
const (
	Prefix = "https://open.feishu.cn/open-apis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	AppId     string
	AppSecret string

	Timeout time.Duration

	Debugger func(args ...interface{})
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(appId, appSecret string) *API

func (*API) AddUsersToChat

func (api *API) AddUsersToChat(chatId string, userIds []string) (err error)

func (*API) CreateChat

func (api *API) CreateChat(name, userOpenId string) (chatId string, err error)

func (*API) DestroyChat

func (api *API) DestroyChat(chatId string) (err error)

func (*API) GetChatInfo

func (api *API) GetChatInfo(chatId string) (group Group, err error)

func (*API) GetUserInfo

func (api *API) GetUserInfo(userId string) (userInfo UserInfo, err error)

func (*API) ListAllChats

func (api *API) ListAllChats() (groups Groups, err error)

func (*API) NewRequest

func (api *API) NewRequest(method, path string, reqBody interface{}, respData interface{}) (err error)

func (*API) RemoveUsersFromChat

func (api *API) RemoveUsersFromChat(chatId string, userIds []string) (err error)

func (*API) SendCard

func (api *API) SendCard(target string, card Card) (err error)

func (*API) SendImageMessage

func (api *API) SendImageMessage(target, imageKey string) (err error)

func (*API) SendMessage

func (api *API) SendMessage(target, content string) (err error)

func (*API) SendPost

func (api *API) SendPost(target string, post Post) (err error)

func (*API) UpdateChat added in v1.1.1

func (api *API) UpdateChat(chatId string, update map[string]interface{}) (err error)

List of parameters to update:

| Parameter | Type | Required | Description |-----------------------------|--------|----------|--------------------------------------------------- | owner_open_id | string | Optional | Group owner's open_id (When transferring group | | | | ownership, either owner_open_id or owner_user_id | | | | can be filled in) | owner_user_id | string | Optional | Group owner's user_id (When transferring group | | | | ownership, either owner_open_id or owner_user_id | | | | can be filled in) | name | string | Optional | Default display group name | i18n_names | map | Optional | Internationalized group name | description | string | Optional | Group description | only_owner_add | bool | Optional | Whether only the group owner can add people | share_allowed | bool | Optional | Whether group sharing is allowed | add_member_verify | bool | Optional | Whether to enable group join verification | only_owner_at_all | bool | Optional | Whether only the group owner can @all | only_owner_edit | bool | Optional | Whether only the group owner can edit group | | | | information, including avatar, name, description, | | | | and announcement | send_message_permission | string | Optional | Who is allowed to send messages. all: everyone, | | | | owner: only group owner | join_message_visibility | string | Optional | Member join group notification. all: notify | | | | everyone, owner: notify only owner, not_anyone: | | | | notify no one | leave_message_visibility | string | Optional | Member leave group notification. all: notify | | | | everyone, owner: notify only owner, not_anyone: | | | | notify no one | group_email_enabled | bool | Optional | Whether to enable group email | send_group_email_permission | string | Optional | Permission to send group emails. owner: only | | | | group owner, group_member: group members, | | | | tenant_member: team members, all: everyone

func (*API) UploadAvatarImage

func (api *API) UploadAvatarImage(file io.Reader) (key string, err error)

func (*API) UploadMessageImage

func (api *API) UploadMessageImage(file io.Reader) (key string, err error)

type APIResponse

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

type AccessTokenResponse

type AccessTokenResponse struct {
	APIResponse
	Expire int    `json:"expire"`
	Token  string `json:"tenant_access_token"`
}

type Card

type Card struct {
	Config   CardConfig    `json:"config"`
	Header   CardHeader    `json:"header"`
	Elements []interface{} `json:"elements"`
}

type CardConfig

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

type CardHeader

type CardHeader struct {
	Title    CardHeaderTitle `json:"title"`
	Template string          `json:"template"`
}

https://open.feishu.cn/document/ukTMukTMukTM/ukTNwUjL5UDM14SO1ATN

type CardHeaderTitle

type CardHeaderTitle struct {
	Tag     string `json:"tag"`
	Content string `json:"content"`
}

type EventResponse

type EventResponse struct {
	Type  string `json:"type"`
	Token string `json:"token"`

	// type == "url_verification"
	Challenge string `json:"challenge"`

	// type == "event_callback"
	Event struct {
		ChatId           string `json:"open_chat_id"`
		Type             string `json:"type"`
		MsgType          string `json:"msg_type"`
		Text             string `json:"text"`
		TextWithoutAtBot string `json:"text_without_at_bot"`
		OpenId           string `json:"open_id"`
		UserOpenId       string `json:"user_open_id"`
	} `json:"event"`
}

type Group

type Group struct {
	Avatar      string `json:"avatar"`
	ChatId      string `json:"chat_id"`
	Description string `json:"description"`
	Name        string `json:"name"`
	OwnerOpenId string `json:"owner_open_id"`
	OwnerUserId string `json:"owner_user_id"`
	Members     []struct {
		OpenId string `json:"open_id"`
	} `json:"members"`
}

type GroupInfoResponse

type GroupInfoResponse struct {
	APIResponse
	Data Group `json:"data"`
}

type GroupResponse

type GroupResponse struct {
	APIResponse
	Data struct {
		ChatId string `json:"chat_id"`
	} `json:"data"`
}

type Groups

type Groups []Group

func (*Groups) String

func (groups *Groups) String() string

type GroupsResponse

type GroupsResponse struct {
	APIResponse
	Data struct {
		Groups Groups `json:"groups"`
	} `json:"data"`
}

type MessageResponse

type MessageResponse struct {
	APIResponse
	Data struct {
		MessageId string `json:"message_id"`
	} `json:"data"`
}

type Post

type Post map[string]PostOfLocale
Example
package main

import (
	"encoding/json"
	"os"

	"github.com/caiguanhao/larkslim"
)

func main() {
	post := larkslim.Post{
		"zh_cn": larkslim.PostOfLocale{
			Title: "post",
			Content: larkslim.PostLines{
				{
					{
						Tag:  "text",
						Text: "Name: ",
					},
					{
						Tag:  "a",
						Text: "Hello",
						Href: "https://www.google.com",
					},
				},
			},
		},
	}
	enc := json.NewEncoder(os.Stdout)
	enc.SetIndent("", "\t")
	enc.Encode(post)
}
Output:

{
	"zh_cn": {
		"title": "post",
		"content": [
			[
				{
					"tag": "text",
					"text": "Name: "
				},
				{
					"tag": "a",
					"text": "Hello",
					"href": "https://www.google.com"
				}
			]
		]
	}
}

type PostLine

type PostLine []PostTag

type PostLines

type PostLines []PostLine

type PostOfLocale

type PostOfLocale struct {
	Title   string    `json:"title"`
	Content PostLines `json:"content"`
}

type PostTag

type PostTag struct {
	Tag      string `json:"tag,omitempty"`
	Unescape bool   `json:"un_escape,omitempty"`
	Text     string `json:"text,omitempty"`
	Href     string `json:"href,omitempty"`
	UserId   string `json:"user_id,omitempty"`
	ImageKey string `json:"image_key,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type Protected

type Protected struct {
	Original interface{}
	Filtered interface{}
}

type UploadResponse

type UploadResponse struct {
	APIResponse
	Data struct {
		ImageKey string `json:"image_key"`
	} `json:"data"`
}

type UserInfo

type UserInfo struct {
	Name   string `json:"name"`
	OpenId string `json:"open_id"`
}

type UserInfoResponse

type UserInfoResponse struct {
	APIResponse
	Data struct {
		UserInfo UserInfo `json:"user"`
	} `json:"data"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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