chat

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const AddMemberAPI = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/members"
View Source
const CreateAPI = "https://open.feishu.cn/open-apis/im/v1/chats"
View Source
const GetAnnouncementAPI = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/announcement"
View Source
const RemoveMemberAPI = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/members"
View Source
const UpdateAPI = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id"
View Source
const UpdateAnnouncementAPI = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/announcement"

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMemberRequest

type AddMemberRequest struct {
	// 群 ID
	ChatID string

	// 进群成员 ID 类型 open_id/user_id/union_id/app_id
	// 注意:拉机器人入群请使用 app_id
	// 示例值:"open_id"
	MemberIDType string

	// 出现不可用ID后的处理方式 0/1/2
	// 示例值:0
	SucceedType string

	// 成员ID列表,获取ID请参见如何获得 User ID、Open ID 和 Union ID?
	IDList []string
}

type AddMemberResponse

type AddMemberResponse struct {
	InvalidIDList    []string `json:"invalid_id_list"`
	NotExistedIDList []string `json:"not_existed_id_list"`
}

func AddMember

func AddMember(client client.Client, req *AddMemberRequest) (resp *AddMemberResponse, err error)

type Chat

type Chat interface {
	Create(name string, description string, userIds []string) (string, error)
}

type CreateRequest

type CreateRequest struct {
	// 群名称
	Name string

	// 群描述
	Description string

	// 群头像对应的 Image Key,可通过上传图片获取(注意:上传图片的 image_type 需要指定为 avatar)
	// 示例值:"default-avatar_44ae0ca3-e140-494b-956f-78091e348435"
	// 上传图片:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/create
	Avatar string

	// 创建群时指定的群主,不填时指定建群的机器人为群主。
	// 群主 ID,ID值与查询参数中的 user_id_type 对应。
	OwnerID string

	// 创建群时邀请的群成员,id 类型为 user_id_type
	// 最大长度:50
	UserIDList []string

	// 创建群时邀请的群机器人
	// 最大长度:5
	BotIDList []string

	// 群模式,可选值:
	// group
	// topic
	ChatMode string

	// 群类型,可选值:
	// private - 私有群
	// public - 公开群
	ChatType string

	// 是否是外部群;若群组需要邀请不同租户的用户或机器人,请指定为外部群;
	// 示例值:false
	// 默认值:false
	External string `json:"external"`

	// 入群消息可见性
	// 可选值有:
	// only_owner:仅群主和管理员可见
	// all_members:所有成员可见
	// not_anyone:任何人均不可见
	// 示例值:"only_owner"
	JoinMessageVisibility string `json:"join_message_visibility"`

	// 出群消息可见性
	// 可选值有:
	// only_owner:仅群主和管理员可见
	// all_members:所有成员可见
	// not_anyone:任何人均不可见
	// 示例值:"only_owner"
	LeaveMessageVisibility string `json:"leave_message_visibility"`

	// 加群审批
	// 可选值有:
	// no_approval_required:无需审批
	// approval_required:需要审批
	// 示例值:"no_approval_required"
	MembershipApproval string `json:"membership_approval"`
}

type CreateResponse

type CreateResponse struct {
	ChatID      string `json:"chat_id"`
	Avatar      string `json:"avatar"`
	Name        string `json:"name"`
	Description string `json:"description"`
	I18nNames   struct {
		ZhCN string `json:"zh_cn"`
		EnUS string `json:"en_us"`
		JaJP string `json:"ja_jp"`
	}
	OwnerID                string `json:"owner_id"`
	AddMemberPermission    string `json:"add_member_permission"`
	ShareCardPermission    string `json:"share_card_permission"`
	AtAllPermission        string `json:"at_all_permission"`
	ChatMode               string `json:"chat_mode"`
	ChatType               string `json:"chat_type"`
	ChatTag                string `json:"chat_tag"`
	External               bool   `json:"external"`
	TenantKey              string `json:"tenant_key"`
	JoinMessageVisibility  string `json:"join_message_visibility"`
	LeaveMessageVisibility string `json:"leave_message_visibility"`
	MembershipApproval     string `json:"membership_approval"`
	ModerationPermission   string `json:"moderation_permission"`
}

func Create

func Create(client client.Client, req *CreateRequest) (resp *CreateResponse, err error)

type GetAnnouncementRequest

type GetAnnouncementRequest struct {
	// 待获取公告的群 ID,详情参见群ID 说明
	// 注意:不支持P2P单聊
	// 示例值:"oc_5ad11d72b830411d72b836c20"
	ChatID string `json:"chat_id"`

	// 用户 ID 类型
	// 示例值:"open_id"
	// 可选值有:
	// open_id:用户的 open id
	// union_id:用户的 union id
	// user_id:用户的 user id
	// 默认值:open_id
	UserIDType string `json:"user_id_type"`
}

