forked from larksuite/oapi-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
1718 lines (1658 loc) · 82.6 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package im code generated by oapi sdk gen
/*
* MIT License
*
* Copyright (c) 2022 Lark Technologies Pte. Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package larkim
import (
"bytes"
"context"
"net/http"
"github.com/assassinLL/oapi-sdk-go/v3/core"
)
func NewService(config *larkcore.Config) *ImService {
i := &ImService{config: config}
i.BatchMessage = &batchMessage{service: i}
i.Chat = &chat{service: i}
i.ChatAnnouncement = &chatAnnouncement{service: i}
i.ChatManagers = &chatManagers{service: i}
i.ChatMemberBot = &chatMemberBot{service: i}
i.ChatMemberUser = &chatMemberUser{service: i}
i.ChatMembers = &chatMembers{service: i}
i.ChatMenuItem = &chatMenuItem{service: i}
i.ChatMenuTree = &chatMenuTree{service: i}
i.ChatModeration = &chatModeration{service: i}
i.ChatTab = &chatTab{service: i}
i.ChatTopNotice = &chatTopNotice{service: i}
i.File = &file{service: i}
i.Image = &image{service: i}
i.Message = &message{service: i}
i.MessageReaction = &messageReaction{service: i}
i.MessageResource = &messageResource{service: i}
i.Pin = &pin{service: i}
return i
}
type ImService struct {
config *larkcore.Config
BatchMessage *batchMessage // 消息 - 批量消息
Chat *chat // 群组
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
}
type batchMessage struct {
service *ImService
}
type chat struct {
service *ImService
}
type chatAnnouncement struct {
service *ImService
}
type chatManagers struct {
service *ImService
}
type chatMemberBot struct {
service *ImService
}
type chatMemberUser struct {
service *ImService
}
type chatMembers struct {
service *ImService
}
type chatMenuItem struct {
service *ImService
}
type chatMenuTree struct {
service *ImService
}
type chatModeration struct {
service *ImService
}
type chatTab struct {
service *ImService
}
type chatTopNotice struct {
service *ImService
}
type file struct {
service *ImService
}
type image struct {
service *ImService
}
type message struct {
service *ImService
}
type messageReaction struct {
service *ImService
}
type messageResource struct {
service *ImService
}
type pin struct {
service *ImService
}
// 批量撤回消息
//
// - 批量撤回通过[批量发送消息](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 查询批量消息整体进度
//
// - 该接口在[查询批量消息推送和阅读人数](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetProgressBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 查询批量消息推送和阅读人数
//
// - 批量发送消息后,可以通过该接口查询批量消息推送的总人数和阅读人数。
//
// - 注意事项:;- 只能查询通过[批量发送消息](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ReadUserBatchMessageResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, b.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 创建群
//
// - 创建群并设置群头像、群名、群描述等。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 解散群
//
// - 解散群组。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群信息
//
// - 获取群名称、群描述、群头像、群主 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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群分享链接
//
// - 获取指定群的分享链接。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &LinkChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取用户或机器人所在的群列表
//
// - 获取用户或者机器人所在群列表。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.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
}
// 搜索对用户或机器人可见的群列表
//
// - 搜索对用户或机器人可见的群列表,包括:用户或机器人所在的群、对用户或机器人公开的群。;搜索可获得的群信息包括:群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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SearchChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.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
}
// 更新群信息
//
// - 更新群头像、群名称、群描述、群配置、转让群主等。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateChatResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群公告信息
//
// - 获取会话中的群公告信息,公告信息格式与[云文档](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatAnnouncementResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 更新群公告信息
//
// - 更新会话中的群公告信息,更新公告信息的格式和更新[云文档](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PatchChatAnnouncementResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 指定群管理员
//
// - 将用户或机器人指定为群管理员。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &AddManagersChatManagersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 删除群管理员
//
// - 删除指定的群管理员(用户或机器人)。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteManagersChatManagersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 将用户或机器人拉入群聊
//
// - 将用户或机器人拉入群聊。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 将用户或机器人移出群聊
//
// - 将用户或机器人移出群聊。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群成员列表
//
// - 获取用户/机器人所在群的群成员列表。
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.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
}
// 判断用户或机器人是否在群里
//
// - 根据使用的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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &IsInChatChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 用户或机器人主动加入群聊
//
// - 用户或机器人主动加入群聊。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &MeJoinChatMembersResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 修改群菜单元信息
//
// - 修改某个一级菜单或者二级菜单的元信息。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &PatchChatMenuItemResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 添加群菜单
//
// - 向群内添加群菜单。
//
// - 注意事项:;- 该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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 删除群菜单。
//
// - 删除群内菜单。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群内菜单
//
// - 通过群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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 排序群菜单
//
// - 给一个群内的一级菜单排序。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SortChatMenuTreeResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 获取群成员发言权限
//
// - 获取群发言模式、可发言用户名单等
//
// - 注意事项:; - 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &GetChatModerationResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.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
}
// 更新群发言权限
//
// - 更新群组的发言权限设置,可设置为全员可发言、仅管理员可发言 或 指定用户可发言。
//
// - 注意事项:; - 需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &UpdateChatModerationResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 添加会话标签页
//
// - 添加自定义会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &CreateChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 删除会话标签页
//
// - 删除会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &DeleteTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 拉取会话标签页
//
// - 拉取会话标签页。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &ListTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 会话标签页排序
//
// - 会话标签页排序。
//
// - 注意事项:;- 应用需要开启[机器人能力](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/assassinLL/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.service.config, options...)
if err != nil {
return nil, err
}
// 反序列响应结果
resp := &SortTabsChatTabResp{ApiResp: apiResp}
err = apiResp.JSONUnmarshalBody(resp, c.service.config)
if err != nil {
return nil, err
}
return resp, err
}
// 更新会话标签页
//
// - 更新会话标签页
//
// - 注意事项:;- 应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability);- 机器人或授权用户必须在群里;- 只允许更新类型为`doc`和`url`的会话标签页;- 更新doc类型时,操作者(access token对应的身份)需要拥有对应文档的权限;- 在开启 ==仅群主和管理员可管理标签页== 的设置时,仅群主和群管理员可以更新会话标签页;- 操作内部群时,操作者须与群组在同一租户下