Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commands ¶
type Commands map[string]CommandRunFunc
func (Commands) ReadMessage ¶
Message Reader. Prefix must be manually cutted. Every run function provided by a command will be run with goroutine.
var cmds commands.Commands for s.Scan() { // ... user, cmd, flags, fullmsg := irc.ParseLine(line) if cmd == "PRIVMSG" { msg, hasPrefix := strings.CutPrefix(fullmsg, "!") // assuming ! is your bot's prefix if !hasPrefix { continue // ignore message that has no bot prefix } to := flags[0] if to == botnick { to = user.Nick // this is PM } invalid := cmds.ReadMessage(conn, user, to, msg) if invalid { irc.Chat(conn, to, fmt.Sprintf("%s: Unknown command", user.Nick)) } } }
func (Commands) RegisterCommand ¶
func (s Commands) RegisterCommand(name string, run CommandRunFunc) (overrided bool)
Command registerer. `overrided` may return false if existing command has been registered in a map.
Click to show internal directories.
Click to hide internal directories.