Help us shape the future of Go! Take the 2026 Go Developer Survey

messaging

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapFileNameBytes

func CapFileNameBytes(name string, maxBytes int) string

CapFileNameBytes truncates name to at most maxBytes bytes while preserving a short extension (≤16 bytes) when present and never splitting a UTF-8 rune.

func SanitizeFileNamePart

func SanitizeFileNamePart(s string) string

SanitizeFileNamePart keeps Unicode letters/digits plus `._-` and replaces everything else with '_'. Leading / trailing punctuation is trimmed so the result is safe to embed as one segment in a generated filename.

Types

type ChatType

type ChatType string
const (
	ChatTypeP2P   ChatType = "p2p"
	ChatTypeGroup ChatType = "group"
)

type EventHandler

type EventHandler interface {
	OnMessage(ctx context.Context, msg *Message)
}

type Listener

type Listener interface {
	Start(ctx context.Context) error
}

type MediaPayload

type MediaPayload struct {
	URL  string
	Path string
}

MediaPayload describes one outbound media attachment. Exactly one of URL or Path should be set by callers. URL is used for externally hosted media; Path is used for already downloaded local files.

type MediaReplier

type MediaReplier interface {
	Replier
	ReplyMedia(ctx context.Context, messageID string, media MediaPayload) error
}

MediaReplier is an optional extension implemented by platforms that can send native media messages. Callers should type-assert this interface and fall back to ReplyText when a platform does not support it.

type Mention

type Mention struct {
	ID            MentionID
	Key           string
	MentionedType string
	Name          string
	TenantKey     string
}

type MentionID

type MentionID struct {
	OpenID  string
	UnionID string
	UserID  string
}

type Message

type Message struct {
	Platform    Platform
	MessageID   string
	ParentID    string
	RootID      string
	ChatID      string
	ChatType    ChatType
	SenderID    string
	MessageType string
	Content     string
	// CreateTime / UpdateTime keep the raw platform timestamp strings for
	// prompt-template compatibility. ReceivedAt is when Quartet accepted the
	// message; EventTime is the parsed platform event time when available.
	CreateTime string
	UpdateTime string
	ReceivedAt time.Time
	EventTime  time.Time
	Mentions   []Mention
	RawEvent   []byte
}

type Platform

type Platform string
const (
	PlatformLark   Platform = "lark"
	PlatformWeChat Platform = "wechat"
)

type Replier

type Replier interface {
	SendText(ctx context.Context, chatID, content string) error
	ReplyText(ctx context.Context, messageID, content string) error
}

Directories

Path Synopsis
Package media owns platform-agnostic IM attachment directories.
Package media owns platform-agnostic IM attachment directories.
Package wechat provides personal-WeChat integration via the iLink protocol.
Package wechat provides personal-WeChat integration via the iLink protocol.
cdn
Package cdn talks to the WeChat C2C CDN: encrypts files locally with AES-128-ECB, hands them to the upload endpoint, and inverts the flow on the download side.
Package cdn talks to the WeChat C2C CDN: encrypts files locally with AES-128-ECB, hands them to the upload endpoint, and inverts the flow on the download side.

Jump to

Keyboard shortcuts

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