WeWorkFinanceSDK

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

README

企业微信会话内容存档SDK golang版

Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

用于拉取企业聊天记录与媒体消息,该SDK是对官方linux c库的封装

Usage

package main

import (
    "log"
    "fmt"
    "bytes"

    sdk "github.com/bububa/WeWorkFinanceSDK"
)

func main() {
    corpId := "企业ID"
    corpSecre := "secret"
    clt, err := sdk.NewClient(corpId, corpSecret)
    if err != nil {
        log.Fatalln(err)
    }
    defer clt.Free()
    var (
        seq uint64 
        limit uint64 = 1000
        proxy = ""
        passwd = ""
        timeout = 300
    )
    for {
        chatsData, err := clt.GetChatData(seq, limit, proxy, passwd, timeout)
        if err != nil {
            log.Fatalln(err)
        }
        if len(chatsData) == 0 {
            break
        }
        // iterate chatsData
        for _, data := range chatsData {
            // update seq with chatdata.Seq for next loop
            seq = data.Seq
            // decrypt chat data
            msg, err := clt.DecryptData(data.EncryptRandomKey, data.EncryptChatMsg)
            if err != nil {
                log.Fatalln(err)
                continue
            }
            fmt.Printf("msg: %+v\n", msg)
            if msg.MessageType() == sdk.IMG_MSG {
                var (
                    w = new(bytes.Buffer) 
                    sdkField = msg.(sdk.ImageMessage).SdkFieldId
                )
                err := clt.DownloadMedia(w, sdkField, proxy, passwd, timeout)
                if err != nil {
                    log.Fatalln(err)
                    continue
                }
                log.Printf("download mediadata, len:%d bytes\n", w.Len())
            }
        }
    }
}

Reference

企业微信获取会话内容文档

Documentation

Overview

WeWorkFinanceSDK 企业内容存档SDK

Index

Constants

View Source
const (
	SDKErrMsg = "sdk failed" // SDK 错误消息
)

Variables

This section is empty.

Functions

func RSADecrypt

func RSADecrypt(privateKey []byte, ciphertext []byte) ([]byte, error)

RSADecrypt RSA解密

func RSADecryptBase64

func RSADecryptBase64(privateKey []byte, cryptoText string) ([]byte, error)

RSADecryptBase64 base64decode后RSA解密

func RSAEncrypt

func RSAEncrypt(publicKey []byte, origData []byte) ([]byte, error)

RSAEncrypt RSA加密

func RSAEncryptBase64

func RSAEncryptBase64(publicKey []byte, origData []byte) (string, error)

RSAEncryptBase64 RSA加密后base64encode

func RSASignWithSHA1

func RSASignWithSHA1(privateKey []byte, data []byte) ([]byte, error)

RSASignWithSHA1 RSA-SHA1签名

func RSASignWithSHA1Base64

func RSASignWithSHA1Base64(privateKey []byte, data []byte) (string, error)

RSASignWithSHA1Base64 RSA-SHA1签名后做base64encode

func RSAVerifySignWithSha1

func RSAVerifySignWithSha1(publicKey []byte, origData []byte, signData string) error

RSAVerifySignWithSha1 RSA-SHA1签名验证

func Sha1Sum

func Sha1Sum(data []byte) []byte

Sha1Sum SHA1

Types

type ActionType

type ActionType = string

ActionType // 消息动作

const (
	SEND_ACTION   ActionType = "send"   // 发送消息
	RECALL_ACTION ActionType = "recall" // 撤回消息
	SWITCH_ACTION ActionType = "switch" // 切换企业日志
)

type AggreeMessage

type AggreeMessage struct {
	BaseMessage
	UserId    string `json:"userid,omitempty"`     // 同意/不同意协议者的userid,外部企业默认为external_userid。
	AgreeTime int64  `json:"agree_time,omitempty"` // 同意/不同意协议的时间,utc时间,ms单位。
}

AggreeMessage 同意会话消息

type BaseMessage

