tencentIM

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIMTextElem     = "TIMTextElem"
	TIMLocationElem = "TIMLocationElem"
	TIMFaceElem     = "TIMFaceElem"
	TIMCustomElem   = "TIMCustomElem"
)
View Source
const (
	// 没设置性别
	GenderTypeUnknown = "Gender_Type_Unknown"
	// 男性
	GenderTypeMale = "Gender_Type_Male" // 男性
	// 女性
	GenderTypeFemale = "Gender_Type_Female" // 女性
)
View Source
const SupperGroupIdPre = "@GLG#"

Variables

This section is empty.

Functions

This section is empty.

Types

type AndroidInfo

type AndroidInfo struct {
	Sound string `json:"Sound"`
}

type ApnsInfo

type ApnsInfo struct {
	Sound     string `json:"Sound"`
	BadgeMode int    `json:"BadgeMode"`
	Title     string `json:"Title"`
	SubTitle  string `json:"SubTitle"`
	Image     string `json:"Image"`
}

type AppDefinedData

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

type BatchChatMsg

type BatchChatMsg struct {
	FromAccount string   `json:"From_Account"`
	ToAccount   []string `json:"To_Account"`
	ChatMsg
}

type ChatMsg

type ChatMsg struct {
	SyncOtherMachine  int             `json:"SyncOtherMachine"`
	SyncFromOldSystem int             `json:"SyncFromOldSystem" `
	MsgLifeTime       int             `json:"MsgLifeTime"`
	MsgRandom         int             `json:"MsgRandom"`
	MsgTimeStamp      int64           `json:"MsgTimeStamp"`
	MsgBody           []MsgBody       `json:"MsgBody"`
	OfflinePushInfo   OfflinePushInfo `json:"OfflinePushInfo"`
}

SyncOtherMachine Integer 选填 1:把消息同步到 From_Account 在线终端和漫游上;

2:消息不同步至 From_Account;

若不填写默认情况下会将消息存 From_Account 漫游 MsgLifeTime Integer 选填 消息离线保存时长(单位:秒),最长为7天(604800秒) 若设置该字段为0,则消息只发在线用户,不保存离线 若设置该字段超过7天(604800秒),仍只保存7天 若不设置该字段,则默认保存7天 MsgRandom Integer 必填 消息随机数,由随机函数产生,用于后台定位问题 MsgTimeStamp Integer 选填 消息时间戳,UNIX 时间戳(单位:秒) MsgType String 必填 TIM 消息对象类型,目前支持的消息对象包括:TIMTextElem(文本消息),TIMFaceElem(表情消息),TIMLocationElem(位置消息),TIMCustomElem(自定义消息) MsgContent Object 必填 对于每种 MsgType 用不同的 MsgContent 格式,具体可参考 消息格式描述 OfflinePushInfo Object 选填 离线推送信息配置,具体可参考 消息格式描述

type GroupAddMemberReq

type GroupAddMemberReq struct {
	GroupID    string       `json:"GroupId"`
	Silence    int          `json:"Silence"`
	MemberList []MemberList `json:"MemberList"`
}

type GroupDeleteMemberReq

type GroupDeleteMemberReq struct {
	GroupID            string   `json:"GroupId"`             // 必填	群 ID
	Reason             string   `json:"Reason"`              // 选填	踢出用户原因
	Silence            int      `json:"Silence"`             // 默认为0 是否静默删人 0非静默删人 1静默删人静默即不通知所有成员,只通知被删除群成员
	MemberToDelAccount []string `json:"MemberToDel_Account"` // 待删除的群成员
}

type GroupInfo

type GroupInfo struct {
	GroupId      string `json:"GroupId"`
	ErrorCode    int    `json:"ErrorCode"`
	ErrorInfo    string `json:"ErrorInfo"`
	Type         string `json:"Type"`
	Name         string `json:"Name"`
	OwnerAccount string `json:"Owner_Account"`
	MemberNum    int    `json:"MemberNum"`
}

{"ActionStatus":"OK","ErrorCode":0,"ErrorInfo":"","GroupInfo":[{"ErrorCode":10015,"ErrorInfo":"invalid group id","GroupId":"1"}]}

type GroupMemberInfo

type GroupMemberInfo struct {
	MemberNum  int          `json:"MemberNum"`
	MemberList []MemberList `json:"MemberList"`
}

type GroupMemberInfoReq

