Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides utilities for working with the bot's behavior definition. While the library handles event dispatch by itself, custom commands and bot features may benefit from having this module available to them (e.g. a bot's help system).
- defaultBehavior :: Behavior e s
- findCmdInSet :: String -> CommandSet e s -> Maybe (Command e s)
- findCmdInSets :: Char -> String -> [CommandSet e s] -> Maybe (Command e s)
- findCmd :: Char -> String -> [CommandSet e s] -> Maybe (Either (CommandSet e s) (Command e s))
- findSet :: Char -> [CommandSet e s] -> Maybe (CommandSet e s)
- searchCmds :: String -> [CommandSet e s] -> [(Char, Command e s)]
- listNames :: Maybe Char -> Maybe Quotes -> Bool -> [String] -> String
- listPrimaryNames :: Maybe Char -> Maybe Quotes -> Bool -> [Command e s] -> String
Defining
defaultBehavior :: Behavior e s Source
A default behavior definition which be convenienty overridden and extended using record syntax. It currently simply doesn't do anything (pings do get handled behind the scenes), but things like default responses and logging could be added in the future.
Searching
findCmdInSet :: String -> CommandSet e s -> Maybe (Command e s) Source
Take a command name (without prefix) and a command set, and return the
(leftmost) command which has that name, or Nothing
if there is no such
command.
findCmdInSets :: Char -> String -> [CommandSet e s] -> Maybe (Command e s) Source
Find a command in a list of command sets, using the given prefix character
and command name. This is a shortcut for findCmd
which doesn't return the
matched command set (for the cases you only need to find the command).
:: Char | Command prefix to search for |
-> String | Command name to search for |
-> [CommandSet e s] | Command set in which to search |
-> Maybe (Either (CommandSet e s) (Command e s)) |
findSet :: Char -> [CommandSet e s] -> Maybe (CommandSet e s) Source
Take a command prefix and a list of command sets, and return the
(leftmost) set which has that prefex, or Nothing
if there is no such set.
searchCmds :: String -> [CommandSet e s] -> [(Char, Command e s)] Source
Search for commands by testing a search string against their textual fields: Names and help strings. Each returned pair is a command and the prefix under which it was found.