type BaseMessage struct {
	MsgId   string      `json:"msgid,omitempty"`   // 消息id,消息的唯一标识,企业可以使用此字段进行消息去重。
	Action  ActionType  `json:"action,omitempty"`  // 消息动作,目前有send(发送消息)/recall(撤回消息)/switch(切换企业日志)三种类型。
	From    string      `json:"from,omitempty"`    // 消息发送方id。同一企业内容为userid,非相同企业为external_userid。消息如果是机器人发出,也为external_userid。
	ToList  []string    `json:"tolist,omitempty"`  // 消息接收方列表,可能是多个,同一个企业内容为userid,非相同企业为external_userid。
	RoomId  string      `json:"roomid,omitempty"`  // 群聊消息的群id。如果是单聊则为空。
	MsgTime int64       `json:"msgtime,omitempty"` // 消息发送时间戳,utc时间,ms单位。
	MsgType MessageType `json:"msgtype,omitempty"` // 文本消息为:text。
}

BaseMessage 会话消息公共字段

func (BaseMessage) ActionType

func (this BaseMessage) ActionType() ActionType

ActionType Message interface

func (BaseMessage) ID

func (this BaseMessage) ID() string

ID implement Message interface

func (BaseMessage) MessageType

func (this BaseMessage) MessageType() MessageType

MessageType implement Message interface

type CalendarMessage

type CalendarMessage struct {
	BaseMessage
	Title        string   `json:"title,omitempty"`        // 日程主题
	CreatorName  string   `json:"creatorname,omitempty"`  // 日程组织者
	AttendeeName []string `json:"attendeename,omitempty"` // 日程参与人。数组,内容为String类型
	StartTime    int64    `json:"starttime,omitempty"`    // 日程开始时间。Utc时间,单位秒
	EndTime      int64    `json:"endtime,omitempty"`      // 日程结束时间。Utc时间,单位秒
	Place        string   `json:"place,omitempty"`        // 日程地点
	Remarks      string   `json:"remarks,omitempty"`      // 日程备注
}

CalendarMessage 日程消息

type CardMessage

type CardMessage struct {
	BaseMessage
	CorpName string `json:"corpname,omitempty"` // 名片所有者所在的公司名称。
	UserId   string `json:"userid,omitempty"`   // 名片所有者的id,同一公司是userid,不同公司是external_userid
}

CardMessage 名片消息

type ChatData

type ChatData struct {
	Seq              uint64 `json:"seq,omitempty"`                // 消息的seq值,标识消息的序号。再次拉取需要带上上次回包中最大的seq。Uint64类型,范围0-pow(2,64)-1
	MsgId            string `json:"msgid,omitempty"`              // 消息id,消息的唯一标识,企业可以使用此字段进行消息去重。
	PublickeyVer     uint32 `json:"publickey_ver,omitempty"`      // 加密此条消息使用的公钥版本号。
	EncryptRandomKey string `json:"encrypt_random_key,omitempty"` // 使用publickey_ver指定版本的公钥进行非对称加密后base64加密的内容,需要业务方先base64 decode处理后,再使用指定版本的私钥进行解密,得出内容。
	EncryptChatMsg   string `json:"encrypt_chat_msg,omitempty"`   // 消息密文。需要业务方使用将encrypt_random_key解密得到的内容,与encrypt_chat_msg,传入sdk接口DecryptData,得到消息明文。
}

ChatData 加密消息数据

type ChatDataResponse

type ChatDataResponse struct {
	Error
	ChatDataList []ChatData `json:"chatdata,omitempty"`
}

ChatDataResponse 拉去消息返回值

func (ChatDataResponse) IsError

func (this ChatDataResponse) IsError() bool

IsError 判断是否错误

type ChatRecord

type ChatRecord struct {
	Type         ChatRecordType `json:"type,omitempty"`          // 每条聊天记录的具体消息类型:ChatRecordText/ ChatRecordFile/ ChatRecordImage/ ChatRecordVideo/ ChatRecordLink/ ChatRecordLocation/ ChatRecordMixed ….
	Content      string         `json:"content,omitempty"`       // 消息内容。Json串,内容为对应类型的json
	MsgTime      int64          `json:"msgtime,omitempty"`       // 消息时间,utc时间,ms单位。
	FromChatroom bool           `json:"from_chatroom,omitempty"` // 是否来自群会话。
}

