tencentcloud_im

package module
v0.0.0-...-9935dc6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

README

TencentCloud IM

FOSSA Status

A Go SDK for TencentCloud IM.

Features:

  • No nonsense precompiled dynamic library
  • Signature generation with openssl-go
  • Sane API
  • First class support for context.Context

Todo:

  • Complete API
  • More tests

Security

If you find any security venerability, please send an encrypted mail to email with GPG ID 0xB29A14086516184D. You can encrypt your mail to me on Keybase if you don't know how to use GPG.

License

FOSSA Status

Documentation

Index

Constants

View Source
const (
	Service_IM_OPEN_LOGIN_SVC   = "im_open_login_svc"
	Service_OPEN_IM             = "openim"
	Service_PROFILE             = "profile"
	Service_GROUP_OPEN_HTTP_SVC = "group_open_http_svc"
)
View Source
const (
	// im_open_login_svc
	Command_ACCOUNT_IMPORT      = "account_import"
	Command_MULTIACCOUNT_IMPORT = "multiaccount_import"
	Command_KICK                = "kick"
	// openim
	Command_SEND_MSG       = "sendmsg"
	Command_BATCH_SEND_MSG = "batchsendmsg"
	Command_QUERY_STATE    = "querystate"
	// profile
	Command_PORTRAIT_SET = "portrait_set"
	// group_open_http_svc
	Command_CREATE_GROUP             = "create_group"
	Command_ADD_GROUP_MEMBER         = "add_group_member"
	Command_GROUP_MSG_GET_SIMPLE     = "group_msg_get_simple"
	Command_GET_GROUP_MEMBER_INFO    = "get_group_member_info"
	Command_DELETE_GROUP_MEMBER      = "delete_group_member"
	Command_MODIFY_GROUP_MEMBER_INFO = "modify_group_member_info"
	Command_MODIFY_GROUP_BASE_INFO   = "modify_group_base_info"
	Command_CHANGE_GROUP_OWNER       = "change_group_owner"
	Command_SEND_GROUP_MSG           = "send_group_msg"
)
View Source
const (
	GroupMsgPriorityHigh   GroupMsgPriority = "High"
	GroupMsgPriorityNormal                  = "Normal"
	GroupMsgPriorityLow                     = "Low"
	GroupMsgPriorityLowest                  = "Lowest"
)
View Source
const (
	MsgType_TIMTextElem     MsgType = "TIMTextElem"
	MsgType_TIMFaceElem             = "TIMFaceElem"
	MsgType_TIMLocationElem         = "TIMLocationElem"
	MsgType_TIMCustomElem           = "TIMCustomElem"
)
View Source
const (
	ProfileTag_Tag_Profile_IM_Nick            ProfileTag = "Tag_Profile_IM_Nick"
	ProfileTag_Tag_Profile_IM_Gender                     = "Tag_Profile_IM_Gender"
	ProfileTag_Tag_Profile_IM_BirthDay                   = "Tag_Profile_IM_BirthDay"
	ProfileTag_Tag_Profile_IM_Location                   = "Tag_Profile_IM_Location"
	ProfileTag_Tag_Profile_IM_SelfSignature              = "Tag_Profile_IM_SelfSignature"
	ProfileTag_Tag_Profile_IM_AllowType                  = "Tag_Profile_IM_AllowType"
	ProfileTag_Tag_Profile_IM_Language                   = "Tag_Profile_IM_Language"
	ProfileTag_Tag_Profile_IM_Image                      = "Tag_Profile_IM_Image"
	ProfileTag_Tag_Profile_IM_MsgSettings                = "Tag_Profile_IM_MsgSettings"
	ProfileTag_Tag_Profile_IM_AdminForbidType            = "Tag_Profile_IM_AdminForbidType"
	ProfileTag_Tag_Profile_IM_Level                      = "Tag_Profile_IM_Level"
	ProfileTag_Tag_Profile_IM_Role                       = "Tag_Profile_IM_Role"
)

