Documentation ¶
Index ¶
- func DispatchMessages(in, out chan *struc.IRCMessage, scripts []Botscript) error
- func NoAction(msg *struc.IRCMessage, args []string, kwargs map[string]string) *struc.IRCMessage
- func ParseIRCMessage(msg []byte, out chan *struc.IRCMessage)
- func ParsingLoop(in chan []byte, out chan *struc.IRCMessage)
- func Pong(msg *struc.IRCMessage, out chan *struc.IRCMessage)
- func UnParsingLoop(in chan *struc.IRCMessage, out chan []byte)
- func UnparseIRCMessage(msg *struc.IRCMessage, out chan []byte)
- func YesFilter(msg *struc.IRCMessage) (bool, []string, map[string]string)
- type Action
- type Botscript
- type Filter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DispatchMessages ¶
func DispatchMessages(in, out chan *struc.IRCMessage, scripts []Botscript) error
DispatchMessages loops infinitely, accepting parsed versions of received IRC messages and dispatching them to botscripts. These botscripts return any messages they want to send on the 'out' channel. This can be viewed as the 'main' loop in GoBot. To stop this goroutine, close the input channel.
func NoAction ¶
func NoAction(msg *struc.IRCMessage, args []string, kwargs map[string]string) *struc.IRCMessage
NoAction defines the basic action to take in receipt of a message: none.
func ParseIRCMessage ¶
func ParseIRCMessage(msg []byte, out chan *struc.IRCMessage)
ParseIRCMessage takes a byte array of an IRC message and parses it into an IRCMessage structure. This function isn't necessarily cheap, so expects to be run as a goroutine. There are a ton of casual assumptions in here that make this function less-than-resilient. I'm going to call it "low-hanging fruit for future improvement" and move on with my life.
func ParsingLoop ¶
func ParsingLoop(in chan []byte, out chan *struc.IRCMessage)
ParsingLoop provides a tight loop that pops values off the input channel and dispatches goroutines to parse them. This loop is very small to attempt to avoid bottlenecking. To stop this goroutine, close the input channel.
func Pong ¶
func Pong(msg *struc.IRCMessage, out chan *struc.IRCMessage)
Pong responds an IRC PING message with an IRC PONG message.
func UnParsingLoop ¶
func UnParsingLoop(in chan *struc.IRCMessage, out chan []byte)
UnParsingLoop provides a tight loop that pops values off the input channel and dispatches goroutines to unparse them. This loop is very small to avoid bottlenecking, as it will get quite a lot of traffic. To stop this goroutine, close the input channel.
func UnparseIRCMessage ¶
func UnparseIRCMessage(msg *struc.IRCMessage, out chan []byte)
UnparseIRCMessage builds an IRC message into a byte array suitable for sending on the wire. This method is not necessarily cheap, so it expects to be run as a goroutine.
Types ¶
type Action ¶
type Action func(*struc.IRCMessage, []string, map[string]string) *struc.IRCMessage
Actions are functions that respond to a given IRC message with a different IRC message.
func LogAction ¶
LogAction builds an action that writes any IRC message to a logging source (represented by the io.Writer).
func PrintAction ¶
PrintAction builds an action that replies to an IRC message with another message, based on a format string that's not unlike a shell string using variable substitution.
type Botscript ¶
type Botscript func(in, out chan *struc.IRCMessage)
A Botscript represents a series of filters and actions to be applied on receipt of an IRC message. These expect to be launched as goroutines that run for the life of the program. They can be stopped from running by closing the input channel. They will not close their output channel before they exit.
func BuildBotscript ¶
BuildBotscript creates a function that corresponds to a botscript that applies a variety of filters and actions to an incoming message.
type Filter ¶
The Filter type is the type of the functions that act as filters. They accept IRCMessage structures and return whether or not the given message matches the filter, and any arguments or keyword arguments they want passed to actions.
func RegexFilterFromRegex ¶
RegexFilterFromRegex takes a regular expression and returns a filter function that applies the given regular expression to each incoming IRC message. For the moment the regular expressiont treats named groups just the same as normal groups.