Documentation ¶
Overview ¶
Package ipc describes an IPC request/response protocol for communicating chat commands and chat response messages.
Index ¶
Constants ¶
const ( // CooldownUser mode cools down the channel as well as the user and is the // default mode. CooldownUser int = 0 // CooldownChannel mode cools down the channel only. CooldownChannel = 1 // CooldownNone mode does not have a user/channel cooldown. Rather, the // command has its own cooldown implementation or uses a cooldown key that // can ignore channel cooldown. CooldownNone = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Commands []string `json:"commands"` // A verbatim command never has a prefix adjustment Verbatim bool `json:"verbatim,omitempty"` Strict bool `json:"strict,omitempty"` // Does not accept arguments ArgValidator string `json:"arg_validator,omitempty"` // Regex to apply to argument string Endpoint string `json:"endpoint"` Async bool `json:"async,omitempty"` Admin bool `json:"admin,omitempty"` Owner bool `json:"owner,omitempty"` Privileged bool `json:"privileged,omitempty"` AlwaysOn bool `json:"online,omitempty"` CooldownMode int `json:"cooldown_mode,omitempty"` Cooldown string `json:"cooldown,omitempty"` CooldownTime int `json:"cooldown_int,omitempty"` }
A Command is a complete description of a command and its keywords.
type Fragment ¶
type Fragment struct { // M is the token M string `json:"m"` // If X is set, banphrase checking needs to be performed X bool `json:"x,omitempty"` }
A Fragment is a partial message. Individual elements of the message can be banphrase-checked.
func M ¶
M is used to create a fragment that does not need to be banphrase-checked.
type Host ¶
type Host struct { BaseURL string `json:"base_url"` Headers map[string]string `json:"headers"` MsgPack bool `json:"msgpack,omitempty"` }
A Host implements commands.
type HostCommandSet ¶
type HostCommandSet struct { ID string `json:"id"` BaseURL string `json:"base_url"` Headers map[string]string `json:"headers,omitempty"` MsgPack bool `json:"msgpack,omitempty"` Commands []Command `json:"commands"` // TODO: perhaps this is per command SetTag string `json:"set_tag"` Whisper bool `json:"whisper,omitempty"` }
A HostCommandSet is used to communicate the commands offered by a service.
func (HostCommandSet) Host ¶
func (hcs HostCommandSet) Host() Host
Host extracts a Host structure from a HostCommandSet.
type Response ¶
type Response = TwitchMessageResponse
func Direct ¶
Direct returns a direct response to a user. Intended for system messages.
type TwitchMessageContext ¶
type TwitchMessageContext struct { Timestamp int64 `json:"ts"` User string `json:"user"` UserID string `json:"uid"` DisplayName string `json:"display"` TargetUser string `json:"target"` // For whispers, equal to User Tags map[string]string `json:"tags,omitempty"` NormalizedMessage string `json:"msg"` Prefix string `json:"prefix,omitempty"` Command string `json:"cmd"` Args []string `json:"args"` }
A TwitchMessageContext is a message context for Twitch-based command triggers.
type TwitchMessageResponse ¶
type TwitchMessageResponse struct { Fragments []Fragment `json:"fragmsg,omitempty"` Command bool `json:"cmd,omitempty"` // Execute as command Response string `json:"response,omitempty"` Inline bool `json:"inline,omitempty"` // Can be inlined Whisper bool `json:"whisper,omitempty"` // Should reply as whisper CooldownKey string `json:"cooldown_key,omitempty"` CooldownTime int `json:"cooldown_time,omitempty"` // Output should be discarded if it was recently sent IsCooldownReaction bool `json:"is_cooldown_reaction,omitempty"` }
A TwitchMessageResponse is a response to a command. If Response is empty, the cooldown associated with the command is not processed.
TODO: support high-rate commands like Pajbot does to merge command output using templated/combined message responses.