ChatRecord 消息记录内的消息内

type ChatRecordMessage

type ChatRecordMessage struct {
	BaseMessage
	Title string       `json:"title,omitempty"` // 聊天记录标题
	Item  []ChatRecord `json:"item,omitempty"`  // 消息记录内的消息内容,批量数据
}

ChatRecordMessage 聊天记录消息

type ChatRecordType

type ChatRecordType = string

ChatRecordType 每条聊天记录的具体消息类型

const (
	TEXT_REC_MSG    ChatRecordType = "ChatRecordText"     // 文本消息
	IMG_REC_MSG     ChatRecordType = "ChatRecordImage"    // 图片消息
	VOICE_REC_MSG   ChatRecordType = "ChatRecordVoice"    // 语音消息
	VIDEO_REC_MSG   ChatRecordType = "ChatRecordVideo"    // 视频消息
	CARD_REC_MSG    ChatRecordType = "ChatRecordCard"     // 名片消息
	LOC_REC_MSG     ChatRecordType = "ChatRecordLocation" // 位置消息
	EMOTION_REC_MSG ChatRecordType = "ChatRecordEmotion"  // 表情消息
	FILE_REC_MSG    ChatRecordType = "ChatRecordFile"     // 文件消息
	LINK_REC_MSG    ChatRecordType = "ChatRecordLink"     // 链接消息
	WEAPP_REC_MSG   ChatRecordType = "ChatRecordWeapp"    // 小程序消息
	MIXED_REC_MSG   ChatRecordType = "ChatRecordMixed"    // 混合消息
)

type Client

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

func NewClient

func NewClient(corpId string, corpSecret string) (*Client, error)

NewClient * 初始化函数 * * @param [in] corpid 调用企业的企业id,例如:wwd08c8exxxx5ab44d,可以在企业微信管理端--我的企业--企业信息查看 * @param [in] secret 聊天内容存档的Secret,可以在企业微信管理端--管理工具--聊天内容存档查看 *

func (*Client) DecryptData

func (this *Client) DecryptData(encryptKey string, encryptMsg string) (Message, error)
DecryptData

* @brief 解析密文.企业微信自有解密内容 * @param [in] encrypt_key, getchatdata返回的encrypt_random_key,使用企业自持对应版本秘钥RSA解密后的内容 * @param [in] encrypt_msg, getchatdata返回的encrypt_chat_msg * @return msg, 解密的消息明文

func (*Client) DownloadMedia

func (this *Client) DownloadMedia(w io.Writer, sdkField string, proxy string, passwd string, timeout int) error

DownloadMedia 下载MediaData

func (*Client) Free

func (this *Client) Free()

Free 释放sdk,和NewClient成对使用

func (*Client) GetChatData

func (this *Client) GetChatData(seq uint64, limit uint64, proxy string, passwd string, timeout int) ([]ChatData, error)
GetChatData

* 拉取聊天记录函数 * * * @param [in] seq 从指定的seq开始拉取消息,注意的是返回的消息从seq+1开始返回,seq为之前接口返回的最大seq值。首次使用请使用seq:0 * @param [in] limit 一次拉取的消息条数,最大值1000条,超过1000条会返回错误 * @param [in] proxy 使用代理的请求,需要传入代理的链接。如:socks5://10.0.0.1:8081 或者 http://10.0.0.1:8081 * @param [in] passwd 代理账号密码,需要传入代理的账号密码。如 user_name:passwd_123 * @param [in] timeout 超时时间,单位秒 * @return chatDatas 返回本次拉取消息的数据,slice结构体.内容包括errcode/errmsg,以及每条消息内容。示例如下:

{"errcode":0,"errmsg":"ok","chatdata":[{"seq":196,"msgid":"CAQQ2fbb4QUY0On2rYSAgAMgip/yzgs=","publickey_ver":3,"encrypt_random_key":"ftJ+uz3n/z1DsxlkwxNgE+mL38H42/KCvN8T60gbbtPD+Rta1hKTuQPzUzO6Hzne97MgKs7FfdDxDck/v8cDT6gUVjA2tZ/M7euSD0L66opJ/IUeBtpAtvgVSD5qhlaQjvfKJc/zPMGNK2xCLFYqwmQBZXbNT7uA69Fflm512nZKW/piK2RKdYJhRyvQnA1ISxK097sp9WlEgDg250fM5tgwMjujdzr7ehK6gtVBUFldNSJS7ndtIf6aSBfaLktZgwHZ57ONewWq8GJe7WwQf1hwcDbCh7YMG8nsweEwhDfUz+u8rz9an+0lgrYMZFRHnmzjgmLwrR7B/32Qxqd79A==","encrypt_chat_msg":"898WSfGMnIeytTsea7Rc0WsOocs0bIAerF6de0v2cFwqo9uOxrW9wYe5rCjCHHH5bDrNvLxBE/xOoFfcwOTYX0HQxTJaH0ES9OHDZ61p8gcbfGdJKnq2UU4tAEgGb8H+Q9n8syRXIjaI3KuVCqGIi4QGHFmxWenPFfjF/vRuPd0EpzUNwmqfUxLBWLpGhv+dLnqiEOBW41Zdc0OO0St6E+JeIeHlRZAR+E13Isv9eS09xNbF0qQXWIyNUi+ucLr5VuZnPGXBrSfvwX8f0QebTwpy1tT2zvQiMM2MBugKH6NuMzzuvEsXeD+6+3VRqL"}]}

func (*Client) GetContentFromSlice

func (this *Client) GetContentFromSlice(slice *C.struct_Slice_t) []byte

GetContentFromSlice 转换C.struct_Slice_t为go bytes

func (*Client) GetMediaData

func (this *Client) GetMediaData(indexBuf string, sdkFileId string, proxy string, passwd string, timeout int) (*MediaData, error)

type CollectDetails

type CollectDetails struct {
	Id   uint64             `json:"id,omitempty"`   // 表项id
	Ques string             `json:"ques,omitempty"` // 表项名称
	Type CollectDetailsType `json:"type,omitempty"` // 表项类型,有Text(文本),Number(数字),Date(日期),Time(时间)
}

CollectDetails 填表消息表内容

type CollectDetailsType

type CollectDetailsType = string

CollectDetailsType 表项类型

const (
	TEXT   CollectDetailsType = "Text"   // 文本
	NUMBER CollectDetailsType = "Number" // 数字
	DATE   CollectDetailsType = "Date"   // 日期
	TIME   CollectDetailsType = "Time"   // 时间
)

type CollectMessage

type CollectMessage struct {
	BaseMessage
	RoomName   string           `json:"room_name,omitempty"`   // 填表消息所在的群名称。
	Creator    string           `json:"creator,omitempty"`     // 创建者在群中的名字
	CreateTime string           `json:"create_time,omitempty"` // 创建的时间
	Details    []CollectDetails `json:"details,omitempty"`     // 表内容
}

CollectMessage 填表消息

type DemoFileData

type DemoFileData struct {
	FileName     string `json:"filename,omitempty"`     // 文档共享名称
	DemoOperator string `json:"demooperator,omitempty"` // 文档共享操作用户的id
	StartTime    int64  `json:"starttime,omitempty"`    // 文档共享开始时间
	EndTime      int64  `json:"endtime,omitempty"`      // 文档共享结束时间
}

DemoFileData 文档分享对

type DocMessage

type DocMessage struct {
	BaseMessage
	Title      string `json:"title,omitempty"`       // 在线文档名称
	LinkUrl    string `json:"link_url,omitempty"`    // 在线文档链接
	DocCreator string `json:"doc_creator,omitempty"` // 在线文档创建者。本企业成员创建为userid;外部企业成员创建为external_userid
}

DocMessage 在线文档消息

type EmotionMessage

