larki

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

README

Larki

github action GitHub release (latest by date)

lark-oapi-go 的再封装

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterTextContent

func FilterTextContent(text string, mentions []*larkim.MentionEvent) (string, bool)

FilterTextContent 返回过滤掉 @ 信息后的文本内容和是否需要忽略,若包含@全体成员,则忽略,否则返回去除@信息后的文本内容

func GetImage

func GetImage(ctx context.Context, messageId, imageKey string) (io.Reader, error)

GetImage 下载图片

func GetMessage

func GetMessage(ctx context.Context, messageId string) (*larkim.Message, error)

GetMessage 获取指定消息

func NewImageContent

func NewImageContent(imageKey string) string

NewImageContent 构造图片消息内容

func ParseImageKey

func ParseImageKey(context string) (string, bool)

ParseImageKey 解析图片消息imageKey

func ParseTextContent

func ParseTextContent(text string) (string, bool)

ParseTextContent 解析文本消息内容

func ReplyCard

func ReplyCard(ctx context.Context, messageId, card string) error

ReplyCard 使用卡片回复消息

func ReplyCardTemplate

func ReplyCardTemplate(ctx context.Context, messageId, templateId string, vars map[string]interface{}) error

ReplyCardTemplate 使用模板卡片回复消息

func ReplyImage

func ReplyImage(ctx context.Context, messageId, imageKey string) error

ReplyImage 使用图片回复消息

func ReplyMessage

func ReplyMessage(ctx context.Context, message, messageId, messageType string) error

ReplyMessage 回复消息

func ReplyText

func ReplyText(ctx context.Context, messageId, title string, text ...string) error

ReplyText 使用文本回复消息

func SendCardTemplateToGroup

func SendCardTemplateToGroup(ctx context.Context, groupId, templateId string, vars map[string]interface{}) (string, error)

SendCardTemplateToGroup 使用模板卡片发送消息到群组

func SendCardTemplateToUser

func SendCardTemplateToUser(ctx context.Context, openId, templateId string, vars map[string]interface{}) (string, error)

SendCardTemplateToUser 使用模板卡片发送消息到用户

func SendCardToGroup

func SendCardToGroup(ctx context.Context, groupId, card string) (string, error)

SendCardToGroup 使用卡片发送消息到群组

func SendCardToUser

func SendCardToUser(ctx context.Context, openId, card string) (string, error)

SendCardToUser 使用卡片发送消息到用户

func SendImageToGroup

func SendImageToGroup(ctx context.Context, groupId, imageKey string) (string, error)

SendImageToGroup 使用图片发送消息到群组

func SendImageToUser

func SendImageToUser(ctx context.Context, openId, imageKey string) (string, error)

SendImageToUser 使用图片发送消息到用户

func SendMessage

func SendMessage(ctx context.Context, receiverIdType, message, receiveId, messageType string) (string, error)

SendMessage 发送消息

func SendMessageToGroup

func SendMessageToGroup(ctx context.Context, groupId, message, messageType string) (string, error)

SendMessageToGroup 发送消息到群组

func SendMessageToUser

func SendMessageToUser(ctx context.Context, openId, message, messageType string) (string, error)

SendMessageToUser 发送消息到用户

func SendTextToGroup

func SendTextToGroup(ctx context.Context, groupId, title string, text ...string) (string, error)

SendTextToGroup 使用文本发送消息到群组

func SendTextToUser

func SendTextToUser(ctx context.Context, openId, title string, text ...string) (string, error)

SendTextToUser 使用文本发送消息到用户

func SetGlobalClient

func SetGlobalClient(client *Client)

func UploadImage

func UploadImage(ctx context.Context, reader io.Reader) (string, error)

UploadImage 上传图片

Types

type BotAddedEvent added in v0.0.3

type BotAddedEvent struct {
	*larkim.P2ChatMemberBotAddedV1Data
}

type BotInfo

type BotInfo struct {
	ActivateStatus int    `json:"activate_status"`
	AppName        string `json:"app_name"`
	AvatarUrl      string `json:"avatar_url"`
	OpenID         string `json:"open_id"`
}

type ChatCreatedEvent added in v0.0.3

type ChatCreatedEvent struct {
	*larkim.P1P2PChatCreatedV1Data
}

type Client

type Client struct {
	*lark.Client
	*Config
	*BotInfo
	EventDispatcher *dispatcher.EventDispatcher
	MessageEvent    <-chan *MessageEvent
	MessageClient
	ImageClient
}
var GlobalClient *Client

func NewClient

func NewClient(appId, appSecret, verifyToken, encryptKey string) (*Client, error)

func NewClientWithConfig

func NewClientWithConfig(config *Config) (*Client, error)

func (*Client) GetBotInfo

func (c *Client) GetBotInfo() (*BotInfo, error)

GetBotInfo 获取 BotInfo

func (*Client) GetDocResource added in v0.0.5

func (c *Client) GetDocResource(ctx context.Context, fileToken string) (io.Reader, string, error)

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, messageId, imageKey string) (io.Reader, error)

GetImage 下载图片

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, messageId string) (*larkim.Message, error)

GetMessage 获取指定消息

func (*Client) GetRecord added in v0.0.4

func (c *Client) GetRecord(ctx context.Context, baseId, tableId, recordId string) (*larkbitable.AppTableRecord, error)

func (*Client) GetRecords added in v0.0.3

func (c *Client) GetRecords(ctx context.Context, baseId, tableId string, limit int) ([]*larkbitable.AppTableRecord, error)