type GroupMemberInfoReq struct {
	GroupID                         string   `json:"GroupId"`
	MemberInfoFilter                []string `json:"MemberInfoFilter"`
	MemberRoleFilter                []string `json:"MemberRoleFilter"`
	AppDefinedDataFilterGroupMember []string `json:"AppDefinedDataFilter_GroupMember"`
	Limit                           int      `json:"Limit"`
	Offset                          int      `json:"Offset"`
}

type GroupMsg

type GroupMsg struct {
	GroupID               string    `json:"GroupId"`
	Random                int       `json:"Random"`
	FromAccount           string    `json:"From_Account"`
	MsgPriority           string    `json:"MsgPriority"`
	OnlineOnlyFlag        int       `json:"OnlineOnlyFlag"`
	ForbidCallbackControl []string  `json:"ForbidCallbackControl"`
	MsgBody               []MsgBody `json:"MsgBody"`
}

GroupId String 必填 向哪个群组发送消息 Random Integer 必填 32位随机数。如果5分钟内两条消息的随机值相同,后一条消息将被当做重复消息而丢弃 MsgPriority String 选填 消息的优先级 MsgBody Array 必填 消息体,详细可参阅 消息格式描述 From_Account String 选填 消息来源帐号,选填。如果不填写该字段,则默认消息的发送者为调用该接口时使用的 App 管理员帐号。除此之外,App 亦可通过该字段“伪造”消息的发送者,从而实现一些特殊的功能需求。需要注意的是,如果指定该字段,必须要确保字段中的帐号是存在的 ForbidCallbackControl Array 选填 消息回调禁止开关,只对单条消息有效,ForbidBeforeSendMsgCallback 表示禁止发消息前回调,ForbidAfterSendMsgCallback 表示禁止发消息后回调 OnlineOnlyFlag Integer 选填 1表示消息仅发送在线成员,默认0表示发送所有成员,音视频聊天室(AVChatRoom)和在线成员广播大群(BChatRoom)不支持该参数

type GroupReq

type GroupReq struct {
	GroupID      string `json:"GroupId"`       // 必填	群 ID
	OwnerAccount string `json:"Owner_Account"` // 选填	群主的 UserId(选填)
	Type         string `json:"Type"`          // 群组类型:Private/Public/ChatRoom(不支持 AVChatRoom)(必填
	Name         string `json:"Name"`          // 选填	踢出用户原因
	Introduction string `json:"Introduction"`  // 选填 群简介

}

type GroupResInfo

type GroupResInfo struct {
	ActionStatus string      `json:"ActionStatus"`
	ErrorCode    int         `json:"ErrorCode"`
	ErrorInfo    string      `json:"ErrorInfo"`
	GroupInfo    []GroupInfo `json:"GroupInfo"`
}

GroupResInfo 群组信息

type IMPath

type IMPath string
const (
	BASEURL = "https://console.tim.qq.com"

	// 群里 聊天
	SendGroupMSG IMPath = "/group_open_http_svc/send_group_msg" //在群组中发送普通消息

	//
	MULTIACCOUNTIMPORT IMPath = "/im_open_login_svc/multiaccount_import" //导入多个帐号
	ACCOUNTIMPORT      IMPath = "/im_open_login_svc/account_import"      //导入单个帐号

	//
	//单聊消息
	QUERYSTATE IMPath = "/openim/querystate" //查询帐号在线状态	v4/openim/querystate
	SENDMSG    IMPath = "/openim/sendmsg"    //单发单聊消息	v4/openim/sendmsg

	// 群管理
	GROUPADD       IMPath = "/group_open_http_svc/create_group"        //新增群组
	GROUPADDMEMBER IMPath = "/group_open_http_svc/add_group_member"    //增加群组成员
	GROUPDELMEMBER IMPath = "/group_open_http_svc/delete_group_member" //删除群组成员

	GETGROUPINFO       IMPath = "/group_open_http_svc/get_group_info"        //获取群组详细资料
	GETGROUPMEMBERINFO IMPath = "/group_open_http_svc/get_group_member_info" //获取群成员详细资料

)

type IMServer

type IMServer struct {
	AppID      int    // 腾讯 app id
	Key        string // 密码
	Identifier string // admin
	Expire     int    // 过期时间

	Sig string // 腾讯云 那边的 用户签名
}

func (*IMServer) AddImGroup

func (s *IMServer) AddImGroup(g GroupReq) error

AddImGroup 新增群组

func (*IMServer) GetGroupInfo

func (s *IMServer) GetGroupInfo(gid []string) (resp GroupResInfo, err error)

GetGroupInfo 获取群组信息

func (*IMServer) GetGroupMemberInfo

