larkslim

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 11 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) GetAccessToken

func (api *API) GetAccessToken() (expire int, err error)

func (*API) GetChatInfo

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

func (*API) GetUserInfo

func (api *API) GetUserInfo(userIds []string) (userInfos UserInfos, err error)

func (*API) ListAllChats

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

func (*API) NewRequest

func (api *API) NewRequest(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) 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 {
		UserInfos UserInfos `json:"user_infos"`
	} `json:"data"`
}

type UserInfos

type UserInfos []UserInfo

func (*UserInfos) String

func (userInfos *UserInfos) String() string

Directories

Path Synopsis
cmd
ws module

Jump to

Keyboard shortcuts

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