type EmotionMessage struct {
	BaseMessage
	Type      EmotionType `json:"type,omitempty"`      // 表情类型,png或者gif.1表示gif 2表示png。
	Width     uint32      `json:"width,omitempty"`     // 表情图片宽度。
	Height    uint32      `json:"height,omitempty"`    // 表情图片高度。
	ImageSize uint32      `json:"imagesize,omitempty"` // 资源的文件大小。
	SdkFileId string      `json:"sdkfileid,omitempty"` // 媒体资源的id信息。
	Md5Sum    string      `json:"md5sum,omitempty"`    // 图片资源的md5值,供进行校验。
}

EmotionMessage 表情消息

type EmotionType

type EmotionType = uint32

EmotionType 表情类型

const (
	GIF EmotionType = 1 // gif表情
	PNG EmotionType = 2 // png表情
)

type Error

type Error struct {
	ErrCode int    `json:"errcode,omitempty"` // 错误代码
	ErrMsg  string `json:"errmsg,omitempty"`  // 错误说明
}

SDK Error结构体

func NewSDKErr

func NewSDKErr(code int) Error

NewSDKError 新建错误

func (Error) Error

func (this Error) Error() string

Error implement error interface

type FileMessage

type FileMessage struct {
	BaseMessage
	FileName  string `json:"filename,omitempty"`  // 文件名称。
	FileExt   string `json:"fileext,omitempty"`   // 文件类型后缀。
	SdkFileId string `json:"sdkfileid,omitempty"` // 媒体资源的id信息。
	FileSize  uint32 `json:"filesize,omitempty"`  // 文件大小。
	Md5Sum    string `json:"md5sum,omitempty"`    // 资源的md5值,供进行校验。
}

FileMessage 文件消息

type ImageMessage

type ImageMessage struct {
	BaseMessage
	SdkFileId string `json:"sdkfileid,omitempty"` // 媒体资源的id信息。
	Md5Sum    string `json:"md5sum,omitempty"`    // 图片资源的md5值,供进行校验。
	FileSize  uint32 `json:"filesize,omitempty"`  // 图片资源的文件大小。
}

ImageMessage 图片消息

type LinkMessage

type LinkMessage struct {
	BaseMessage
	Title    string `json:"title,omitempty"`       // 消息标题。
	Desc     string `json:"description,omitempty"` // 消息描述。
	LinkUrl  string `json:"link_url,omitempty"`    // 链接url地址
	ImageUrl string `json:"image_url,omitempty"`   // 链接图片url。
}

LinkMessage 链接消息

type LocationMessage

type LocationMessage struct {
	BaseMessage
	Lng     float64 `json:"longitude,omitempty"` // 经度,单位double
	Lat     float64 `json:"latitude,omitempty"`  // 纬度,单位double
	Address string  `json:"address,omitempty"`   // 地址信息
	Title   string  `json:"title,omitempty"`     // 位置信息的title。
	Zoom    uint32  `json:"zoom,omitempty"`      // 缩放比例。
}

LocationMessage 位置消息

type MarkdownMessage

type MarkdownMessage struct {
	BaseMessage
	Content string `json:"content,omitempty"` // markdown消息内容,目前为机器人发出的消息
}

MarkdownMessage MarkDown格式消息

type MediaData

type MediaData struct {
	OutIndexBuf string `json:"outindexbuf,omitempty"` // 消息分片索引信息
	IsFinish    bool   `json:"is_finish,omitempty"`   //
	Data        []byte `json:"data,omitempty"`        // 媒体数据内通
}

MediaData 媒体消息结构体

type MeetingMessage

type MeetingMessage struct {
	BaseMessage
	Topic       string        `json:"topic,omitempty"`       // 会议主题
	StartTime   int64         `json:"starttime,omitempty"`   // 会议开始时间。Utc时间
	EndTime     int64         `json:"endtime,omitempty"`     // 会议结束时间。Utc时间
	Address     string        `json:"address,omitempty"`     // 会议地址
	Remarks     string        `json:"remarks,omitempty"`     // 会议备注
	MeetingType MeetingType   `json:"meetingtype,omitempty"` // 会议消息类型。101发起会议邀请消息、102处理会议邀请消息
	MeetingId   uint64        `json:"meetingid,omitempty"`   // 会议id。方便将发起、处理消息进行对照
	Status      MeetingStatus `json:"status,omitempty"`      // 会议邀请处理状态。1 参加会议、2 拒绝会议、3 待定、4 未被邀请、5 会议已取消、6 会议已过期、7 不在房间内。
}

