irc-fun-bot-0.3.0.0: Library for writing fun IRC bots.

Safe HaskellNone
LanguageHaskell2010

Network.IRC.Fun.Bot.Behavior

Contents

Description

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).

Synopsis

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).

findCmd Source

Arguments

:: 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)) 

Find a command in a list of command sets, using the given prefix character and command name. If the prefix isn't matched, Nothing is returned. If the prefix is matched but the command isn't, Just Left the command set is returned. Otherwise, Just Right the matched command is returned.

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.

Showing

listNames Source

Arguments

:: Maybe Char

Optionally prepend the prefix char to names

-> Maybe Quotes

Optionally add quotes around the names

-> Bool

Whether to separate with commas (otherwise spaces)

-> [String]

List of command names

-> String 

Format a list of command names.

listPrimaryNames Source

Arguments

:: Maybe Char

Optionally prepend the prefix char to names

-> Maybe Quotes

Optionally add quotes around the names

-> Bool

Whether to separate with commas (otherwise spaces)

-> [Command e s]

List of commands

-> String 

Format a list of the primary names of the given commands.