type GetAnnouncementResponse

type GetAnnouncementResponse struct {
	// 云文档序列化信息
	Content string `json:"content"`

	// 文档当前版本号 纯数字
	Revision string `json:"revision"`

	// 文档生成的时间戳(秒)
	CreateTime string `json:"create_time"`

	// 文档更新时间戳(秒)
	UpdateTime string `json:"update_time"`

	// 文档所有者的 ID 类型
	// 如果所有者是用户,则与查询参数中的user_id_type 相同;取值为open_id user_id union_id 其中之一,不同 ID 的说明参见 用户相关的 ID 概念
	// 如果所有者是机器人,为机器人应用的 app_id,详情参见 获取应用身份访问凭证
	// 可选值有:
	// user_id:以 user_id 来识别用户
	// union_id:以 union_id 来识别用户
	// open_id:以 open_id 来识别用户
	// app_id:以 app_id 来识别机器人应用
	OwnerIDType string `json:"owner_id_type"`

	// 文档所有者 ID,ID 值与owner_id_type 中的ID类型对应
	OwnerID string `json:"owner_id"`

	// 文档最新修改者 id 类型
	// 如果修改者是用户,则与查询参数中的user_id_type 相同;取值为open_id user_id union_id 其中之一,不同 ID 的说明参见 用户相关的 ID 概念
	// 如果修改者是机器人,为机器人应用的 app_id,详情参见 获取应用身份访问凭证
	// 可选值有:
	// user_id:以 user_id 来识别用户
	// union_id:以 union_id 来识别用户
	// open_id:以 open_id 来识别用户
	// app_id:以 app_id 来识别应用
	ModifierIDType string `json:"modifier_id_type"`

	// 文档最新修改者 ID,ID 值与modifier_id_type 中的ID类型对应
	ModifierID string `json:"modifier_id"`
}

func GetAnnouncement

func GetAnnouncement(client client.Client, req *GetAnnouncementRequest) (resp *GetAnnouncementResponse, err error)

type RemoveMemberRequest

type RemoveMemberRequest struct {
	// 群 ID
	ChatID string

	// 进群成员 ID 类型 open_id/user_id/union_id/app_id
	// 注意:拉机器人入群请使用 app_id
	// 示例值:"open_id"
	MemberIDType string

	// 成员ID列表,获取ID请参见如何获得 User ID、Open ID 和 Union ID?
	IDList []string
}

type RemoveMemberResponse

type RemoveMemberResponse struct {
	InvalidIDList []string `json:"invalid_id_list"`
}

func RemoveMember

func RemoveMember(client client.Client, req *RemoveMemberRequest) (resp *RemoveMemberResponse, err error)

type SendMessageRequest

type SendMessageRequest struct {
	// 群 ID
	ChatID string `json:"chat_id"`

	// 消息类型 包括:text、post、image、file、audio、media、sticker、interactive、share_chat、share_user等
	// 类型定义请参考发送消息content说明(https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json
	// 示例值:"text"
	MsgType string `json:"msg_type"`

	// 消息内容,json结构序列化后的字符串。不同msg_type对应不同内容。消息类型 包括:text、post、image、file、audio、media、sticker、interactive、share_chat、share_user等
	// 具体格式说明参考:发送消息content说明(https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json
	Content string `json:"content"`
}

type SendMessageResponse

type SendMessageResponse = message.SendResponse

func SendMessage

func SendMessage(client client.Client, req *SendMessageRequest) (resp *SendMessageResponse, err error)

type UpdateAnnouncementRequest

type UpdateAnnouncementRequest struct {
	// 待获取公告的群 ID,详情参见群ID 说明
	// 注意:不支持P2P单聊
	// 示例值:"oc_5ad11d72b830411d72b836c20"
	ChatID string `json:"chat_id"`

	// 文档当前版本号 int64 类型,获取群公告信息接口会返回
	// 示例值:"12"
	Revision string `json:"revision"`

	// 修改文档请求的序列化字段
	// 更新公告信息的格式和更新云文档格式相同
	Requests []string `json:"requests"`

	Content []string `json:"content"`
}

type UpdateAnnouncementResponse