MeetingMessage 会议邀请消息

type MeetingStatus

type MeetingStatus = uint32

MeetingStatus 会议邀请处理状态

const (
	JOIN_MEETING     MeetingStatus = 1 // 参加会议
	REJECT_MEETING   MeetingStatus = 2 // 拒绝会议
	PENDING_MEETING  MeetingStatus = 3 // 待定
	NOINVITE_MEETING MeetingStatus = 4 // 未被邀请
	CANCELED_MEETING MeetingStatus = 5 // 会议已取消
	EXPIRED_MEETING  MeetingStatus = 6 // 会议已过期
	ABSENT_MEETING   MeetingStatus = 7 // 不在房间内
)

type MeetingType

type MeetingType = uint32

MeetingType 会议消息类型

const (
	LAUNCH_MEETING MeetingType = 101 // 发起会议邀请消息
	HANDLE_MEETING MeetingType = 102 // 处理会议邀请消息
)

type MeetingVoiceCall

type MeetingVoiceCall struct {
	EndTime         int64             `json:"endtime,omitempty"`         // 音频结束时间
	SdkFileId       string            `json:"sdkfileid,omitempty"`       // 音频媒体下载的id
	DemoFileData    []DemoFileData    `json:"demofiledata,omitempty"`    // 文档分享对象,Object类型
	ShareScreenData []ShareScreenData `json:"sharescreendata,omitempty"` // 屏幕共享对象,Object类型
}

MeetingVoiceCall 音频消息内

type MeetingVoiceCallMessage

type MeetingVoiceCallMessage struct {
	BaseMessage
	VoiceId          string            `json:"voiceid,omitempty"`            // 音频id
	MeetingVoiceCall *MeetingVoiceCall `json:"meeting_voice_call,omitempty"` // 音频消息内容。包括结束时间、fileid,可能包括多个demofiledata、sharescreendata消息,demofiledata表示文档共享信息,sharescreendata表示屏幕共享信息。Object类型
}

MeetingVoiceCallMessage 音频存档消息

type Message

type Message interface {
	ID() string                // 消息ID
	GetMsgType() MessageType   // 消息类型
	GetActionType() ActionType // 消息动作类型
}

Message 会话消息

type MessageType

type MessageType = string

MessageType 消息类型

const (
	UNKNOWN_MSG            MessageType = ""                   // 未定义
	TEXT_MSG               MessageType = "text"               // 	文本消息
	IMG_MSG                MessageType = "image"              // 	图片消息
	REVOKE_MSG             MessageType = "revoke"             // 撤回消息
	AGREE_MSG              MessageType = "agree"              // 同意消息
	DISAGREE_MSG           MessageType = "disagree"           // 不同意消息
	VOICE_MSG              MessageType = "voice"              // 语音消息
	VIDEO_MSG              MessageType = "video"              // 视频消息
	CARD_MSG               MessageType = "card"               // 名片消息
	LOC_MSG                MessageType = "location"           // 位置消息
	EMOTION_MSG            MessageType = "emotion"            // 表情消息
	FILE_MSG               MessageType = "file"               // 文件消息
	LINK_MSG               MessageType = "link"               // 链接消息
	WEAPP_MSG              MessageType = "weapp"              // 小程序消息
	CHATRECORD_MSG         MessageType = "chatrecord"         // 会话记录消息
	TODO_MSG               MessageType = "todo"               // 待办消息
	VOTE_MSG               MessageType = "vote"               // 投票消息
	COLLECT_MSG            MessageType = "collect"            // 填表消息
	REDPACKET_MSG          MessageType = "redpacket"          // 红包消息
	MEETING_MSG            MessageType = "meeting"            // 会议邀请消息
	DOC_MSG                MessageType = "docmsg"             // 在线文档消息
	MARKDOWN_MSG           MessageType = "markdown"           // MarkDown格式消息
	NEWS_MSG               MessageType = "news"               // 图文消息
	CALENDAR_MSG           MessageType = "calendar"           // 日程消息
	MIXED_MSG              MessageType = "mixed"              // 混合消息
	MEETING_VOICE_CALL_MSG MessageType = "meeting_voice_call" // 音频存档消息
	VOIP_DOC_SHARE_MSG     MessageType = "voip_doc_share"     // 音频共享文档
	EXTERNAL_REDPACKET_MSG MessageType = "external_redpacket" // 互通红包消息
	SPHFEED_MSG            MessageType = "sphfeed"            // 视频号消息
)