func (s *IMServer) GetGroupMemberInfo(g GroupMemberInfoReq) (GroupMemberInfo, error)

func (*IMServer) GetPortrait

func (s *IMServer) GetPortrait(p PortraitReq) (PortraitResp, error)

func (*IMServer) GroupAddMember

func (s *IMServer) GroupAddMember(roomId interface{}, accounts []string) ([]MemberList, error)

GroupAddMember cloud.tencent.com/document/product/269/1621 增加群组成员

func (*IMServer) GroupDeleteMember

func (s *IMServer) GroupDeleteMember(roomId interface{}, accounts []string) error

GroupDeleteMember cloud.tencent.com/document/product/269/1622 删除群组成员

func (*IMServer) MultiAccountImports

func (s *IMServer) MultiAccountImports(account []string) ([]string, error)

本接口单次最多支持导入100个帐号,同一个帐号重复导入仅会创建1个内部 ID。 Accounts Array 必填 用户名,单个用户名长度不超过32字节,单次最多导入100个用户名 FailAccounts Array 导入失败的帐号列表

func (*IMServer) SendMsg

func (s *IMServer) SendMsg(b SingleChatMsg) (msgTime int64, msgKey string, err error)

单人消息

func (*IMServer) SendRoomData

func (s *IMServer) SendRoomData(roomId interface{}, msgType int, byteData []byte) error

SendRoomData 群里所有人的 消息

func (*IMServer) SetRobotProfile

func (s *IMServer) SetRobotProfile(u UserProfile) error

func (IMServer) SetUserLv

func (s IMServer) SetUserLv(userId interface{}, lv, anchorLv int) error

更新 qq IM 用户的 等级 和 主播等级 不用更新 就传输 -1

func (*IMServer) SetUserPartProfile

func (s *IMServer) SetUserPartProfile(userId interface{}, list ...ProfileItem) error

qq IM 设置 用户信息 部分更新

func (*IMServer) SetUserProfile

func (s *IMServer) SetUserProfile(u UserProfile) error

部分信息更新不要调用这个,调用下面那个 qq IM 设置 用户信息 全量更新

type MemberList

type MemberList struct {
	MemberAccount string `json:"Member_Account"`
	Result        int    `json:"Result"`

	Role string `json:"Role"`
}

type MsgBody

type MsgBody struct {
	MsgContent MsgContent `json:"MsgContent"`
	MsgType    string     `json:"MsgType"`
}

func NewCustomElem

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

自定义消息元素 Data String 自定义消息数据。 不作为 APNs 的 payload 字段下发,故从 payload 中无法获取 Data 字段。 Desc String 自定义消息描述信息。当接收方为 iOS 或 Android 后台在线时,做离线推送文本展示。 若发送自定义消息的同时设置了 OfflinePushInfo.Desc 字段,此字段会被覆盖,请优先填 OfflinePushInfo.Desc 字段。 当消息中只有一个 TIMCustomElem 自定义消息元素时,如果 Desc 字段和 OfflinePushInfo.Desc 字段都不填写,将收不到该条消息的离线推送,需要填写 OfflinePushInfo.Desc 字段才能收到该消息的离线推送。 Ext String 扩展字段。当接收方为 iOS 系统且应用处在后台时,此字段作为 APNs 请求包 Payloads 中的 Ext 键值下发,Ext 的协议格式由业务方确定,APNs 只做透传。 Sound String 自定义 APNs 推送铃音。

func NewTextElem

func NewTextElem(text string) MsgBody

文本消息元素 Text String 消息内容。当接收方为 iOS 或 Android 后台在线时,作为离线推送的文本展示。

type MsgContent

type MsgContent struct {
	Data      interface{} `json:"Data"`
	Desc      string      `json:"Desc"`
	Ext       string      `json:"Ext"`
	Text      string      `json:"Text"`
	Sound     string      `json:"Sound"`
	Index     int         `json:"Index"`
	Latitude  float64     `json:"Latitude,omitempty"`
	Longitude float64     `json:"Longitude,omitempty"`
}

type MsgTypeData

type MsgTypeData struct {
	MsgType int         `json:"msgType"`
	Data    interface{} `json:"data"`
}

type OfflinePushInfo

type OfflinePushInfo struct {
	PushFlag    int         `json:"PushFlag"`
	Desc        string      `json:"Desc"`
	Ext         string      `json:"Ext"`
	AndroidInfo AndroidInfo `json:"AndroidInfo"`
	ApnsInfo    ApnsInfo    `json:"ApnsInfo"`
}

