types

package
v0.0.0-...-4ca2c20 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeMessage = "message" // 消息事件
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelMessageEvent

type ChannelMessageEvent struct {
	MessageEvent
	ChannelID string `json:"channel_id"` // Channel ID
	UserID    string `json:"user_id"`    // Sender Node ID
}

type Event

type Event struct {
	Time       string `json:"time"`           // RFC3339Nano format
	TimeISO    string `json:"time_iso"`       // RFC3339 format
	Type       string `json:"type"`           // message or other ob12 type
	DetailType string `json:"detail_type"`    // p2p or channel
	Hash       string `json:"hash,omitempty"` // optional hash
}

基础事件类型

func (*Event) Name

func (e *Event) Name() string

type Message

type Message []Segment

func PlaintextToMessage

func PlaintextToMessage(text string) Message

func (Message) Empty

func (msg Message) Empty() bool

func (Message) ExtractPlaintext

func (msg Message) ExtractPlaintext() string

type MessageEvent

type MessageEvent struct {
	Event
	Message Message `json:"message"`
}

type P2PMessageEvent

type P2PMessageEvent struct {
	MessageEvent
	UserID string `json:"user_id"` // Sender Node ID, empty in send
}

func MakeP2PMessageEvent

func MakeP2PMessageEvent(message Message) P2PMessageEvent

MakeP2PMessageEvent do not assiocate with anyone, it should just be sent and handled by receiver

type Segment

type Segment struct {
	Type string `json:"type"`
	Data any    `json:"data"`
}

type TextSegment

type TextSegment struct {
	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

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