Documentation ¶
Overview ¶
Package ipc describes an IPC request/response protocol for communicating chat commands and chat response messages.
Index ¶
Constants ¶
View Source
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 ¶
View Source
var Direct = Reply
Direct returns a direct response to a user. Intended for system messages.
View Source
var NoResponse = Response{}
Functions ¶
Types ¶
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.
type IRC ¶
type MessageContext ¶
type MessageContext struct { Timestamp int64 `json:"ts"` Platform string `json:"platform"` NormalizedMessage string `json:"msg"` Command string `json:"cmd"` Args []string `json:"args"` Prefix string `json:"prefix,omitempty"` User string `json:"user"` // Unique, but not permanent UserID string `json:"uid"` // Unique DisplayName string `json:"display"` // Friendly, sometimes unique TargetUser string `json:"target"` // For whispers, equal to User Tags map[string]string `json:"tags,omitempty"` }
A MessageContext is a message context for Twitch-based command triggers.
func (MessageContext) Arg ¶
func (mctx MessageContext) Arg(i int) string
func (MessageContext) Trailer ¶
func (mctx MessageContext) Trailer(i int) string
type Response ¶
type Response struct { Fragmsg []Fragment `json:"fragmsg,omitempty"` Fragments []string `json:"frags,omitempty"` Command bool `json:"cmd,omitempty"` // Execute as command SkipsBanphrase bool `json:"no_bancheck,omitempty"` // Explicitly for commands or specialized messages DeprecatedResponse string `json:"response,omitempty"` NotIfBanphrased bool `json:"not_if_bp,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 Response 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.
Click to show internal directories.
Click to hide internal directories.