msg

package
v0.0.0-...-c10fe95 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidChatPacket       = errors.New("invalid chat packet")
	ValidationFailed  error = bot.DisconnectErr(chat.TranslateMsg("multiplayer.disconnect.chat_validation_failed"))
)

Functions

This section is empty.

Types

type EventsHandler

type EventsHandler struct {
	// SystemChat handles messages sent by gaming system.
	//
	// In vanilla client:
	// If overlay is false, the message will be displayed in the chat box.
	// If overlay is true, the message will be displayed on the top of the hot-bar.
	SystemChat func(msg chat.Message, overlay bool) error

	// PlayerChatMessage handles messages sent by players.
	//
	// Message signing system is added in 1.19. The message and its context could be signed by the player's private key.
	// The manager tries to verify the message signature through the player's public key,
	// and return the result as validated boolean.
	PlayerChatMessage func(msg chat.Message, validated bool) error

	// DisguisedChat handles DisguisedChat message.
	//
	// DisguisedChat message used to send system chat.
	// Now it is used to send messages from "/say" command from server console.
	DisguisedChat func(msg chat.Message) error
}

EventsHandler is a collection of event handlers. Fill the fields with your handler functions and pass this struct to New to create the msg manager. The handler functions will be called when the corresponding event is triggered. Leave the fields as nil if you don't want to handle the event.

type Manager

type Manager struct {
	sign.SignatureCache
	// contains filtered or unexported fields
}

The Manager is used to receive and send chat messages.

func New

func New(c *bot.Client, p *basic.Player, pl *playerlist.PlayerList, events EventsHandler) *Manager

New returns a new chat manager.

func (*Manager) SendMessage

func (m *Manager) SendMessage(msg string) error

SendMessage send chat message to server. Doesn't support sending message with signature currently.

Jump to

Keyboard shortcuts

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