Convenience functions on top of Yogurt.Mud.
- mkTrigger :: Pattern -> Mud a -> Mud Hook
- mkTriggerOnce :: Pattern -> Mud a -> Mud Hook
- triggerOneOf :: [(Pattern, Mud ())] -> Mud ()
- 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 ()
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.
For each pair
(pattern, action) a hook is installed. As soon as one of the hooks fires, the hooks are removed and the corresponding action is executed.
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 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.
mkTimer interval prog creates a timer that executes
Checks whether a timer is active. A timer is deactivated by
Sends a message appended with a newline character to the MUD, triggering hooks.
Sends a message appended with a newline character to the terminal, without triggering hooks.
Sends a message appended with a newline character to the MUD, without triggering hooks.
startLogging name causes all messages to be logged in a file called
name-yyyymmdd-hhmm.log. The used hooks have priority 100.
Triggering multiple hooks
By default, when a message causes a hook to fire, the message is stopped and discarded unless the hook decides otherwise. These functions provide ways to give other hooks with lower priorities a chance to fire as well.
When called from a hook body, gives hooks that haven't been considered yet a chance to match on the currently triggering message. If no other hooks match, the message is sent on to its destination. 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.
matchMore, but allows specification of the message that is passed on.