Yogurt-0.3: A MUD client librarySource codeContentsIndex
Network.Yogurt.Utils
Contents
Hook and timer derivatives
Timers
Sending messages
Logging
Miscellaneous
Description
Convenience functions on top of Yogurt.Mud.
Synopsis
mkTrigger :: Pattern -> Mud a -> Mud Hook
mkTriggerOnce :: Pattern -> Mud a -> Mud Hook
mkAlias :: String -> String -> Mud Hook
mkArgAlias :: String -> ([String] -> String) -> Mud Hook
mkCommand :: String -> Mud a -> Mud Hook
data Timer
type Interval = Int
mkTimer :: Interval -> Mud a -> Mud Timer
mkTimerOnce :: Interval -> Mud a -> Mud Timer
rmTimer :: Timer -> Mud ()
isTimerActive :: Timer -> Mud Bool
receive :: String -> Mud ()
sendln :: String -> Mud ()
echo :: String -> Mud ()
echoln :: String -> Mud ()
echorln :: String -> Mud ()
bell :: Mud ()
type Logger = (Hook, Hook)
startLogging :: String -> Mud Logger
stopLogging :: Logger -> Mud ()
matchMore :: Mud ()
matchMoreOn :: String -> Mud ()
matchMoreOn' :: String -> Mud ()
Hook and timer derivatives
mkTrigger :: Pattern -> Mud a -> Mud HookSource
Creates a hook that watches messages headed to the terminal. When fired, the message is passed on to the terminal and the action is executed.
mkTriggerOnce :: Pattern -> Mud a -> Mud HookSource
Like mkTrigger, but fires at most once.
mkAlias :: String -> String -> Mud HookSource
mkAlias command subst creates a hook that watches messages headed to the remote MUD. If the message is or starts with the word command, the command is replaced by subst before being sent to the MUD.
mkArgAlias :: String -> ([String] -> String) -> Mud HookSource
Like mkAlias, mkArgAlias command subst creates a hook that watches messages headed to the remote MUD. But here the whole message is substituted instead of just the first command word, and the substitution depends on the command's arguments.
mkCommand :: String -> Mud a -> Mud HookSource
Like mkAlias, but instead of substituting the command, a program is executed.
Timers
data Timer Source
The abstract Time type.
type Interval = IntSource
Interval in milliseconds.
mkTimer :: Interval -> Mud a -> Mud TimerSource
mkTimer interval prog creates a timer that executes prog every interval milliseconds.
mkTimerOnce :: Interval -> Mud a -> Mud TimerSource
Creates a timer that fires only once.
rmTimer :: Timer -> Mud ()Source
Disables the timer.
isTimerActive :: Timer -> Mud BoolSource
Checks whether a timer is active. A timer is deactivated by rmTimer.
Sending messages
receive :: String -> Mud ()Source
Sends a message to the terminal, triggering hooks.
sendln :: String -> Mud ()Source
Sends a message appended with a newline character to the MUD, triggering hooks.
echo :: String -> Mud ()Source
Sends a message to the terminal, without triggering hooks.
echoln :: String -> Mud ()Source
Sends a message appended with a newline character to the terminal, without triggering hooks.
echorln :: String -> Mud ()Source
Sends a message appended with a newline character to the MUD, without triggering hooks.
bell :: Mud ()Source
Sends a bell character to the terminal.
Logging
type Logger = (Hook, Hook)Source
startLogging :: String -> Mud LoggerSource
startLogging name causes all messages to be logged in a file called name-yyyymmdd-hhmm.log. The used hooks have priority 100.
stopLogging :: Logger -> Mud ()Source
Stops the logger.
Miscellaneous
matchMore :: Mud ()Source
When called from a hook body, gives hooks that haven't been considered yet a chance to match on the currently triggering message. Useful if you want to build a hook that only has a side-effect and doesn't want to directly affect the other active hooks.
matchMoreOn :: String -> Mud ()Source
Like matchMore, but allows specification of the message that is passed on.
matchMoreOn' :: String -> Mud ()Source
Like matchMoreOn, but also makes the currently firing hook eligible for firing again.
Produced by Haddock version 2.4.2