Ai
1 Star 0 Fork 0

zhuhukun/oapi-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
resource.go 86.23 KB
一键复制 编辑 原始数据 按行查看 历史
Lakers 提交于 2024-12-25 16:44 +08:00 . feat: github->gitee
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845
// Code generated by Lark OpenAPI.
package larkim
import (
"bytes"
"context"
"gitee.com/zhuhukun/oapi-sdk-go/v3/core"
"net/http"
)
type V1 struct {
BatchMessage *batchMessage // 消息 - 批量消息
Chat *chat // 群组
ChatAccessEvent *chatAccessEvent // chat.access_event
ChatAnnouncement *chatAnnouncement // 群组 - 群公告
ChatManagers *chatManagers // 群组 - 群成员
ChatMemberBot *chatMemberBot // 事件
ChatMemberUser *chatMemberUser // 事件
ChatMembers *chatMembers // 群组 - 群成员
ChatMenuItem *chatMenuItem // chat.menu_item
ChatMenuTree *chatMenuTree // 群组 - 群菜单
ChatModeration *chatModeration // chat.moderation
ChatTab *chatTab // 群组 - 会话标签页
ChatTopNotice *chatTopNotice // chat.top_notice
File *file // 消息 - 文件信息
Image *image // 消息 - 图片信息
Message *message // 消息 - 消息卡片
MessageReaction *messageReaction // 消息 - 表情回复
MessageResource *messageResource // message.resource
Pin *pin // 消息 - Pin
Thread *thread // thread
}
func New(config *larkcore.Config) *V1 {
return &V1{
BatchMessage: &batchMessage{config: config},
Chat: &chat{config: config},
ChatAccessEvent: &chatAccessEvent{config: config},
ChatAnnouncement: &chatAnnouncement{config: config},
ChatManagers: &chatManagers{config: config},
ChatMemberBot: &chatMemberBot{config: config},
ChatMemberUser: &chatMemberUser{config: config},
ChatMembers: &chatMembers{config: config},
ChatMenuItem: &chatMenuItem{config: config},
ChatMenuTree: &chatMenuTree{config: config},
ChatModeration: &chatModeration{config: config},
ChatTab: &chatTab{config: config},
ChatTopNotice: &chatTopNotice{config: config},
File: &file{config: config},
Image: &image{config: config},
Message: &message{config: config},
MessageReaction: &messageReaction{config: config},
MessageResource: &messageResource{config: config},
Pin: &pin{config: config},
Thread: &thread{config: config},
}
}
type batchMessage struct {
config *larkcore.Config
}
type chat struct {
config *larkcore.Config
}
type chatAccessEvent struct {
config *larkcore.Config
}
type chatAnnouncement struct {
config *larkcore.Config
}
type chatManagers struct {
config *larkcore.Config
}
type chatMemberBot struct {
config *larkcore.Config
}
type chatMemberUser struct {
config *larkcore.Config
}
type chatMembers struct {
config *larkcore.Config
}
type chatMenuItem struct {
config *larkcore.Config
}
type chatMenuTree struct {
config *larkcore.Config
}
type chatModeration struct {
config *larkcore.Config
}
type chatTab struct {
config *larkcore.Config
}
type chatTopNotice struct {
config *larkcore.Config
}
type file struct {
config *larkcore.Config
}
type image struct {
config *larkcore.Config
}
type message struct {
config *larkcore.Config
}
type messageReaction struct {
config *larkcore.Config
}
type messageResource struct {
config *larkcore.Config
}
type pin struct {
config *larkcore.Config
}
type thread struct {
config *larkcore.Config
}
// Delete 批量撤回消息
//
// - 批量撤回通过[批量发送消息](https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM)接口发送的消息。
//
// - 注意事项:;- 应用需要启用[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 撤回单条发送的消息请使用[撤回消息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/delete)接口;- 不支持撤回发出时间超过1天的消息;- 一次调用涉及大量消息,所以为异步接口,会有一定延迟。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/batch_message/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_batchMessage.go
func (b *batchMessage) Delete(ctx context.Context, req *DeleteBatchMessageReq, options ...larkcore.RequestOptionFunc) (*DeleteBatchMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/batch_messages/:batch_message_id"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, b.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.config)
if err != nil {
return nil, err
}
return resp, err
}
// GetProgress 查询批量消息整体进度
//
// - 该接口在[查询批量消息推送和阅读人数](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/batch_message/read_user)查询结果的基础上,增加了批量请求中有效的userid数量以及消息撤回进度数据。
//
// - 注意事项:;* 该接口返回的数据为查询时刻的快照数据
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/batch_message/get_progress
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/getProgress_batchMessage.go
func (b *batchMessage) GetProgress(ctx context.Context, req *GetProgressBatchMessageReq, options ...larkcore.RequestOptionFunc) (*GetProgressBatchMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/batch_messages/:batch_message_id/get_progress"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, b.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetProgressBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.config)
if err != nil {
return nil, err
}
return resp, err
}
// ReadUser 查询批量消息推送和阅读人数
//
// - 批量发送消息后,可以通过该接口查询批量消息推送的总人数和阅读人数。
//
// - 注意事项:;- 只能查询通过[批量发送消息](https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM)接口产生的消息;- 该接口返回的数据为查询时刻的快照数据
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/batch_message/read_user
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/readUser_batchMessage.go
func (b *batchMessage) ReadUser(ctx context.Context, req *ReadUserBatchMessageReq, options ...larkcore.RequestOptionFunc) (*ReadUserBatchMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/batch_messages/:batch_message_id/read_user"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, b.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ReadUserBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 创建群
//
// - 创建群并设置群头像、群名、群描述等。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 本接口支持在创建群的同时拉用户或机器人进群;如果仅需要拉用户或者机器人入群参考 [将用户或机器人拉入群聊](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/create)接口
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_chat.go
func (c *chat) Create(ctx context.Context, req *CreateChatReq, options ...larkcore.RequestOptionFunc) (*CreateChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 解散群
//
// - 解散群组。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 如果使用tenant_access_token,需要机器人符合以下任一情况才可解散群:; - 机器人是群主; - 机器人是群的创建者且具备==更新应用所创建群的群信息==权限;- 如果使用user_access_token,需要对应的用户是群主才可解散群
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_chat.go
func (c *chat) Delete(ctx context.Context, req *DeleteChatReq, options ...larkcore.RequestOptionFunc) (*DeleteChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取群信息
//
// - 获取群名称、群描述、群头像、群主 ID 等群基本信息。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 机器人或授权用户必须在群里(否则只会返回群名称、群头像等基本信息);- 获取内部群信息时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_chat.go
func (c *chat) Get(ctx context.Context, req *GetChatReq, options ...larkcore.RequestOptionFunc) (*GetChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Link 获取群分享链接
//
// - 获取指定群的分享链接。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - access_token所对应的 **机器人** 或 **授权用户** 必须在`chat_id`参数指定的群组中;- 单聊、密聊、团队群不支持分享群链接;- 当Bot被停用或Bot退出群组时,Bot生成的群链接也将停用;- 当群聊开启了 ==仅群主和群管理员可添加群成员/分享群== 设置时,仅**群主**和**群管理员**可以获取群分享链接;- 获取内部群分享链接时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/link
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/link_chat.go
func (c *chat) Link(ctx context.Context, req *LinkChatReq, options ...larkcore.RequestOptionFunc) (*LinkChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/link"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &LinkChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// List 获取用户或机器人所在的群列表
//
// - 获取用户或者机器人所在群列表。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 请注意区分本接口和[获取群信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/get)的请求 URL;- 获取的群列表不包含P2P单聊
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/list_chat.go
func (c *chat) List(ctx context.Context, req *ListChatReq, options ...larkcore.RequestOptionFunc) (*ListChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
func (c *chat) ListByIterator(ctx context.Context, req *ListChatReq, options ...larkcore.RequestOptionFunc) (*ListChatIterator, error) {
return &ListChatIterator{
ctx: ctx,
req: req,
listFunc: c.List,
options: options,
limit: req.Limit}, nil
}
// Search 搜索对用户或机器人可见的群列表
//
// - 搜索对用户或机器人可见的群列表,包括:用户或机器人所在的群、对用户或机器人公开的群。;搜索可获得的群信息包括:群ID(chat_id)、群名称、群描述等。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/search
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/search_chat.go
func (c *chat) Search(ctx context.Context, req *SearchChatReq, options ...larkcore.RequestOptionFunc) (*SearchChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/search"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SearchChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
func (c *chat) SearchByIterator(ctx context.Context, req *SearchChatReq, options ...larkcore.RequestOptionFunc) (*SearchChatIterator, error) {
return &SearchChatIterator{
ctx: ctx,
req: req,
listFunc: c.Search,
options: options,
limit: req.Limit}, nil
}
// Update 更新群信息
//
// - 更新群头像、群名称、群描述、群配置、转让群主等。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 对于群主/群管理员 或 创建群组且具备 ==更新应用所创建群的群信息== 权限的机器人,可更新所有信息;- 对于不满足上述权限条件的群成员或机器人:; - 若未开启 ==仅群主和群管理员可编辑群信息== 配置,仅可更新群头像、群名称、群描述、群国际化名称信息; - 若开启了 ==仅群主和群管理员可编辑群信息== 配置,任何群信息都不能修改;- 如果同时更新 ==邀请用户或机器人入群权限== 和 ==群分享权限== 这两项设置需要满足以下条件:; - 若未开启 ==仅群主和管理员可以邀请用户或机器人入群==,需要设置 ==群分享权限== 为 ==允许分享==; - 若开启了 ==仅群主和管理员可以邀请用户或机器人入群==,需要设置 ==群分享权限== 为 ==不允许分享==
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/update
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/update_chat.go
func (c *chat) Update(ctx context.Context, req *UpdateChatReq, options ...larkcore.RequestOptionFunc) (*UpdateChatResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id"
apiReq.HttpMethod = http.MethodPut
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取群公告信息
//
// - 获取会话中的群公告信息,公告信息格式与[云文档](https://open.feishu.cn/document/ukTMukTMukTM/uAzM5YjLwMTO24CMzkjN)格式相同。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 获取内部群信息时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-announcement/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_chatAnnouncement.go
func (c *chatAnnouncement) Get(ctx context.Context, req *GetChatAnnouncementReq, options ...larkcore.RequestOptionFunc) (*GetChatAnnouncementResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/announcement"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatAnnouncementResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Patch 更新群公告信息
//
// - 更新会话中的群公告信息,更新公告信息的格式和更新[云文档](https://open.feishu.cn/document/ukTMukTMukTM/uAzM5YjLwMTO24CMzkjN)格式相同。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 操作者需要拥有群公告文档的阅读权限;- 获取内部群信息时,操作者须与群组在同一租户下;- 若群开启了 ==仅群主和群管理员可编辑群信息== 配置,群主/群管理员 或 创建群组且具备 ==更新应用所创建群的群信息== 权限的机器人,可更新群公告;- 若群未开启 ==仅群主和群管理员可编辑群信息== 配置,所有成员可以更新群公告
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-announcement/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/patch_chatAnnouncement.go
func (c *chatAnnouncement) Patch(ctx context.Context, req *PatchChatAnnouncementReq, options ...larkcore.RequestOptionFunc) (*PatchChatAnnouncementResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/announcement"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PatchChatAnnouncementResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// AddManagers 指定群管理员
//
// - 将用户或机器人指定为群管理员。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 仅有群主可以指定群管理员
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-managers/add_managers
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/addManagers_chatManagers.go
func (c *chatManagers) AddManagers(ctx context.Context, req *AddManagersChatManagersReq, options ...larkcore.RequestOptionFunc) (*AddManagersChatManagersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/managers/add_managers"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &AddManagersChatManagersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// DeleteManagers 删除群管理员
//
// - 删除指定的群管理员(用户或机器人)。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 仅有群主可以删除群管理员
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-managers/delete_managers
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/deleteManagers_chatManagers.go
func (c *chatManagers) DeleteManagers(ctx context.Context, req *DeleteManagersChatManagersReq, options ...larkcore.RequestOptionFunc) (*DeleteManagersChatManagersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/managers/delete_managers"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteManagersChatManagersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 将用户或机器人拉入群聊
//
// - 将用户或机器人拉入群聊。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 如需拉用户进群,需要机器人对用户有[可用性](https://open.feishu.cn/document/home/introduction-to-scope-and-authorization/availability); - 机器人或授权用户必须在群组中;- 外部租户不能被加入到内部群中;- 操作内部群时,操作者须与群组在同一租户下; - 在开启 ==仅群主和群管理员可添加群成员== 的设置时,仅有群主/管理员 或 创建群组且具备 ==更新应用所创建群的群信息== 权限的机器人,可以拉用户或者机器人进群; - 在未开启 ==仅群主和群管理员可添加群成员== 的设置时,所有群成员都可以拉用户或机器人进群
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_chatMembers.go
func (c *chatMembers) Create(ctx context.Context, req *CreateChatMembersReq, options ...larkcore.RequestOptionFunc) (*CreateChatMembersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/members"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 将用户或机器人移出群聊
//
// - 将用户或机器人移出群聊。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 用户或机器人在任何条件下均可移除自己出群(即主动退群);- 仅有群主/管理员 或 创建群组并且具备 ==更新应用所创建群的群信息== 权限的机器人,可以移除其他用户或者机器人;- 每次请求,最多移除50个用户或者5个机器人;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_chatMembers.go
func (c *chatMembers) Delete(ctx context.Context, req *DeleteChatMembersReq, options ...larkcore.RequestOptionFunc) (*DeleteChatMembersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/members"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取群成员列表
//
// - 获取用户/机器人所在群的群成员列表。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 机器人或授权用户必须在群组中; - 该接口不会返回群内的机器人成员; - 由于返回的群成员列表会过滤掉机器人成员,因此返回的群成员个数可能会小于指定的page_size; - 如果有同一时间加入群的群成员,会一次性返回,这会导致返回的群成员个数可能会大于指定的page_size;- 获取内部群信息时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_chatMembers.go
func (c *chatMembers) Get(ctx context.Context, req *GetChatMembersReq, options ...larkcore.RequestOptionFunc) (*GetChatMembersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/members"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
func (c *chatMembers) GetByIterator(ctx context.Context, req *GetChatMembersReq, options ...larkcore.RequestOptionFunc) (*GetChatMembersIterator, error) {
return &GetChatMembersIterator{
ctx: ctx,
req: req,
listFunc: c.Get,
options: options,
limit: req.Limit}, nil
}
// IsInChat 判断用户或机器人是否在群里
//
// - 根据使用的access_token判断对应的用户或者机器人是否在群里。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 获取内部群信息时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/is_in_chat
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/isInChat_chatMembers.go
func (c *chatMembers) IsInChat(ctx context.Context, req *IsInChatChatMembersReq, options ...larkcore.RequestOptionFunc) (*IsInChatChatMembersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/members/is_in_chat"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &IsInChatChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// MeJoin 用户或机器人主动加入群聊
//
// - 用户或机器人主动加入群聊。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 目前仅支持加入公开群;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/me_join
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/meJoin_chatMembers.go
func (c *chatMembers) MeJoin(ctx context.Context, req *MeJoinChatMembersReq, options ...larkcore.RequestOptionFunc) (*MeJoinChatMembersResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/members/me_join"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &MeJoinChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Patch 修改群菜单元信息
//
// - 修改某个一级菜单或者二级菜单的元信息。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;- 机器人必须在群里。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-menu_item/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/patch_chatMenuItem.go
func (c *chatMenuItem) Patch(ctx context.Context, req *PatchChatMenuItemReq, options ...larkcore.RequestOptionFunc) (*PatchChatMenuItemResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/menu_items/:menu_item_id"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PatchChatMenuItemResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 添加群菜单
//
// - 向群内添加群菜单。
//
// - 注意事项:;- 该API是向群内追加菜单,群内原来存在的菜单并不会被覆盖。操作API后,将返回群内所有菜单。;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;- 机器人必须在群里。;- 一个群内,一级菜单最多有3个,每个一级菜单最多有5个二级菜单。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-menu_tree/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_chatMenuTree.go
func (c *chatMenuTree) Create(ctx context.Context, req *CreateChatMenuTreeReq, options ...larkcore.RequestOptionFunc) (*CreateChatMenuTreeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/menu_tree"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 删除群菜单。
//
// - 删除群内菜单。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;- 机器人必须在群里。;- 操作API后,将返回群内所有菜单。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-menu_tree/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_chatMenuTree.go
func (c *chatMenuTree) Delete(ctx context.Context, req *DeleteChatMenuTreeReq, options ...larkcore.RequestOptionFunc) (*DeleteChatMenuTreeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/menu_tree"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取群内菜单
//
// - 通过群ID获取群内菜单。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;- 机器人必须在群里。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-menu_tree/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_chatMenuTree.go
func (c *chatMenuTree) Get(ctx context.Context, req *GetChatMenuTreeReq, options ...larkcore.RequestOptionFunc) (*GetChatMenuTreeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/menu_tree"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Sort 排序群菜单
//
// - 给一个群内的一级菜单排序。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;- 机器人必须在群里。;- 操作API后,将返回群内所有菜单。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-menu_tree/sort
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/sort_chatMenuTree.go
func (c *chatMenuTree) Sort(ctx context.Context, req *SortChatMenuTreeReq, options ...larkcore.RequestOptionFunc) (*SortChatMenuTreeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/menu_tree/sort"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SortChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取群成员发言权限
//
// - 获取群发言模式、可发言用户名单等
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 机器人 或 授权用户 必须在群里
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-moderation/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_chatModeration.go
func (c *chatModeration) Get(ctx context.Context, req *GetChatModerationReq, options ...larkcore.RequestOptionFunc) (*GetChatModerationResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/moderation"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatModerationResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
func (c *chatModeration) GetByIterator(ctx context.Context, req *GetChatModerationReq, options ...larkcore.RequestOptionFunc) (*GetChatModerationIterator, error) {
return &GetChatModerationIterator{
ctx: ctx,
req: req,
listFunc: c.Get,
options: options,
limit: req.Limit}, nil
}
// Update 更新群发言权限
//
// - 更新群组的发言权限设置,可设置为全员可发言、仅管理员可发言 或 指定用户可发言。
//
// - 注意事项:; - 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 若以用户授权调用接口,**当授权用户是群主**时,可更新群发言权限;- 若以租户授权调用接口(即以机器人身份调用接口),当**机器人是群主** 或者 **机器人是群组创建者、具备==更新应用所创建群的群信息==权限且仍在群内**时,可更新群发言权限
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-moderation/update
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/update_chatModeration.go
func (c *chatModeration) Update(ctx context.Context, req *UpdateChatModerationReq, options ...larkcore.RequestOptionFunc) (*UpdateChatModerationResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/moderation"
apiReq.HttpMethod = http.MethodPut
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateChatModerationResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 添加会话标签页
//
// - 添加自定义会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 只允许添加类型为`doc`和`url`的会话标签页;- 添加doc类型时,操作者(access token对应的身份)需要拥有对应文档的权限;- tab_config字段当前只对`url`类型的会话标签页生效;- 在开启 ==仅群主和管理员可管理标签页== 的设置时,仅群主和群管理员可以添加会话标签页;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-tab/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_chatTab.go
func (c *chatTab) Create(ctx context.Context, req *CreateChatTabReq, options ...larkcore.RequestOptionFunc) (*CreateChatTabResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/chat_tabs"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// DeleteTabs 删除会话标签页
//
// - 删除会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 只允许删除类型为`doc`和`url`的会话标签页;- 在开启 ==仅群主和管理员可管理标签页== 的设置时,仅群主和群管理员可以删除会话标签页;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-tab/delete_tabs
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/deleteTabs_chatTab.go
func (c *chatTab) DeleteTabs(ctx context.Context, req *DeleteTabsChatTabReq, options ...larkcore.RequestOptionFunc) (*DeleteTabsChatTabResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/chat_tabs/delete_tabs"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// ListTabs 拉取会话标签页
//
// - 拉取会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-tab/list_tabs
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/listTabs_chatTab.go
func (c *chatTab) ListTabs(ctx context.Context, req *ListTabsChatTabReq, options ...larkcore.RequestOptionFunc) (*ListTabsChatTabResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/chat_tabs/list_tabs"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// SortTabs 会话标签页排序
//
// - 会话标签页排序。
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 消息标签页强制固定为第一顺位,不参与排序,但是请求体中必须包含该标签页的Tab ID;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-tab/sort_tabs
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/sortTabs_chatTab.go
func (c *chatTab) SortTabs(ctx context.Context, req *SortTabsChatTabReq, options ...larkcore.RequestOptionFunc) (*SortTabsChatTabResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/chat_tabs/sort_tabs"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SortTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// UpdateTabs 更新会话标签页
//
// - 更新会话标签页
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 只允许更新类型为`doc`和`url`的会话标签页;- 更新doc类型时,操作者(access token对应的身份)需要拥有对应文档的权限;- 在开启 ==仅群主和管理员可管理标签页== 的设置时,仅群主和群管理员可以更新会话标签页;- 操作内部群时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-tab/update_tabs
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/updateTabs_chatTab.go
func (c *chatTab) UpdateTabs(ctx context.Context, req *UpdateTabsChatTabReq, options ...larkcore.RequestOptionFunc) (*UpdateTabsChatTabResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/chat_tabs/update_tabs"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// DeleteTopNotice 撤销群置顶
//
// - 撤销会话中的置顶。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 机器人或授权用户必须在群组中;- 撤销内部群置顶时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-top_notice/delete_top_notice
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/deleteTopNotice_chatTopNotice.go
func (c *chatTopNotice) DeleteTopNotice(ctx context.Context, req *DeleteTopNoticeChatTopNoticeReq, options ...larkcore.RequestOptionFunc) (*DeleteTopNoticeChatTopNoticeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/top_notice/delete_top_notice"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteTopNoticeChatTopNoticeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// PutTopNotice 更新群置顶
//
// - 更新会话中的群置顶信息,可以将群中的某一条消息,或者群公告置顶显示。
//
// - 注意事项:; - 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability); - 机器人或授权用户必须在群组中;- 更新内部群置顶时,操作者须与群组在同一租户下
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-top_notice/put_top_notice
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/putTopNotice_chatTopNotice.go
func (c *chatTopNotice) PutTopNotice(ctx context.Context, req *PutTopNoticeChatTopNoticeReq, options ...larkcore.RequestOptionFunc) (*PutTopNoticeChatTopNoticeResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/chats/:chat_id/top_notice/put_top_notice"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PutTopNoticeChatTopNoticeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 上传文件
//
// - 上传文件,可以上传视频,音频和常见的文件类型。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 文件大小不得超过30M,且不允许上传空文件
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_file.go
func (f *file) Create(ctx context.Context, req *CreateFileReq, options ...larkcore.RequestOptionFunc) (*CreateFileResp, error) {
options = append(options, larkcore.WithFileUpload())
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/files"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateFileResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, f.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 下载文件
//
// - 下载文件接口,只能下载应用自己上传的文件。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 只能下载机器人自己上传的文件;- 下载用户发送的资源,请使用[获取消息中的资源文件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-resource/get)接口;- 下载的资源大小不能超过100M;- 如果需要Content-Disposition header,发起请求的时候需要在header中设置Content-Type为application/json
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_file.go
func (f *file) Get(ctx context.Context, req *GetFileReq, options ...larkcore.RequestOptionFunc) (*GetFileResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/files/:file_key"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetFileResp{ApiResp: apiResp}
// 如果是下载,则设置响应结果
if apiResp.StatusCode == http.StatusOK {
resp.File = bytes.NewBuffer(apiResp.RawBody)
resp.FileName = larkcore.FileNameByHeader(apiResp.Header)
return resp, err
}
err = apiResp.JSONUnmarshalBody(resp, f.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 上传图片
//
// - 上传图片接口,支持上传 JPEG、PNG、WEBP、GIF、TIFF、BMP、ICO格式图片。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 图片大小不得超过10M,且不支持上传大小为0的图片
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_image.go
func (i *image) Create(ctx context.Context, req *CreateImageReq, options ...larkcore.RequestOptionFunc) (*CreateImageResp, error) {
options = append(options, larkcore.WithFileUpload())
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/images"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, i.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateImageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, i.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 下载图片
//
// - 下载图片资源,只能下载当前应用所上传且图片类型为message的图片。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 只能下载机器人自己上传且图片类型为message的图片,avatar类型暂不支持下载;- 下载用户发送的资源,请使用[获取消息中的资源文件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-resource/get)接口
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_image.go
func (i *image) Get(ctx context.Context, req *GetImageReq, options ...larkcore.RequestOptionFunc) (*GetImageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/images/:image_key"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, i.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetImageResp{ApiResp: apiResp}
// 如果是下载,则设置响应结果
if apiResp.StatusCode == http.StatusOK {
resp.File = bytes.NewBuffer(apiResp.RawBody)
resp.FileName = larkcore.FileNameByHeader(apiResp.Header)
return resp, err
}
err = apiResp.JSONUnmarshalBody(resp, i.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 发送消息
//
// - 给指定用户或者会话发送消息,支持文本、富文本、可交互的[消息卡片](https://open.feishu.cn/document/ukTMukTMukTM/uczM3QjL3MzN04yNzcDN)、群名片、个人名片、图片、视频、音频、文件、表情包。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 给用户发送消息,需要机器人对用户有[可用性](https://open.feishu.cn/document/home/introduction-to-scope-and-authorization/availability);- 给群组发送消息,需要机器人在群组中
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_message.go
func (m *message) Create(ctx context.Context, req *CreateMessageReq, options ...larkcore.RequestOptionFunc) (*CreateMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 撤回消息
//
// - 机器人撤回机器人自己发送的消息或群主撤回群内消息。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ,撤回消息时机器人仍需要在会话内;- 机器人可以撤回单聊和群组内,自己发送 且 发送时间不超过1天(24小时)的消息;- 若机器人要撤回群内他人发送的消息,则机器人必须是该群的群主、管理员 或者 创建者,且消息发送时间不超过1年;- 无法撤回通过「[批量发送消息](https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM)」接口发送的消息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_message.go
func (m *message) Delete(ctx context.Context, req *DeleteMessageReq, options ...larkcore.RequestOptionFunc) (*DeleteMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Forward
//
// - 转发一条消息
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=forward&project=im&resource=message&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/forward_message.go
func (m *message) Forward(ctx context.Context, req *ForwardMessageReq, options ...larkcore.RequestOptionFunc) (*ForwardMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/forward"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ForwardMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Get 获取指定消息的内容
//
// - 通过 message_id 查询消息内容。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 机器人必须在群组中
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_message.go
func (m *message) Get(ctx context.Context, req *GetMessageReq, options ...larkcore.RequestOptionFunc) (*GetMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// List 获取会话历史消息
//
// - 获取会话(包括单聊、群组)的历史消息(聊天记录)。
//
// - 接口级别权限默认只能获取单聊(p2p)消息,如果需要获取群组(group)消息,应用还必须拥有 **==获取群组中所有消息==** 权限
//
// - - 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 获取消息时,机器人必须在群组中
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/list_message.go
func (m *message) List(ctx context.Context, req *ListMessageReq, options ...larkcore.RequestOptionFunc) (*ListMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
func (m *message) ListByIterator(ctx context.Context, req *ListMessageReq, options ...larkcore.RequestOptionFunc) (*ListMessageIterator, error) {
return &ListMessageIterator{
ctx: ctx,
req: req,
listFunc: m.List,
options: options,
limit: req.Limit}, nil
}
// MergeForward
//
// - 合并转发多条消息
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=merge_forward&project=im&resource=message&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/mergeForward_message.go
func (m *message) MergeForward(ctx context.Context, req *MergeForwardMessageReq, options ...larkcore.RequestOptionFunc) (*MergeForwardMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/merge_forward"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &MergeForwardMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Patch 更新应用发送的消息
//
// - 更新应用已发送的消息卡片内容。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 若以user_access_token更新消息,该操作用户必须是卡片消息的发送者;- 仅支持对所有人更新**未撤回**的[「共享卡片」](ukTMukTMukTM/uAjNwUjLwYDM14CM2ATN)消息,需在卡片的config属性中,显式声明 =="update_multi":true==。 ;- **不支持更新批量消息**;- 文本消息请求体最大不能超过150KB;卡片及富文本消息请求体最大不能超过30KB;- 仅支持修改14天内发送的消息;- 单条消息更新频控为**5QPS**
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/patch_message.go
func (m *message) Patch(ctx context.Context, req *PatchMessageReq, options ...larkcore.RequestOptionFunc) (*PatchMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// PushFollowUp
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=push_follow_up&project=im&resource=message&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/pushFollowUp_message.go
func (m *message) PushFollowUp(ctx context.Context, req *PushFollowUpMessageReq, options ...larkcore.RequestOptionFunc) (*PushFollowUpMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/push_follow_up"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PushFollowUpMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// ReadUsers 查询消息已读信息
//
// - 查询消息的已读信息。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 只能查询机器人自己发送,且发送时间不超过7天的消息;- 查询消息已读信息时机器人仍需要在会话内;- 本接口不支持查询批量消息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/read_users
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/readUsers_message.go
func (m *message) ReadUsers(ctx context.Context, req *ReadUsersMessageReq, options ...larkcore.RequestOptionFunc) (*ReadUsersMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/read_users"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ReadUsersMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Reply 回复消息
//
// - 回复指定消息,支持文本、富文本、卡片、群名片、个人名片、图片、视频、文件等多种消息类型。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 回复私聊消息,需要机器人对用户有[可用性](https://open.feishu.cn/document/home/introduction-to-scope-and-authorization/availability);- 回复群组消息,需要机器人在群中
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/reply
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/reply_message.go
func (m *message) Reply(ctx context.Context, req *ReplyMessageReq, options ...larkcore.RequestOptionFunc) (*ReplyMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/reply"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ReplyMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Update
//
// - 编辑已发送的消息内容,当前仅支持编辑文本和富文本消息。
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=update&project=im&resource=message&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/update_message.go
func (m *message) Update(ctx context.Context, req *UpdateMessageReq, options ...larkcore.RequestOptionFunc) (*UpdateMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id"
apiReq.HttpMethod = http.MethodPut
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// UrgentApp 发送应用内加急
//
// - 对指定消息进行应用内加急。
//
// - 特别说明:;- 默认接口限流为50 QPS,请谨慎调用
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 不支持加急批量消息;- 只能加急机器人自己发送的消息;- 加急时机器人需要在加急消息所在的群中;- 调用本接口需要用户已阅读加急的消息才可以继续加急(用户未读的加急上限为200条)
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/urgent_app
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/urgentApp_message.go
func (m *message) UrgentApp(ctx context.Context, req *UrgentAppMessageReq, options ...larkcore.RequestOptionFunc) (*UrgentAppMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/urgent_app"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UrgentAppMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// UrgentPhone 发送电话加急
//
// - 对指定消息进行应用内加急与电话加急。
//
// - 特别说明:;- 通过接口产生的电话加急将消耗企业的加急额度,请慎重调用;- 通过[租户管理后台](https://admin.feishu.cn/)-费用中心-短信/电话加急 可以查看当前额度;- 默认接口限流为50 QPS,请谨慎调用
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 只能加急机器人自己发送的消息;- 加急时机器人需要在加急消息所在的群组中;- 需要用户阅读已加急的消息才可以继续加急(用户未读的加急上限为200条)
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/urgent_phone
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/urgentPhone_message.go
func (m *message) UrgentPhone(ctx context.Context, req *UrgentPhoneMessageReq, options ...larkcore.RequestOptionFunc) (*UrgentPhoneMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/urgent_phone"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UrgentPhoneMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// UrgentSms 发送短信加急
//
// - 对指定消息进行应用内加急与短信加急。
//
// - 特别说明:;- 通过接口产生的短信加急将消耗企业的加急额度,请慎重调用;- 通过[租户管理后台](https://admin.feishu.cn/)-费用中心-短信/电话加急 可以查看当前额度;- 默认接口限流为50 QPS,请谨慎调用
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 只能加急机器人自己发送的消息;- 加急时机器人仍需要在加急消息所在的群组中;- 调用本接口需要用户已阅读加急的消息才可以继续加急(用户未读的加急上限为200条)
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/urgent_sms
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/urgentSms_message.go
func (m *message) UrgentSms(ctx context.Context, req *UrgentSmsMessageReq, options ...larkcore.RequestOptionFunc) (*UrgentSmsMessageResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/urgent_sms"
apiReq.HttpMethod = http.MethodPatch
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UrgentSmsMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create 添加消息表情回复
//
// - 给指定消息添加指定类型的表情回复(reaction即表情回复,本文档统一用“reaction”代称)。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 待添加reaction的消息要真实存在,不能被撤回;- 给消息添加reaction,需要reaction的发送方(机器人或者用户)在消息所在的会话内
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-reaction/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_messageReaction.go
func (m *messageReaction) Create(ctx context.Context, req *CreateMessageReactionReq, options ...larkcore.RequestOptionFunc) (*CreateMessageReactionResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/reactions"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateMessageReactionResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 删除消息表情回复
//
// - 删除指定消息的表情回复(reaction即表情回复,本文档统一用“reaction”代称)。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 只能删除真实存在的reaction,并且删除reaction请求的操作者必须是reaction的原始添加者
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-reaction/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_messageReaction.go
func (m *messageReaction) Delete(ctx context.Context, req *DeleteMessageReactionReq, options ...larkcore.RequestOptionFunc) (*DeleteMessageReactionResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/reactions/:reaction_id"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteMessageReactionResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// List 获取消息表情回复
//
// - 获取指定消息的特定类型表情回复列表(reaction即表情回复,本文档统一用“reaction”代称)。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 待获取reaction信息的消息要真实存在,不能被撤回;- 获取消息的reaction,需要request的授权主体(机器人或者用户)在消息所在的会话内
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-reaction/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/list_messageReaction.go
func (m *messageReaction) List(ctx context.Context, req *ListMessageReactionReq, options ...larkcore.RequestOptionFunc) (*ListMessageReactionResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/reactions"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListMessageReactionResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
func (m *messageReaction) ListByIterator(ctx context.Context, req *ListMessageReactionReq, options ...larkcore.RequestOptionFunc) (*ListMessageReactionIterator, error) {
return &ListMessageReactionIterator{
ctx: ctx,
req: req,
listFunc: m.List,
options: options,
limit: req.Limit}, nil
}
// Get 获取消息中的资源文件
//
// - 获取消息中的资源文件,包括音频,视频,图片和文件,**暂不支持表情包资源下载**。当前仅支持 100M 以内的资源文件的下载。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人和消息需要在同一会话中;- 暂不支持获取合并转发消息中的子消息的资源文件
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-resource/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/get_messageResource.go
func (m *messageResource) Get(ctx context.Context, req *GetMessageResourceReq, options ...larkcore.RequestOptionFunc) (*GetMessageResourceResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/messages/:message_id/resources/:file_key"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, m.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetMessageResourceResp{ApiResp: apiResp}
// 如果是下载,则设置响应结果
if apiResp.StatusCode == http.StatusOK {
resp.File = bytes.NewBuffer(apiResp.RawBody)
resp.FileName = larkcore.FileNameByHeader(apiResp.Header)
return resp, err
}
err = apiResp.JSONUnmarshalBody(resp, m.config)
if err != nil {
return nil, err
}
return resp, err
}
// Create Pin消息
//
// - Pin一条指定的消息。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- Pin消息时,机器人必须在对应的群组中;- 若消息已经被Pin,返回该Pin的操作信息;- 不能Pin一条对操作者不可见的消息;- 对同一条消息的Pin操作不能超过==5 QPS==
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/pin/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/create_pin.go
func (p *pin) Create(ctx context.Context, req *CreatePinReq, options ...larkcore.RequestOptionFunc) (*CreatePinResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/pins"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreatePinResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, p.config)
if err != nil {
return nil, err
}
return resp, err
}
// Delete 移除Pin消息
//
// - 移除一条指定消息的Pin。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 移除Pin消息时,机器人必须在对应的群组中;- 若消息未被Pin或已被撤回,返回成功信息;- 不能移除一条对操作者不可见的Pin消息;- 对同一条消息移除Pin的操作不能超过==5 QPS==
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/pin/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/delete_pin.go
func (p *pin) Delete(ctx context.Context, req *DeletePinReq, options ...larkcore.RequestOptionFunc) (*DeletePinResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/pins/:message_id"
apiReq.HttpMethod = http.MethodDelete
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeletePinResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, p.config)
if err != nil {
return nil, err
}
return resp, err
}
// List 获取群内Pin消息
//
// - 获取所在群内指定时间范围内的所有Pin消息。
//
// - 注意事项:;- 需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) ;- 获取Pin消息时,机器人必须在群组中;- 获取的Pin消息按Pin的创建时间降序排列;- 接口默认限流为==50 QPS==
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/pin/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/list_pin.go
func (p *pin) List(ctx context.Context, req *ListPinReq, options ...larkcore.RequestOptionFunc) (*ListPinResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/pins"
apiReq.HttpMethod = http.MethodGet
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListPinResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, p.config)
if err != nil {
return nil, err
}
return resp, err
}
func (p *pin) ListByIterator(ctx context.Context, req *ListPinReq, options ...larkcore.RequestOptionFunc) (*ListPinIterator, error) {
return &ListPinIterator{
ctx: ctx,
req: req,
listFunc: p.List,
options: options,
limit: req.Limit}, nil
}
// Forward
//
// - 转发
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=forward&project=im&resource=thread&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/imv1/forward_thread.go
func (t *thread) Forward(ctx context.Context, req *ForwardThreadReq, options ...larkcore.RequestOptionFunc) (*ForwardThreadResp, error) {
// 发起请求
apiReq := req.apiReq
apiReq.ApiPath = "/open-apis/im/v1/threads/:thread_id/forward"
apiReq.HttpMethod = http.MethodPost
apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ForwardThreadResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, t.config)
if err != nil {
return nil, err
}
return resp, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuhukun/oapi-sdk-go.git
git@gitee.com:zhuhukun/oapi-sdk-go.git
zhuhukun
oapi-sdk-go
oapi-sdk-go
v3.4.51

搜索帮助