Variables

This section is empty.

Functions

func DoNotSyncToFromAccount

func DoNotSyncToFromAccount() doNotSyncToFromAccount

func SetFromAccount

func SetFromAccount(from string) sendGroupMsgRequestOptFunc

Types

type APNSOfflinePushInfo

type APNSOfflinePushInfo struct {
	// 离线推送声音文件路径。
	Sound string `json:"Sound"`
	// 这个字段缺省或者为 0 表示需要计数,为 1 表示本条消息不需要计数,即右上角图标数字不增加
	BadgeMode int `json:"BadgeMode"`
	// 该字段用于标识apns推送的标题,若填写则会覆盖最上层Title
	Title string `json:"Title"`
	// 该字段用于标识apns推送的子标题
	SubTitle string `json:"SubTitle"`
	// 该字段用于标识apns携带的图片地址,当客户端拿到该字段时,可以通过下载图片资源的方式将图片展示在弹窗上
	Image string `json:"Image"`
}

type AccountImportRequest

type AccountImportRequest struct {
	Identifier string `json:"Identifier"`
	Nick       string `json:"Nick"`
	FaceURL    string `json:"FaceUrl"`
	Type       int    `json:"Type"`
}

type AddGroupMemberOpt

type AddGroupMemberOpt interface {
	ApplyToAddGroupMemberRequest(req *AddGroupMemberRequest)
}

type AddGroupMemberRequest

type AddGroupMemberRequest struct {
	GroupId    string                `json:"GroupId"`
	Silence    int                   `json:"Silence,omitempty"`
	MemberList []types.MinimalMember `json:"MemberList"`
}

type AddGroupMemberResponse

type AddGroupMemberResponse struct {
	IMResponse
	MemberList []AddGroupMemberResultItem `json:"MemberList"`
}

type AddGroupMemberResultItem

type AddGroupMemberResultItem struct {
	Member_Account string `json:"Member_Account"`
	Result         int    `json:"Result"`
}

type AndroidOfflinePushInfo

type AndroidOfflinePushInfo struct {
	// 离线推送声音文件路径。
	Sound string `json:"Sound"`
}

type AppMemberDefinedDataItem

type AppMemberDefinedDataItem struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

type BatchSendMsgOpt

type BatchSendMsgOpt interface {
	ApplyToBatchSendMsgRequest(req *BatchSendMsgRequest)
}

type BatchSendMsgRequest

type BatchSendMsgRequest struct {
	// 1:把消息同步到 From_Account 在线终端和漫游上;
	// 2:消息不同步至 From_Account;若不填写默认情况下会将消息存 From_Account 漫游
	SyncOtherMachine SyncSetting `json:"SyncOtherMachine,omitempty"`
	// 消息发送方帐号。(用于指定发送消息方帐号)
	FromAccount string `json:"From_Account,omitempty"`
	// 必填,消息接收方帐号。
	ToAccount []string `json:"To_Account"`
	// 必填,消息随机数,由随机函数产生。(用作消息去重)(
	// NOTE(QuantumGhost): 这个字段会在初始化的时候自懂添加
	MsgRandom int `json:"MsgRandom"`
	// 必填,消息内容,具体格式请参考 [消息格式描述](http://bit.ly/2ARGSfV)。
	// (注意,一条消息可包括多种消息元素,MsgBody 为 Array 类型)
	MsgBody []MsgBody `json:"MsgBody"`
	// 离线推送信息配置,具体可参考 [消息格式描述](http://bit.ly/2AMK9NQ)。
	OfflinePushInfo *OfflinePushInfo `json:"OfflinePushInfo,omitempty"`
}

type ChangeGroupOwnerRequest