type MixedMessage

type MixedMessage struct {
	BaseMessage
	Mixed struct {
		Item []MixedMsg `json:"item,omitempty"`
	} `json:"mixed,omitempty"` // 消息内容。可包含图片、文字、表情等多种消息。Object类型
}

MixedMessage 混合消息

type MixedMsg

type MixedMsg struct {
	Type    MessageType `json:"type,omitempty"`
	Content string      `json:"content,omitempty"`
}

MixedMsg 混合消息内容

type News

type News struct {
	Title  string `json:"title,omitempty"`       // 图文消息标题
	Desc   string `json:"description,omitempty"` // 图文消息描述
	Url    string `json:"url,omitempty"`         // 图文消息点击跳转地址
	PicUrl string `json:"picurl,omitempty"`      // 图文消息配图的url
}

News 图文消息图文内容

type NewsMessage

type NewsMessage struct {
	BaseMessage
	Info struct {
		Item []News `json:"item,omitempty"` // 图文消息数组
	} `json:"info,omitempty"` // 图文消息的内容
}

NewsMessage 图文消息

type RedpacketMessage

type RedpacketMessage struct {
	BaseMessage
	Type        RedpacketType `json:"type,omitempty"`        // 红包消息类型。1 普通红包、2 拼手气群红包、3 激励群红包。
	Wish        string        `json:"wish,omitempty"`        // 红包祝福语
	TotalCnt    uint32        `json:"totalcnt,omitempty"`    // 红包总个数
	TotalAmount uint32        `json:"totalamount,omitempty"` // 红包总金额。单位为分。
}

RedpacketMessage 红包消息

type RedpacketType

type RedpacketType = uint32

RedpacketType 红包类型

const (
	NORMAL_REDPACKET    RedpacketType = 1 // 普通红包
	SPELL_REDPACKET     RedpacketType = 2 // 拼手气群红包
	INCENTIVE_REDPACKET RedpacketType = 3 // 激励群红包
)

type RevokeMessage

type RevokeMessage struct {
	BaseMessage
	PreMsgId string `json:"pre_msgid,omitempty"` // 标识撤回的原消息的msgid
}

RevokeMessage 撤回消息

type ShareScreenData

type ShareScreenData struct {
	Share     string `json:"share,omitempty"`     // 屏幕共享用户的id
	StartTime int64  `json:"starttime,omitempty"` // 屏幕共享开始时间
	EndTime   int64  `json:"endtime,omitempty"`   // 屏幕共享结束时间
}

ShareScreenData 屏幕共享对象

type SphfeedMessage

type SphfeedMessage struct {
	BaseMessage
	FeedType SphfeedType `json:"feed_type,omitempty"` // 视频号消息类型
	SphName  string      `json:"sph_name,omitempty"`  // 视频号账号名称
	FeedDesc string      `json:"feed_desc,omitempty"` // 视频号消息描述
}

SphfeedMessage 视频号消息

type SphfeedType

type SphfeedType = uint32

SphfeedType 视频号消息类型

const (
	SPHFEED_IMAGE SphfeedType = 2
	SPHFEED_VIDEO SphfeedType = 4
	SPHFEED_LIVE  SphfeedType = 9
)

type SwitchMessage

