Copyright | (c) Leon Medvinsky, 2015 |
---|---|
License | GPL-3 |
Maintainer | lmedvinsky@hotmail.com |
Stability | experimental |
Portability | ghc |
Safe Haskell | None |
Language | Haskell2010 |
- data MessageInfo = MessageInfo {}
- data MessageType
- data Trigger
- data TriggerAct var perma r
- mkTrigger :: (MessageInfo -> Bool) -> (MessageInfo -> TriggerAct a b c) -> a -> Trigger
- mkTrigger_ :: (MessageInfo -> Bool) -> (MessageInfo -> TriggerAct () b c) -> Trigger
- send :: Text -> TriggerAct a b ()
- printLn :: Text -> TriggerAct a b ()
- getVar :: TriggerAct a b a
- storeVar :: a -> TriggerAct a b ()
- duraGet :: TriggerAct a b b
- duraStore :: b -> TriggerAct a b ()
- sendChat :: Text -> Text -> TriggerAct a b ()
- sendPm :: Text -> Text -> TriggerAct a b ()
- command :: Text -> Text -> TriggerAct a b ()
- clusterTrigger :: forall a b. [(MessageInfo -> Bool, MessageInfo -> TriggerAct a b ())] -> a -> Trigger
Documentation
data MessageType Source
The type of a message
Triggers
data TriggerAct var perma r Source
An effect that a Trigger
might produce.
var
is the type of the runtime variable the trigger uses to store data.
perma
is the type of the persistent data for this trigger.
r
is the type of the result of this effect.
Monad (TriggerAct a b) | |
Functor (TriggerAct a b) | |
Applicative (TriggerAct a b) | |
MonadIO (TriggerAct a b) |
Construction
mkTrigger :: (MessageInfo -> Bool) -> (MessageInfo -> TriggerAct a b c) -> a -> Trigger Source
mkTrigger
takes a predicate on message types, and a function to create
a TriggerAct
. The predicate is used to see if a message should be
processed by this Trigger
, and the second function determines what actually
happens when the Trigger
is triggered. The third argument is the initial
state of the trigger.
mkTrigger_ :: (MessageInfo -> Bool) -> (MessageInfo -> TriggerAct () b c) -> Trigger Source
Version for TriggerAct
s with no state
Actions
Basic
send :: Text -> TriggerAct a b () Source
Sends the given message to the server.
printLn :: Text -> TriggerAct a b () Source
Prints the given message to the console.
getVar :: TriggerAct a b a Source
Gets the value of the trigger's runtime store.
storeVar :: a -> TriggerAct a b () Source
Stores a value into the trigger's runtime store.
duraGet :: TriggerAct a b b Source
Gets the persistent data for this trigger.
duraStore :: b -> TriggerAct a b () Source
Stores persistent data for this trigger.
Convenience
sendChat :: Text -> Text -> TriggerAct a b () Source
Takes a room and a message, then sends a message to that room
sendPm :: Text -> Text -> TriggerAct a b () Source
Takes a user and a message, sending a pm to that user
command :: Text -> Text -> TriggerAct a b () Source
Executes a command in the given room (empty string means default room) and given command string.
clusterTrigger :: forall a b. [(MessageInfo -> Bool, MessageInfo -> TriggerAct a b ())] -> a -> Trigger Source
Combines multiple predicate and TriggerActions into one big blob that shares runtime state. Second argument is initial state.