func (*Client) ReplyCard

func (c *Client) ReplyCard(ctx context.Context, messageId, card string) error

ReplyCard 使用卡片回复消息

func (*Client) ReplyCardTemplate

func (c *Client) ReplyCardTemplate(ctx context.Context, messageId, templateId string, vars map[string]interface{}) error

ReplyCardTemplate 使用模板卡片回复消息

func (*Client) ReplyImage

func (c *Client) ReplyImage(ctx context.Context, messageId, imageKey string) error

ReplyImage 使用图片回复消息

func (*Client) ReplyMessage

func (c *Client) ReplyMessage(ctx context.Context, message, messageId, messageType string) error

ReplyMessage 回复消息

func (*Client) ReplyText

func (c *Client) ReplyText(ctx context.Context, messageId, title string, text ...string) error

ReplyText 使用文本回复消息

func (*Client) SendCardTemplateToGroup

func (c *Client) SendCardTemplateToGroup(ctx context.Context, groupId, templateId string, vars map[string]interface{}) (string, error)

SendCardTemplateToGroup 使用模板卡片发送消息到群组

func (*Client) SendCardTemplateToUser

func (c *Client) SendCardTemplateToUser(ctx context.Context, openId, templateId string, vars map[string]interface{}) (string, error)

SendCardTemplateToUser 使用模板卡片发送消息到用户

func (*Client) SendCardToGroup

func (c *Client) SendCardToGroup(ctx context.Context, groupId, card string) (string, error)

SendCardToGroup 使用卡片发送消息到群组

func (*Client) SendCardToUser

func (c *Client) SendCardToUser(ctx context.Context, openId, card string) (string, error)

SendCardToUser 使用卡片发送消息到用户

func (*Client) SendImageToGroup

func (c *Client) SendImageToGroup(ctx context.Context, groupId, imageKey string) (string, error)

SendImageToGroup 使用图片发送消息到群组

func (*Client) SendImageToUser

func (c *Client) SendImageToUser(ctx context.Context, openId, imageKey string) (string, error)

SendImageToUser 使用图片发送消息到用户

func (*Client) SendMessageToGroup

func (c *Client) SendMessageToGroup(ctx context.Context, groupId, message, messageType string) (string, error)

SendMessageToGroup 发送消息到群组

func (*Client) SendMessageToUser

func (c *Client) SendMessageToUser(ctx context.Context, openId, message, messageType string) (string, error)

SendMessageToUser 发送消息到用户

func (*Client) SendTextToGroup

func (c *Client) SendTextToGroup(ctx context.Context, groupId, title string, text ...string) (string, error)

SendTextToGroup 使用文本发送消息到群组

func (*Client) SendTextToUser

func (c *Client) SendTextToUser(ctx context.Context, openId, title string, text ...string) (string, error)

SendTextToUser 使用文本发送消息到用户

func (*Client) UpdateBaseRecord added in v0.0.3

func (c *Client) UpdateBaseRecord(ctx context.Context, baseId, tableId, recordId string, fields map[string]interface{}) error

func (*Client) UploadImage

func (c *Client) UploadImage(ctx context.Context, reader io.Reader) (string, error)

UploadImage 上传图片

type Config

type Config struct {
	AppID       string
	AppSecret   string
	VerifyToken string
	EncryptKey  string
}

type DocumentClient added in v0.0.3

type DocumentClient interface{}

type ImageClient added in v0.0.3

type ImageClient interface {
	GetImage(ctx context.Context, messageId, imageKey string) (io.Reader, error)
	UploadImage(ctx context.Context, reader io.Reader) (string, error)
}

type MessageClient added in v0.0.3

type MessageClient interface {
	GetMessage(ctx context.Context, messageId string) (*larkim.Message, error)
	ReplyMessage(ctx context.Context, message, messageId, messageType string) error
	ReplyText(ctx context.Context, messageId, title string, text ...string) error
	ReplyImage(ctx context.Context, messageId, imageKey string) error
	ReplyCard(ctx context.Context, messageId, card string) error
	ReplyCardTemplate(ctx context.Context, messageId, templateId string, vars map[string]interface{}) error
	SendMessage(ctx context.Context, receiverIdType, message, receiveId, messageType string) (string, error)
	SendMessageToGroup(ctx context.Context, groupId, message, messageType string) (string, error)
	SendTextToGroup(ctx context.Context, groupId, title string, text ...string) (string, error)
	SendImageToGroup(ctx context.Context, groupId, imageKey string) (string, error)
	SendCardToGroup(ctx context.Context, groupId, card string) (string, error)
	SendCardTemplateToGroup(ctx context.Context, groupId, templateId string, vars map[string]interface{}) (string, error)
	SendMessageToUser(ctx context.Context, openId, message, messageType string) (string, error)
	SendTextToUser(ctx context.Context, openId, title string, text ...string) (string, error)
	SendImageToUser(ctx context.Context, openId, imageKey string) (string, error)
	SendCardToUser(ctx context.Context, openId, card string) (string, error)
	SendCardTemplateToUser(ctx context.Context, openId, templateId string, vars map[string]interface{}) (string, error)
}

type MessageEvent

type MessageEvent struct {
	*larkim.P2MessageReceiveV1Data
}

func (*MessageEvent) TrimTextContent

func (m *MessageEvent) TrimTextContent() (string, bool)

TrimTextContent 去除消息中的 @ 信息

Jump to

Keyboard shortcuts

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