Processor

package
v0.0.0-...-c280332 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

处理收到的信息事件

处理收到的信息事件

处理收到的信息事件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FoxTimestamp

func FoxTimestamp() int64

func PostMessageToUrls

func PostMessageToUrls(message map[string]interface{})

上报信息给反向Http

func PrintStructWithFieldNames

func PrintStructWithFieldNames(v interface{})

打印结构体的函数

func SendMessage

func SendMessage(messageText string, data interface{}, messageType string, s *discordgo.Session) error

SendMessage 发送消息根据不同的类型

Types

type OnebotChannelMessage

type OnebotChannelMessage struct {
	ChannelID   string      `json:"channel_id"`
	GuildID     string      `json:"guild_id"`
	Message     interface{} `json:"message"`
	MessageID   string      `json:"message_id"`
	MessageType string      `json:"message_type"`
	PostType    string      `json:"post_type"`
	SelfID      int64       `json:"self_id"`
	SelfTinyID  string      `json:"self_tiny_id"`
	Sender      Sender      `json:"sender"`
	SubType     string      `json:"sub_type"`
	Time        int64       `json:"time"`
	Avatar      string      `json:"avatar,omitempty"`
	UserID      int64       `json:"user_id"`
	RawMessage  string      `json:"raw_message"`
	Echo        string      `json:"echo,omitempty"`
}

频道信息事件

type OnebotGroupMessage

type OnebotGroupMessage struct {
	RawMessage      string      `json:"raw_message"`
	MessageID       int         `json:"message_id"`
	GroupID         int64       `json:"group_id"` // Can be either string or int depending on p.Settings.CompleteFields
	MessageType     string      `json:"message_type"`
	PostType        string      `json:"post_type"`
	SelfID          int64       `json:"self_id"` // Can be either string or int
	Sender          Sender      `json:"sender"`
	SubType         string      `json:"sub_type"`
	Time            int64       `json:"time"`
	Avatar          string      `json:"avatar,omitempty"`
	Echo            string      `json:"echo,omitempty"`
	Message         interface{} `json:"message"` // For array format
	MessageSeq      int         `json:"message_seq"`
	Font            int         `json:"font"`
	UserID          int64       `json:"user_id"`
	RealMessageType string      `json:"real_message_type"`  //当前信息的真实类型 group group_private guild guild_private
	IsBindedGroupId bool        `json:"is_binded_group_id"` //当前群号是否是binded后的
	IsBindedUserId  bool        `json:"is_binded_user_id"`  //当前用户号号是否是binded后的
}

群信息事件

type OnebotGroupMessageS

type OnebotGroupMessageS struct {
	RawMessage      string      `json:"raw_message"`
	MessageID       string      `json:"message_id"`
	GroupID         string      `json:"group_id"` // Can be either string or int depending on p.Settings.CompleteFields
	MessageType     string      `json:"message_type"`
	PostType        string      `json:"post_type"`
	SelfID          int64       `json:"self_id"` // Can be either string or int
	Sender          Sender      `json:"sender"`
	SubType         string      `json:"sub_type"`
	Time            int64       `json:"time"`
	Avatar          string      `json:"avatar,omitempty"`
	Echo            string      `json:"echo,omitempty"`
	Message         interface{} `json:"message"` // For array format
	MessageSeq      int         `json:"message_seq"`
	Font            int         `json:"font"`
	UserID          string      `json:"user_id"`
	RealMessageType string      `json:"real_message_type,omitempty"`  //当前信息的真实类型 group group_private guild guild_private
	RealUserID      string      `json:"real_user_id,omitempty"`       //当前真实uid
	RealGroupID     string      `json:"real_group_id,omitempty"`      //当前真实gid
	IsBindedGroupId bool        `json:"is_binded_group_id,omitempty"` //当前群号是否是binded后的
	IsBindedUserId  bool        `json:"is_binded_user_id,omitempty"`  //当前用户号号是否是binded后的
}

type OnebotPrivateMessage

type OnebotPrivateMessage struct {
	RawMessage      string        `json:"raw_message"`
	MessageID       int           `json:"message_id"` // Can be either string or int depending on logic
	MessageType     string        `json:"message_type"`
	PostType        string        `json:"post_type"`
	SelfID          int64         `json:"self_id"` // Can be either string or int depending on logic
	Sender          PrivateSender `json:"sender"`
	SubType         string        `json:"sub_type"`
	Time            int64         `json:"time"`
	Avatar          string        `json:"avatar,omitempty"`
	Echo            string        `json:"echo,omitempty"`
	Message         interface{}   `json:"message"`           // For array format
	MessageSeq      int           `json:"message_seq"`       // Optional field
	Font            int           `json:"font"`              // Optional field
	UserID          int64         `json:"user_id"`           // Can be either string or int depending on logic
	RealMessageType string        `json:"real_message_type"` //当前信息的真实类型 group group_private guild guild_private
	IsBindedUserId  bool          `json:"is_binded_user_id"` //当前用户号号是否是binded后的
}

私聊信息事件

type PrivateSender

type PrivateSender struct {
	Nickname string `json:"nickname"`
	UserID   int64  `json:"user_id"` // Can be either string or int depending on logic
}

type Processors

type Processors struct {
	Settings        *config.Settings                  // 使用指针
	Wsclient        []*wsclient.WebSocketClient       // 指针的切片
	WsServerClients []callapi.WebSocketServerClienter //ws server被连接的客户端
}

Processor 结构体用于处理消息

func NewProcessor

func NewProcessor(settings *config.Settings, wsclient []*wsclient.WebSocketClient) *Processors

修改函数的返回类型为 *Processor

func NewProcessorV2

func NewProcessorV2(settings *config.Settings) *Processors

修改函数的返回类型为 *Processor

func (*Processors) BroadcastMessageToAll

func (p *Processors) BroadcastMessageToAll(message map[string]interface{}) error

方便快捷的发信息函数

func (*Processors) HandleFrameworkCommand

func (p *Processors) HandleFrameworkCommand(messageText string, data interface{}, Type string, s *discordgo.Session) error

func (*Processors) ProcessChannelDirectMessage

func (p *Processors) ProcessChannelDirectMessage(data *discordgo.MessageCreate, se *discordgo.Session) error

ProcessChannelDirectMessage 处理频道私信消息 这里我们是被动收到

func (*Processors) ProcessGuildNormalMessage

func (p *Processors) ProcessGuildNormalMessage(data *discordgo.MessageCreate, se *discordgo.Session) error

ProcessGuildNormalMessage 处理频道常规消息

func (*Processors) SendMessageToAllClients

func (p *Processors) SendMessageToAllClients(message map[string]interface{}) error

发信息给所有连接正向ws的客户端

type Sender

type Sender struct {
	Nickname string `json:"nickname"`
	TinyID   string `json:"tiny_id"`
	UserID   int64  `json:"user_id"`
	Role     string `json:"role,omitempty"`
	Card     string `json:"card,omitempty"`
	Sex      string `json:"sex,omitempty"`
	Age      int32  `json:"age,omitempty"`
	Area     string `json:"area,omitempty"`
	Level    string `json:"level,omitempty"`
	Title    string `json:"title,omitempty"`
}

Jump to

Keyboard shortcuts

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