type UpdateAnnouncementResponse struct {
	// 云文档序列化信息
	Content string `json:"content"`

	// 文档当前版本号 纯数字
	Revision string `json:"revision"`

	// 文档生成的时间戳(秒)
	CreateTime string `json:"create_time"`

	// 文档更新时间戳(秒)
	UpdateTime string `json:"update_time"`

	// 文档所有者的 ID 类型
	// 如果所有者是用户,则与查询参数中的user_id_type 相同;取值为open_id user_id union_id 其中之一,不同 ID 的说明参见 用户相关的 ID 概念
	// 如果所有者是机器人,为机器人应用的 app_id,详情参见 获取应用身份访问凭证
	// 可选值有:
	// user_id:以 user_id 来识别用户
	// union_id:以 union_id 来识别用户
	// open_id:以 open_id 来识别用户
	// app_id:以 app_id 来识别机器人应用
	OwnerIDType string `json:"owner_id_type"`

	// 文档所有者 ID,ID 值与owner_id_type 中的ID类型对应
	OwnerID string `json:"owner_id"`

	// 文档最新修改者 id 类型
	// 如果修改者是用户,则与查询参数中的user_id_type 相同;取值为open_id user_id union_id 其中之一,不同 ID 的说明参见 用户相关的 ID 概念
	// 如果修改者是机器人,为机器人应用的 app_id,详情参见 获取应用身份访问凭证
	// 可选值有:
	// user_id:以 user_id 来识别用户
	// union_id:以 union_id 来识别用户
	// open_id:以 open_id 来识别用户
	// app_id:以 app_id 来识别应用
	ModifierIDType string `json:"modifier_id_type"`

	// 文档最新修改者 ID,ID 值与modifier_id_type 中的ID类型对应
	ModifierID string `json:"modifier_id"`
}

func UpdateAnnouncement

func UpdateAnnouncement(client client.Client, req *UpdateAnnouncementRequest) (resp *UpdateAnnouncementResponse, err error)

type UpdateRequest

type UpdateRequest struct {
	// 群 ID
	ChatID string `json:"chat_id"`

	// 用户 ID 类型
	// 示例值:"open_id"
	// 可选值有:
	// open_id:用户的 open id
	// union_id:用户的 union id
	// user_id:用户的 user id
	UserIDType string `json:"user_id_type"`

	// 群名称
	Name string `json:"name"`

	// 群描述
	Description string `json:"description"`

	// 群头像对应的 Image Key,可通过上传图片获取(注意:上传图片的 image_type 需要指定为 avatar)
	// 示例值:"default-avatar_44ae0ca3-e140-494b-956f-78091e348435"
	// 上传图片:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/create
	Avatar string `json:"avatar"`

	// 邀请用户或机器人入群权限
	// 可选值有:
	// only_owner:仅群主和管理员
	// all_members:所有成员
	AddMemberPermission string `json:"add_member_permission"`

	// 群分享权限
	// 可选值有:
	// allowed:允许
	// not_allowed:不允许
	ShareCardPermission string `json:"share_card_permission"`

	// at 所有人权限
	// 可选值有:
	// only_owner:仅群主和管理员
	// all_members:所有成员
	// 示例值:"all_members"
	AtAllPermission string `json:"at_all_permission"`

	// 群编辑权限
	// 可选值有:
	// only_owner:仅群主和管理员
	// all_members:所有成员
	// 示例值:"all_members"
	EditPermission string `json:"edit_permission"`

	// 创建群时指定的群主,不填时指定建群的机器人为群主。
	// 群主 ID,ID值与查询参数中的 user_id_type 对应。
	OwnerID string

	// 入群消息可见性
	// 可选值有:
	// only_owner:仅群主和管理员可见
	// all_members:所有成员可见
	// not_anyone:任何人均不可见
	// 示例值:"only_owner"
	JoinMessageVisibility string `json:"join_message_visibility"`

	// 出群消息可见性
	// 可选值有:
	// only_owner:仅群主和管理员可见
	// all_members:所有成员可见
	// not_anyone:任何人均不可见
	// 示例值:"only_owner"
	LeaveMessageVisibility string `json:"leave_message_visibility"`

	// 加群审批
	// 可选值有:
	// no_approval_required:无需审批
	// approval_required:需要审批
	// 示例值:"no_approval_required"
	MembershipApproval string `json:"membership_approval"`

	// 群类型,可选值:
	// private - 私有群
	// public - 公开群
	ChatType string
}

type UpdateResponse

type UpdateResponse struct {
	Avatar      string `json:"avatar"`
	Name        string `json:"name"`
	Description string `json:"description"`
	I18nNames   struct {
		ZhCN string `json:"zh_cn"`
		EnUS string `json:"en_us"`
		JaJP string `json:"ja_jp"`
	}
	OwnerID                string `json:"owner_id"`
	AddMemberPermission    string `json:"add_member_permission"`
	ShareCardPermission    string `json:"share_card_permission"`
	AtAllPermission        string `json:"at_all_permission"`
	ChatType               string `json:"chat_type"`
	JoinMessageVisibility  string `json:"join_message_visibility"`
	LeaveMessageVisibility string `json:"leave_message_visibility"`
	MembershipApproval     string `json:"membership_approval"`
}

func Update

func Update(client client.Client, req *UpdateRequest) (resp *UpdateResponse, err error)

Jump to

Keyboard shortcuts

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