Documentation ¶
Index ¶
- Variables
- func ParseData(message []byte, v interface{}) error
- func RegisterHandlers(handlers ...interface{})
- type ChannelArticleCommentEventBody
- type ChannelArticleCommentHandler
- type ChannelArticleEventBody
- type ChannelArticleHandler
- type ChannelMessageEventBody
- type ChannelMessageEventHandler
- type ChannelVoiceMemberJoinEventBody
- type ChannelVoiceMemberJoinHandler
- type ChannelVoiceMemberLeaveEventBody
- type ChannelVoiceMemberLeaveHandler
- type Client
- type ErrorHandler
- type EventBody
- type EventData
- type EventType
- type GiftSendEventBody
- type GiftSendHandler
- type MemberInviteEventBody
- type MemberInviteEventHandler
- type MemberJoinEventBody
- type MemberJoinEventHandler
- type MemberLeaveEventBody
- type MemberLeaveEventHandler
- type MemberModel
- type MessageHandlers
- type MessageReactionEventBody
- type MessageReactionEventHandler
- type OptionHandler
- type PersonalMessageEventBody
- type PersonalMessageEventHandler
- type PersonalModel
- type PlainTextHandler
- type ReferenceModel
- type TypeCode
- type WSBeatData
- type WSEventMessage
Constants ¶
This section is empty.
Variables ¶
var DefaultHandlers = &MessageHandlers{ PersonalMessage: func(event *WSEventMessage, data *PersonalMessageEventBody) error { return nil }, ChannelMessage: func(event *WSEventMessage, data *ChannelMessageEventBody) error { return nil }, MessageReaction: func(event *WSEventMessage, data *MessageReactionEventBody) error { return nil }, MemberJoin: func(event *WSEventMessage, data *MemberJoinEventBody) error { return nil }, MemberLeave: func(event *WSEventMessage, data *MemberLeaveEventBody) error { return nil }, MemberInvite: func(event *WSEventMessage, data *MemberInviteEventBody) error { return nil }, ChannelVoiceMemberJoin: func(event *WSEventMessage, data *ChannelVoiceMemberJoinEventBody) error { return nil }, ChannelVoiceMemberLeave: func(event *WSEventMessage, data *ChannelVoiceMemberLeaveEventBody) error { return nil }, ChannelArticle: func(event *WSEventMessage, data *ChannelArticleEventBody) error { return nil }, ChannelArticleComment: func(event *WSEventMessage, data *ChannelArticleCommentEventBody) error { return nil }, GiftSend: func(event *WSEventMessage, data *GiftSendEventBody) error { return nil }, PlainTextHandler: func(event *WSEventMessage, message []byte) error { return nil }, ErrorHandler: func(err error) {}, }
DefaultHandlers default handlers to manage all supported message
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(handlers ...interface{})
RegisterHandlers Register global level event message handlers
Types ¶
type ChannelArticleCommentEventBody ¶
type ChannelArticleCommentEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群ID ChannelId string `json:"channelId"` // 来源语音频道ID DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 Member *MemberModel `json:"member"` // 成员信息 ArticleId string `json:"articleId"` // 帖子ID CommentId string `json:"commentId"` // 帖子评论ID ReplyId string `json:"replyId"` // 帖子评论回复ID,为空时:为评论事件,不为空时:为评论回复事件 ImageList []string `json:"imageList"` // 图片列表 Content string `json:"content"` // 文本内容,支持 菱形语法内容的接收 }
ChannelArticleCommentEventBody 帖子评论回复事件
func (*ChannelArticleCommentEventBody) EventType ¶
func (e *ChannelArticleCommentEventBody) EventType() EventType
type ChannelArticleCommentHandler ¶
type ChannelArticleCommentHandler func(event *WSEventMessage, data *ChannelArticleCommentEventBody) error
ChannelArticleCommentHandler 帖子评论回复事件
type ChannelArticleEventBody ¶
type ChannelArticleEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群ID ChannelId string `json:"channelId"` // 来源语音频道ID DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 Member *MemberModel `json:"member"` // 成员信息 ArticleId string `json:"articleId"` // 帖子ID Title string `json:"title"` // 标题 ImageList []string `json:"imageList"` // 图片列表 Content string `json:"content"` // 文本内容,支持 菱形语法内容的接收 }
ChannelArticleEventBody 帖子发布事件
func (*ChannelArticleEventBody) EventType ¶
func (e *ChannelArticleEventBody) EventType() EventType
type ChannelArticleHandler ¶
type ChannelArticleHandler func(event *WSEventMessage, data *ChannelArticleEventBody) error
ChannelArticleHandler 帖子发布事件
type ChannelMessageEventBody ¶
type ChannelMessageEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群id ChannelId string `json:"channelId"` // 来源频道号 DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 Member *MemberModel `json:"member"` // 成员信息 Reference *ReferenceModel `json:"reference"` // 回复信息 MessageId string `json:"messageId"` // 消息ID MessageType model.MessageType `json:"messageType"` // 消息类型,1:文本消息,2:图片消息,3:视频消息,5:文件消息 6:卡片消息 MessageBody jsoniter.RawMessage `json:"messageBody"` // 消息内容(model.IMessageBody) }
ChannelMessageEventBody 频道消息事件
func (*ChannelMessageEventBody) EventType ¶
func (e *ChannelMessageEventBody) EventType() EventType
type ChannelMessageEventHandler ¶
type ChannelMessageEventHandler func(event *WSEventMessage, data *ChannelMessageEventBody) error
ChannelMessageEventHandler 频道消息事件 handler
type ChannelVoiceMemberJoinEventBody ¶
type ChannelVoiceMemberJoinEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群ID ChannelId string `json:"channelId"` // 来源语音频道ID DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 Member *MemberModel `json:"member"` // 成员信息 }
ChannelVoiceMemberJoinEventBody 成员加入语音频道事件
func (*ChannelVoiceMemberJoinEventBody) EventType ¶
func (e *ChannelVoiceMemberJoinEventBody) EventType() EventType
type ChannelVoiceMemberJoinHandler ¶
type ChannelVoiceMemberJoinHandler func(event *WSEventMessage, data *ChannelVoiceMemberJoinEventBody) error
ChannelVoiceMemberJoinHandler 成员加入语音频道事件
type ChannelVoiceMemberLeaveEventBody ¶
type ChannelVoiceMemberLeaveEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群ID ChannelId string `json:"channelId"` // 来源语音频道ID DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 Member *MemberModel `json:"member"` // 成员信息 }
ChannelVoiceMemberLeaveEventBody 成员退出语音频道事件
func (*ChannelVoiceMemberLeaveEventBody) EventType ¶
func (e *ChannelVoiceMemberLeaveEventBody) EventType() EventType
type ChannelVoiceMemberLeaveHandler ¶
type ChannelVoiceMemberLeaveHandler func(event *WSEventMessage, data *ChannelVoiceMemberLeaveEventBody) error
ChannelVoiceMemberLeaveHandler 成员退出语音频道事件
type Client ¶
type Client interface { Connect() error Listen() error Write(event *WSEventMessage) error Reconnect() error Close() }
Client WebSocket client interface
func New ¶
func New(rc restClient.Client, options ...OptionHandler) (Client, error)
New a WebSocket instance
type EventData ¶
type EventData struct { EventId string `json:"eventId"` // 事件ID EventType EventType `json:"eventType"` // 事件类型 EventBody jsoniter.RawMessage `json:"eventBody"` // 事件内容 Timestamp uint64 `json:"timestamp"` // 发送时间戳 }
EventData 事件业务数据
type EventType ¶
type EventType string
EventType event type code
const ( PersonalMessageEvent EventType = "1001" // 个人消息事件 ChannelMessageEvent EventType = "2001" // 频道消息事件 MessageReactionEvent EventType = "3001" // 消息反应事件 MemberJoinEvent EventType = "4001" // 成员加入事件 MemberLeaveEvent EventType = "4002" // 成员退出事件 MemberInviteEvent EventType = "4003" // 成员退出事件 ChannelVoiceMemberJoinEvent EventType = "5001" // 成员加入语音频道事件 ChannelVoiceMemberLeaveEvent EventType = "5002" // 成员退出语音频道事件 ChannelArticleEvent EventType = "6001" // 帖子发布事件 ChannelArticleCommentEvent EventType = "6002" // 帖子评论回复事件 GiftSendEvent EventType = "7001" // 赠礼成功事件 )
type GiftSendEventBody ¶
type GiftSendEventBody struct { IslandSourceId string `json:"islandSourceId"` ChannelId string `json:"channelId"` OrderNo string `json:"orderNo"` TargetType int `json:"targetType"` TargetId string `json:"targetId"` Gift struct { Id string `json:"id"` Name string `json:"name"` Count int `json:"count"` } `json:"gift"` TotalAmount float64 `json:"totalAmount"` IslandRatio float64 `json:"islandRatio"` IslandIncome float64 `json:"islandIncome"` DodoSourceId string `json:"dodoSourceId"` DodoIslandNickName string `json:"dodoIslandNickName"` ToDodoSourceId string `json:"toDodoSourceId"` ToDodoIslandNickName string `json:"toDodoIslandNickName"` ToDodoRatio float64 `json:"toDodoRatio"` ToDodoIncome float64 `json:"toDodoIncome"` }
GiftSendEventBody 赠礼成功事件 [https://open.imdodo.com/dev/event/gift.html#%E8%B5%A0%E7%A4%BC%E6%88%90%E5%8A%9F%E4%BA%8B%E4%BB%B6]
func (*GiftSendEventBody) EventType ¶
func (e *GiftSendEventBody) EventType() EventType
type GiftSendHandler ¶
type GiftSendHandler func(event *WSEventMessage, data *GiftSendEventBody) error
GiftSendHandler 赠礼成功事件
type MemberInviteEventBody ¶
type MemberInviteEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群id DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID DodoIslandNickName string `json:"dodoIslandNickName"` // 邀请人群昵称 ToDodoSourceId string `json:"toDodoSourceId"` // 被邀请人DoDoID ToDodoIslandNickName string `json:"toDodoIslandNickName"` // 被邀请人群昵称 }
MemberInviteEventBody 成员邀请事件
func (*MemberInviteEventBody) EventType ¶
func (e *MemberInviteEventBody) EventType() EventType
type MemberInviteEventHandler ¶
type MemberInviteEventHandler func(event *WSEventMessage, data *MemberInviteEventBody) error
MemberInviteEventHandler 成员邀请事件 handler
type MemberJoinEventBody ¶
type MemberJoinEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群id DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID ModifyTime string `json:"modifyTime"` // 变动时间 }
MemberJoinEventBody 成员加入事件
func (*MemberJoinEventBody) EventType ¶
func (e *MemberJoinEventBody) EventType() EventType
type MemberJoinEventHandler ¶
type MemberJoinEventHandler func(event *WSEventMessage, data *MemberJoinEventBody) error
MemberJoinEventHandler 成员加入事件 handler
type MemberLeaveEventBody ¶
type MemberLeaveEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群id DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 LeaveType int `json:"leaveType"` // 退出类型,1:主动,2:被踢 OperateDodoSourceId string `json:"operateDodoSourceId"` // 操作者DoDoID(执行踢出操作的人) ModifyTime string `json:"modifyTime"` // 变动时间 }
MemberLeaveEventBody 成员退出事件
func (*MemberLeaveEventBody) EventType ¶
func (e *MemberLeaveEventBody) EventType() EventType
type MemberLeaveEventHandler ¶
type MemberLeaveEventHandler func(event *WSEventMessage, data *MemberLeaveEventBody) error
MemberLeaveEventHandler 成员退出事件 handler
type MemberModel ¶
type MemberModel struct { NickName string `json:"nickName"` // 在群昵称 JoinTime string `json:"joinTime"` // 加群时间 }
MemberModel 成员信息
type MessageHandlers ¶
type MessageHandlers struct { PersonalMessage PersonalMessageEventHandler ChannelMessage ChannelMessageEventHandler MessageReaction MessageReactionEventHandler MemberJoin MemberJoinEventHandler MemberLeave MemberLeaveEventHandler MemberInvite MemberInviteEventHandler ChannelVoiceMemberJoin ChannelVoiceMemberJoinHandler ChannelVoiceMemberLeave ChannelVoiceMemberLeaveHandler ChannelArticle ChannelArticleHandler ChannelArticleComment ChannelArticleCommentHandler GiftSend GiftSendHandler PlainTextHandler PlainTextHandler ErrorHandler ErrorHandler }
MessageHandlers instance message handlers
type MessageReactionEventBody ¶
type MessageReactionEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群id ChannelId string `json:"channelId"` // 来源频道号 DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID ReactionTarget *model.ReactionTarget `json:"reactionTarget"` // 反应对象 ReactionEmoji *model.ReactionEmoji `json:"reactionEmoji"` // 反应表情 ReactionType int `json:"reactionType"` // 反应类型,0:删除,1:新增 }
MessageReactionEventBody 消息反应事件
func (*MessageReactionEventBody) EventType ¶
func (e *MessageReactionEventBody) EventType() EventType
type MessageReactionEventHandler ¶
type MessageReactionEventHandler func(event *WSEventMessage, data *MessageReactionEventBody) error
MessageReactionEventHandler 消息反应事件 handler
type OptionHandler ¶
type OptionHandler func(*config) error
func WithMessageHandlers ¶
func WithMessageHandlers(handlers *MessageHandlers) OptionHandler
WithMessageHandlers Customize message handlers
func WithMessageQueueSize ¶
func WithMessageQueueSize(size int) OptionHandler
WithMessageQueueSize Customize message channel queue size
type PersonalMessageEventBody ¶
type PersonalMessageEventBody struct { IslandSourceId string `json:"islandSourceId"` // 来源群ID DodoSourceId string `json:"dodoSourceId"` // 来源DoDoID Personal *PersonalModel `json:"personal"` // 个人信息 MessageId string `json:"messageId"` // 消息ID MessageType model.MessageType `json:"messageType"` // 消息类型,1:文本消息,2:图片消息,3:视频消息 MessageBody jsoniter.RawMessage `json:"messageBody"` // 消息内容(model.IMessageBody) }
PersonalMessageEventBody 个人消息事件
func (*PersonalMessageEventBody) EventType ¶
func (e *PersonalMessageEventBody) EventType() EventType
type PersonalMessageEventHandler ¶
type PersonalMessageEventHandler func(event *WSEventMessage, data *PersonalMessageEventBody) error
PersonalMessageEventHandler 个人消息事件 handler
type PersonalModel ¶
type PersonalModel struct { NickName string `json:"nickName"` // 个人昵称 AvatarUrl string `json:"avatarUrl"` // 个人头像 Sex int `json:"sex"` // 个人性别,-1:保密,0:女,1:男 }
PersonalModel 个人信息
type PlainTextHandler ¶
type PlainTextHandler func(event *WSEventMessage, message []byte) error
PlainTextHandler plain text message handler
type ReferenceModel ¶
type ReferenceModel struct { MessageId string `json:"messageId"` // 被回复消息ID DodoSourceId string `json:"dodoSourceId"` // 被回复者DoDoID NickName string `json:"nickName"` // 被回复者在群昵称 }
ReferenceModel 回复信息
type WSEventMessage ¶
type WSEventMessage struct { Type TypeCode `json:"type"` // 数据类型 Data jsoniter.RawMessage `json:"data,omitempty"` // 数据内容 }
WSEventMessage 事件主体内容