https://cloud.tencent.com/document/product/269/2720 PushFlag Integer 选填 0表示推送,1表示不离线推送。 Title String 选填 离线推送标题。该字段为 iOS 和 Android 共用。 Desc String 选填 离线推送内容。该字段会覆盖上面各种消息元素 TIMMsgElement 的离线推送展示文本。 若发送的消息只有一个 TIMCustomElem 自定义消息元素,该 Desc 字段会覆盖 TIMCustomElem 中的 Desc 字段。如果两个 Desc 字段都不填,将收不到该自定义消息的离线推送。 Ext String 选填 离线推送透传内容。 AndroidInfo.Sound String 选填 Android 离线推送声音文件路径。 AndroidInfo.OPPOChannelID String 选填 OPPO 手机 Android 8.0 以上的 NotificationChannel 通知适配字段。 ApnsInfo.BadgeMode Integer 选填 这个字段缺省或者为0表示需要计数,为1表示本条消息不需要计数,即右上角图标数字不增加。 ApnsInfo.Title String 选填 该字段用于标识 APNs 推送的标题,若填写则会覆盖最上层 Title。 ApnsInfo.SubTitle String 选填 该字段用于标识 APNs 推送的子标题。 ApnsInfo.Image String 选填 该字段用于标识 APNs 携带的图片地址,当客户端拿到该字段时,可以通过下载图片资源的方式将图片展示在弹窗上。

type PortraitReq

type PortraitReq struct {
	ToAccount []string      `json:"To_Account"`
	TagList   []PortraitTag `json:"TagList"`
}

1. 标配资料字段,详情可参见 标配资料字段 2. 自定义资料字段,详情可参见 自定义资料字段

type PortraitResp

type PortraitResp struct {
	UserProfileItem []UserProfileItem `json:"UserProfileItem"`
	FailAccount     []string          `json:"Fail_Account"`
	ActionStatus    string            `json:"ActionStatus"`
	ErrorCode       int               `json:"ErrorCode"`
	ErrorInfo       string            `json:"ErrorInfo"`
	ErrorDisplay    string            `json:"ErrorDisplay"`
}

type PortraitSet

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

设置 用户tag 请求

type PortraitTag

type PortraitTag string
const (
	// 昵称	长度不得超过500个字节
	IMNick PortraitTag = "Tag_Profile_IM_Nick"

	//Gender_Type_Unknown:没设置性别
	//Gender_Type_Female:女性
	//Gender_Type_Male:男性
	// 性别
	IMGender PortraitTag = "Tag_Profile_IM_Gender"

	// string	头像URL	有	长度不得超过500个字节
	IMImage PortraitTag = "Tag_Profile_IM_Image"

	//个性签名 长度不得超过500个字节
	IMSelfSignature PortraitTag = "Tag_Profile_IM_SelfSignature"

	// 用户等级 string
	IMCustomRichLv PortraitTag = "Tag_Profile_Custom_richLv"

	// 主播等级 string
	IMCustomCharmLv PortraitTag = "Tag_Profile_Custom_charmLv"

	// 是否机器人
	IMCustomIsRobot PortraitTag = "Tag_Profile_Custom_isRobot"
)

type PortraitTagValue

type PortraitTagValue string

type ProfileItem

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

type SendMsgResp

type SendMsgResp struct {
	ActionStatus string `json:"ActionStatus"` //
	ErrorInfo    string `json:"ErrorInfo"`    // 错误信息
	ErrorCode    int    `json:"ErrorCode"`    // 错误码
	MsgTime      int64  `json:"MsgTime"`      // 消息时间戳, UNIX 时间戳
	MsgKey       string `json:"MsgKey"`       // 用于消息撤回
}

type SingleChatMsg

type SingleChatMsg struct {
	FromAccount string `json:"From_Account"`
	ToAccount   string `json:"To_Account"`
	ChatMsg
}

From_Account String 选填 消息发送方 UserID(用于指定发送消息方帐号) To_Account String 必填 消息接收方 UserID

type UserProfile

type UserProfile struct {
	ID             int64
	Nick           string
	Sex            int32
	Head           string
	PersonalStatus string
	Lv             int32
	AnchorLv       int32
}

type UserProfileItem

type UserProfileItem struct {
	ToAccount   string        `json:"To_Account"`
	ProfileItem []ProfileItem `json:"ProfileItem,omitempty"`
	ResultCode  int           `json:"ResultCode"`
	ResultInfo  string        `json:"ResultInfo"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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