message

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToTMI

func ToTMI(msg Sent) *tmi.Message

ToTMI creates a message to send to TMI. If reply is not empty, then the result is a reply to the message with that ID.

Types

type Received

type Received[U comparable] struct {
	// ID is the unique ID of the message.
	ID string
	// To is the destination of the message. This may be the identifier of a
	// room or channel or the name of a user.
	To string
	// Sender is a unique identifier for the message sender.
	// Whether it remains constant for a given sender depends on the semantics
	// of the type argument.
	Sender U
	// Text is the text of the message.
	Text string
	// Timestamp is the timestamp of the message as milliseconds since the
	// Unix epoch.
	Timestamp int64
	// IsModerator indicates whether the sender can moderate the room to which
	// the message was sent.
	IsModerator bool
	// IsElevated indicates whether the message sender is known to have
	// elevated privileges with respect to the bot, for example a subscriber
	// on Twitch. This may not implicitly include moderators.
	IsElevated bool
}

Received is a message received from a service.

func FromTMI

func FromTMI(m *tmi.Message) *Received[User]

FromTMI adapts a TMI IRC message.

func (*Received[U]) Time

func (m *Received[U]) Time() time.Time

type Sent

type Sent struct {
	// Reply is a message to reply to. If empty, the message is not interpreted
	// as a reply.
	Reply string
	// To is the channel to whom the message is sent.
	To string
	// Text is the message text.
	Text string
}

Sent is a message to be sent to a service.

func Format

func Format(to string, f formatString, args ...any) Sent

Format constructs a message to send from a format string literal and formatting arguments.

func (Sent) AsReply

func (m Sent) AsReply(reply string) Sent

type User

type User struct {
	// ID is a user's ID.
	// It must remain constant for a given user even across name changes.
	ID string
	// Name is a user's display name.
	Name string
}

User is a user's ID and display name.

Jump to

Keyboard shortcuts

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