type SwitchMessage struct {
	MsgId  string `json:"msgid,omitempty"`  // 消息id,消息的唯一标识,企业可以使用此字段进行消息去重
	Action string `json:"action,omitempty"` // 消息动作,切换企业为switch
	Time   int64  `json:"time,omitempty"`   // 消息发送时间戳,utc时间,ms单位。
	User   string `json:"user,omitempty"`   // 具体为切换企业的成员的userid。
}

SwitchMessage 切换企业日志

func (SwitchMessage) ActionType

func (this SwitchMessage) ActionType() ActionType

ActionType implement ActionType interface

func (SwitchMessage) ID

func (this SwitchMessage) ID() string

ID implement Message interface

func (SwitchMessage) MessageType

func (this SwitchMessage) MessageType() MessageType

MessageType implement Message interface

type TextMessage

type TextMessage struct {
	BaseMessage
	Content string `json:"content,omitempty"` // 消息内容。
}

TextMessage 文字消息

type TodoMessage

type TodoMessage struct {
	BaseMessage
	Title   string `json:"title,omitempty"`   // 待办的来源文本
	Content string `json:"content,omitempty"` // 待办的具体内容
}

TodoMessage 待办事项消息

type VideoMessage

type VideoMessage struct {
	BaseMessage
	SdkFileId  string `json:"sdkfileid,omitempty"`   // 媒体资源的id信息。
	FileSize   uint32 `json:"filesize,omitempty"`    // 图片资源的文件大小。
	PlayLength uint32 `json:"play_length,omitempty"` // 播放长度。
	Md5Sum     string `json:"md5sum,omitempty"`      // 图片资源的md5值,供进行校验。
}

VideoMessage 视频消息

type VoiceMessage

type VoiceMessage struct {
	BaseMessage
	SdkFileId  string `json:"sdkfileid,omitempty"`   // 媒体资源的id信息。
	VoiceSize  uint32 `json:"voice_size,omitempty"`  // 语音消息大小。
	PlayLength uint32 `json:"play_length,omitempty"` // 播放长度。
	Md5Sum     string `json:"md5sum,omitempty"`      // 图片资源的md5值,供进行校验。
}

VoiceMessage 语音消息

type VoipDocShare

type VoipDocShare struct {
	FileName  string `json:"filename,omitempty"`  // 文档共享文件名称
	Md5Sum    string `json:"md5sum,omitempty"`    // 共享文件的md5值
	FileSize  uint64 `json:"filesize,omitempty"`  // 共享文件的大小
	SdkFileId string `json:"sdkfileid,omitempty"` // 共享文件的sdkfile,通过此字段进行媒体数据下载
}

VoipDocShare 共享文档消息内容

type VoipDocShareMessage

type VoipDocShareMessage struct {
	BaseMessage
	VoipId       string        `json:"voipid,omitempty"`         // 音频id
	VoipDocShare *VoipDocShare `json:"voip_doc_share,omitempty"` // 共享文档消息内容。包括filename、md5sum、filesize、sdkfileid字段。Object类型
}

VoipDocShareMessage 音频共享文档消息

type VoteMessage

type VoteMessage struct {
	BaseMessage
	VoteTitle string   `json:"votetitle,omitempty"` // 投票主题。
	VoteItem  []string `json:"voteitem,omitempty"`  // 投票选项,可能多个内容。
	VoteType  VoteType `json:"votetype,omitempty"`  // 投票类型.101发起投票、102参与投票。
	VoteId    string   `json:"voteid,omitempty"`    // 投票id,方便将参与投票消息与发起投票消息进行前后对照。
}

VoteMessage 投票消息

type VoteType

type VoteType = uint32

VoteType 投票类型

const (
	LAUNCH_VOTE VoteType = 101 // 发起投票
	JOIN_VOTE   VoteType = 102 // 参与投票
)

type WeappMessage

type WeappMessage struct {
	BaseMessage
	Title       string `json:"title,omitempty"`       // 消息标题。
	Desc        string `json:"description,omitempty"` // 消息描述。
	Username    string `json:"username,omitempty"`    // 用户名称。
	DisplayName string `json:"displayname,omitempty"` // 小程序名称
}

WeappMessage 小程序消息

Jump to

Keyboard shortcuts

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