type ChangeGroupOwnerRequest struct {
	GroupID         string `json:"GroupId"`
	NewOwnerAccount string `json:"NewOwner_Account"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(appId int, identifier string, urlsig string) *Client

func (*Client) AccountImport

func (c *Client) AccountImport(ctx context.Context, request AccountImportRequest) *IMResponse

func (*Client) AddGroupMember

func (c *Client) AddGroupMember(ctx context.Context, groupId string, im_ids []string, opts ...AddGroupMemberOpt) *AddGroupMemberResponse

func (*Client) BatchSendMsg

func (c *Client) BatchSendMsg(ctx context.Context, from string, to []string, bodies []MsgBody, opts ...BatchSendMsgOpt) *IMResponse

func (*Client) ChangeGroupOwner

func (c *Client) ChangeGroupOwner(ctx context.Context, groupId string, imId string) *IMResponse

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, name string, groupType consts.GroupType, opts ...CreateGroupOpt) *CreateGroupResponse

func (*Client) DeleteGroupMember

func (c *Client) DeleteGroupMember(ctx context.Context, groupId string, imIds []string, opts ...DeleteGroupMemberOpt) *IMResponse

func (*Client) GetGroupMemberInfo

func (c *Client) GetGroupMemberInfo(ctx context.Context, groupId string, opts ...GetGroupMemberInfoOpt) *GetGroupMemberInfoResponse

func (*Client) GroupMsgGetSimple

func (c *Client) GroupMsgGetSimple(ctx context.Context, groupId string, msgNumber int, seq *int) *GroupMsgGetSimpleResponse

func (*Client) Kick

func (c *Client) Kick(ctx context.Context, identifier string) *IMResponse

func (*Client) ModifyGroupBaseInfo

func (c *Client) ModifyGroupBaseInfo(ctx context.Context, groupId string, opts ...ModifyGroupBaseInfoOpt) *IMResponse

func (*Client) ModifyGroupMemberInfo

func (c *Client) ModifyGroupMemberInfo(ctx context.Context, groupId string, imId string, opts ...ModifyGroupMemberInfoOpt) *IMResponse

func (*Client) MultiAccountImport

func (c *Client) MultiAccountImport(ctx context.Context, identifiers []string) *MultiAccountImportResponse

func (*Client) PortraitSet

func (c *Client) PortraitSet(ctx context.Context, accountId string, items []ProfileItem) *PortraitSetResponse

func (*Client) SendGroupMsg

func (c *Client) SendGroupMsg(ctx context.Context, groupId string, msgBody []MsgBody, opts ...SendGroupMsgRequestOpt) *SendGroupMsgResponse

func (*Client) SendMsg

func (c *Client) SendMsg(ctx context.Context, from string, to string, bodies []MsgBody, opts ...SendMsgOpt) *IMResponse

func (*Client) SetClient

func (c *Client) SetClient(client *resty.Client)

type CreateGroupMemberItem

type CreateGroupMemberItem struct {
	Member_Account       string                     `json:"Member_Account"`
	Role                 consts.GroupRole           `json:"Role,omitempty"`
	AppMemberDefinedData []AppMemberDefinedDataItem `json:"AppMemberDefinedData,omitempty"`
}

type CreateGroupOpt

type CreateGroupOpt interface {
	ApplyToCreateGroupRequest(req *CreateGroupRequest)
}

type CreateGroupRequest

type CreateGroupRequest struct {
	// required
	Type consts.GroupType `json:"Type"`
	Name string           `json:"Name,omitempty"`
	// optional
	Owner_Account   string                    `json:"Owner_Account,omitempty"`
	GroupId         string                    `json:"GroupId,omitempty"`
	Introduction    string                    `json:"Introduction,omitempty"`
	Notification    string                    `json:"Notification,omitempty"`
	FaceUrl         string                    `json:"FaceUrl,omitempty"`
	MaxMemberCount  int                       `json:"MaxMemberCount,omitempty"`
	ApplyJoinOption consts.ApplyJoinOption    `json:"ApplyJoinOption,omitempty"`
	AppDefinedData  []GroupAppDefinedDataItem `json:"AppDefinedData,omitempty"`
	MemberList      []CreateGroupMemberItem   `json:"MemberList,omitempty"`
}

type CreateGroupResponse

type CreateGroupResponse struct {
	IMResponse
	GroupId string `json:"GroupId"`
}

type DeleteGroupMemberOpt

type DeleteGroupMemberOpt interface {
	ApplyToDeleteGroupMemberRequest(request *DeleteGroupMemberRequest)
}

type DeleteGroupMemberRequest

type DeleteGroupMemberRequest struct {
	GroupID            string   `json:"GroupId"`
	Silence            int64    `json:"Silence"`
	Reason             string   `json:"Reason"`
	MemberToDelAccount []string `json:"MemberToDel_Account"`
}

type GetGroupMemberInfoOpt

type GetGroupMemberInfoOpt interface {
	ApplyToGetGroupMemberInfoRequest(req *GetGroupMemberInfoRequest)
}

type GetGroupMemberInfoRequest

type GetGroupMemberInfoRequest struct {
	GroupId                          string   `json:"GroupId"`
	MemberInfoFilter                 []string `json:"MemberInfoFilter,omitempty"`
	MemberRoleFilter                 []string `json:"MemberRoleFilter,omitempty"`
	AppDefinedDataFilter_GroupMember []string `json:"AppDefinedDataFilter_GroupMember,omitempty"`
	Limit                            int      `json:"Limit,omitempty"`
	Offset                           int      `json:"Offset,omitempty"`
}

type GetGroupMemberInfoResponse

type GetGroupMemberInfoResponse struct {
	IMResponse
	MemberNum  int               `json:"MemberNum"`
	MemberList []GroupMemberItem `json:"MemberList"`
}

type GroupAppDefinedDataItem

type GroupAppDefinedDataItem struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

type GroupMemberItem

type GroupMemberItem struct {
	MemberAccount        string                    `json:"Member_Account"`
	Role                 string                    `json:"Role"`
	JoinTime             int                       `json:"JoinTime"`
	MsgSeq               int                       `json:"MsgSeq"`
	MsgFlag              string                    `json:"MsgFlag"`
	LastSendMsgTime      int                       `json:"LastSendMsgTime"`
	ShutUpUntil          int                       `json:"ShutUpUntil"`
	AppMemberDefinedData []GroupAppDefinedDataItem `json:"AppMemberDefinedData"`
}

type GroupMessageItem

type GroupMessageItem struct {
	FromAccount  string         `json:"From_Account"`
	IsPlaceMsg   int            `json:"IsPlaceMsg"`
	MsgBody      []GroupMsgBody `json:"MsgBody"`
	MsgRandom    int            `json:"MsgRandom"`
	MsgSeq       int            `json:"MsgSeq"`
	MsgTimeStamp int            `json:"MsgTimeStamp"`
}

type GroupMsgBody

type GroupMsgBody struct {
	MsgContent GroupMsgContent `json:"MsgContent"`
	MsgType    string          `json:"MsgType"`
}

type GroupMsgContent

type GroupMsgContent struct {
	Data string `json:"Data"`
	Desc string `json:"Desc"`
	Ext  string `json:"Ext"`
}

type GroupMsgGetSimpleRequest

type GroupMsgGetSimpleRequest struct {
	GroupId      string `json:"GroupId"`
	ReqMsgNumber int    `json:"ReqMsgNumber"`
	ReqMsgSeq    *int   `json:"ReqMsgSeq,omitempty"`
}

type GroupMsgGetSimpleResponse

type GroupMsgGetSimpleResponse struct {
	IMResponse
	IsFinished int                `json:"IsFinished"`
	RspMsgList []GroupMessageItem `json:"RspMsgList"`
}

type GroupMsgPriority

type GroupMsgPriority string

type IMError

type IMError interface {
	error
	ErrorInfo() string
	ErrorCode() int
}

func ToIMError

func ToIMError(err error) (IMError, bool)

type IMResponse

type IMResponse struct {
	ActionStatus string `json:"ActionStatus"`
	ErrorInfo    string `json:"ErrorInfo"`
	ErrorCode    int    `json:"errorCode"`
	// contains filtered or unexported fields
}

func (*IMResponse) Error

func (r *IMResponse) Error() error

type ModifyGroupBaseInfoOpt

type ModifyGroupBaseInfoOpt interface {
	ApplyModifyGroupBaseInfoRequest(req *ModifyGroupBaseInfoRequest)
}

type ModifyGroupBaseInfoRequest

type ModifyGroupBaseInfoRequest struct {
	GroupID         string                    `json:"GroupId"`
	Name            string                    `json:"Name,omitempty"`
	Introduction    string                    `json:"Introduction,omitempty"`
	Notification    string                    `json:"Notification,omitempty"`
	FaceURL         string                    `json:"FaceUrl,omitempty"`
	MaxMemberNum    int64                     `json:"MaxMemberNum,omitempty"`
	ApplyJoinOption consts.ApplyJoinOption    `json:"ApplyJoinOption,omitempty"`
	ShutUpAllMember string                    `json:"ShutUpAllMember,omitempty"`
	AppDefinedData  []GroupAppDefinedDataItem `json:"AppDefinedData,omitempty"`
}

type ModifyGroupMemberInfoOpt

type ModifyGroupMemberInfoOpt interface {
	ApplyToModifyGroupMemberInfoRequest(request *ModifyGroupMemberInfoRequest)
}

type ModifyGroupMemberInfoRequest

type ModifyGroupMemberInfoRequest struct {
	GroupID              string                    `json:"GroupId"`
	MemberAccount        string                    `json:"Member_Account"`
	Role                 consts.GroupRole          `json:"Role,omitempty"`
	MsgFlag              string                    `json:"MsgFlag,omitempty"`
	NameCard             string                    `json:"NameCard,omitempty"`
	AppMemberDefinedData []GroupAppDefinedDataItem `json:"AppMemberDefinedData,omitempty"`
}

type MsgBody

type MsgBody interface {
	Type() MsgType
}

marker interface

func NewCustomMsgBody

func NewCustomMsgBody(desc, ext, data, sound string) MsgBody

func NewTextMsgBody

func NewTextMsgBody(body string) MsgBody

type MsgType

type MsgType string

type MultiAccountImportResponse

type MultiAccountImportResponse struct {
	IMResponse
	FailAccounts []string `json:"FailAccounts"`
}

type OfflinePushInfo

type OfflinePushInfo struct {
	// 0表示推送,1表示不离线推送。
	PushFlag int `json:"PushFlag"`
	// 离线推送标题。该字段为ios和android共用
	Title string `json:"Title"`
	// 离线推送内容 。
	Desc string `json:"Desc"`
	// 离线推送透传内容。
	Ext string `json:"Ext"`
	//
	AndroidInfo AndroidOfflinePushInfo `json:"AndroidInfo"`
	ApnsInfo    APNSOfflinePushInfo    `json:"ApnsInfo"`
}

func (*OfflinePushInfo) ApplyToBatchSendMsgRequest

func (o *OfflinePushInfo) ApplyToBatchSendMsgRequest(req *BatchSendMsgRequest)

func (*OfflinePushInfo) ApplyToSendMsgRequest

func (o *OfflinePushInfo) ApplyToSendMsgRequest(req *SendMsgRequest)

type PortraitSetRequest

type PortraitSetRequest struct {
	FromAccount string        `json:"From_Account"`
	ProfileItem []ProfileItem `json:"ProfileItem"`
}

type PortraitSetResponse

type PortraitSetResponse struct {
	IMResponse
	ErrorDisplay string
}

type ProfileItem

type ProfileItem struct {
	Tag   ProfileTag  `json:"Tag"`
	Value interface{} `json:"Value"`
}

func NewNickNameProfileItem

func NewNickNameProfileItem(nickname string) ProfileItem

type ProfileTag

type ProfileTag string

type SendGroupMsgRequest

type SendGroupMsgRequest struct {
	GroupID               string           `json:"GroupId"`
	Random                int64            `json:"Random"`
	MsgPriority           GroupMsgPriority `json:"MsgPriority,omitempty"`
	MsgBody               []MsgBody        `json:"MsgBody"`
	FromAccount           string           `json:"From_Account,omitempty"`
	OfflinePushInfo       *OfflinePushInfo `json:"OfflinePushInfo,omitempty"`
	ForbidCallbackControl []string         `json:"ForbidCallbackControl,omitempty"`
}

type SendGroupMsgRequestOpt

type SendGroupMsgRequestOpt interface {
	ApplyToSendGroupMsgRequest(req *SendGroupMsgRequest)
}

func ForbidAfterSendMsgCallback

func ForbidAfterSendMsgCallback() SendGroupMsgRequestOpt

func ForbidBeforeSendMsgCallback

func ForbidBeforeSendMsgCallback() SendGroupMsgRequestOpt

type SendGroupMsgResponse

type SendGroupMsgResponse struct {
	IMResponse
	MsgTime int64 `json:"MsgTime"`
	MsgSeq  int64 `json:"MsgSeq"`
}

type SendMsgOpt

type SendMsgOpt interface {
	ApplyToSendMsgRequest(req *SendMsgRequest)
}

func MsgLifeTime

func MsgLifeTime(lifeTime int) SendMsgOpt

type SendMsgRequest

type SendMsgRequest struct {
	// 1:把消息同步到 From_Account 在线终端和漫游上;
	// 2:消息不同步至 From_Account;若不填写默认情况下会将消息存 From_Account 漫游
	SyncOtherMachine SyncSetting `json:"SyncOtherMachine,omitempty"`
	// 消息发送方帐号。(用于指定发送消息方帐号)
	FromAccount string `json:"From_Account,omitempty"`
	// 必填,消息接收方帐号。
	ToAccount string `json:"To_Account"`
	// 消息离线保存时长(秒数),最长为 7 天(604800s)。若消息只发在线用户,不想保存离线,则该字段填 0。若不填,则默认保存 7 天
	// NOTE(QuantumGhost): 这里为了避免 *int,默认值设置为 604800,如果设置为 0 就会发送 0
	MsgLifeTime int `json:"MsgLifeTime"`
	// 必填,消息随机数,由随机函数产生。(用作消息去重)(
	// NOTE(QuantumGhost): 这个字段会在初始化的时候自懂添加
	MsgRandom int `json:"MsgRandom"`
	// 消息时间戳,UNIX 时间戳。
	MsgTimeStamp int `json:"MsgTimeStamp,omitempty"`
	// 必填,消息内容,具体格式请参考 [消息格式描述](http://bit.ly/2ARGSfV)。
	// (注意,一条消息可包括多种消息元素,MsgBody 为 Array 类型)
	MsgBody []MsgBody `json:"MsgBody"`
	// 离线推送信息配置,具体可参考 [消息格式描述](http://bit.ly/2AMK9NQ)。
	OfflinePushInfo *OfflinePushInfo `json:"OfflinePushInfo,omitempty"`
}

type SyncSetting

type SyncSetting int
const (
	SyncSetting_SyncToFromAccunt       SyncSetting = 1
	SyncSetting_DonotSyncToFromAccount             = 2
)

func (SyncSetting) ApplyToBatchSendMsgRequest

func (s SyncSetting) ApplyToBatchSendMsgRequest(req *BatchSendMsgRequest)

func (SyncSetting) ApplyToSendMsgRequest

func (s SyncSetting) ApplyToSendMsgRequest(req *SendMsgRequest)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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