Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageSource ¶
type MessageSource string
MessageSource is the source of a Minecraft message, either a player or the server.
const ( // PlayerSource indicates that a message came from a player, e.g. // a chat message. PlayerSource MessageSource = "Player" // ServerSource indicates that a message came from the server, // such as when a player joins. ServerSource MessageSource = "Server" )
type MinecraftMessage ¶
type MinecraftMessage struct {
Username string `json:"name"`
Content string `json:"content"`
Source MessageSource `json:"source"`
UUID string `json:"uuid"`
}
MinecraftMessage represents a message from Minecraft to be sent to Discord.
type MinecraftWatcher ¶
type MinecraftWatcher struct {
// contains filtered or unexported fields
}
MinecraftWatcher watches for log lines from a Minecraft server.
func NewWatcher ¶
func NewWatcher(path string, logger *waterlog.WaterLog, customDeathKeywords []string) *MinecraftWatcher
NewWatcher creates a new watcher with all of the Minecraft death message keywords.
func (*MinecraftWatcher) Close ¶
func (w *MinecraftWatcher) Close() error
Close stops the tail process and cleans up inotify file watches.
func (MinecraftWatcher) GetUUID ¶ added in v1.1.0
func (w MinecraftWatcher) GetUUID(name string) (uuid string, ok bool)
GetUUID returns a UUID if present in the cache. See docs for Go maps. This is only meant to be used as a testing helper function.
func (*MinecraftWatcher) ParseLine ¶
func (w *MinecraftWatcher) ParseLine(line string) *MinecraftMessage
ParseLine parses a log line for various types of messages and returns a MinecraftMessage struct if it is a message we care about.
func (*MinecraftWatcher) Watch ¶
func (w *MinecraftWatcher) Watch(c chan<- *MinecraftMessage)
Watch watches a log file for changes and sends Minecraft messages to the given channel.