| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.IRC.Fun.Bot.State
Description
This module provides access functions for working with the state stored within a bot session.
- askConfig :: Session e s Config
- askConfigS :: (Config -> a) -> Session e s a
- askBehavior :: Session e s (Behavior e s)
- askBehaviorS :: (Behavior e s -> a) -> Session e s a
- askTimeGetter :: Session e s (IO (UTCTime, String))
- askEnv :: Session e s e
- askEnvS :: (e -> a) -> Session e s a
- getState :: Session e s s
- getStateS :: (s -> a) -> Session e s a
- putState :: s -> Session e s ()
- modifyState :: (s -> s) -> Session e s ()
- getChannelState :: Session e s (HashMap String (Bool, Bool))
- selectChannel :: String -> Session e s ()
- unselectChannel :: String -> Session e s ()
- channelSelected :: String -> Session e s Bool
- botMemberOf :: String -> Session e s Bool
- addChannelState :: String -> Session e s ()
- saveBotState :: Session e s ()
Documentation
askConfigS :: (Config -> a) -> Session e s a Source
Retrieve a function of the bot configuration.
askBehavior :: Session e s (Behavior e s) Source
Fetch the bot behavior definition.
askBehaviorS :: (Behavior e s -> a) -> Session e s a Source
Retrieve a function of the bot behavior definition.
askTimeGetter :: Session e s (IO (UTCTime, String)) Source
Fetch the time getter. The actual time data is cached and updated at most once per second depending on need. You can safely use it at any frequency withou overloading IO and time formatting.
The second item is a formatted time string in the form
2015-09-01 18:10:00, and is always expressed in UTC.
getStateS :: (s -> a) -> Session e s a Source
Get a specific component of the state, using a projection function supplied.
modifyState :: (s -> s) -> Session e s () Source
Update the state to the result of applying a function to the current state.
getChannelState :: Session e s (HashMap String (Bool, Bool)) Source
Get channel state information, in the form of a mapping from channel names to their data.
Channel data is a pair of two booleans. The first says whether channel tracking is enabled. The second says whether channel logging info a file is enabled.
selectChannel :: String -> Session e s () Source
Add a channel to the persistent list of channels to be joined. Next time
the bot launches (or, say, joinConfig is called), it will join this
channel. If the channel is already listed, nothing happens.
unselectChannel :: String -> Session e s () Source
Remove a channel from the persistent list of channels to be joined. Next time the bot launches, it won't join this channel (unless listed in the config or otherwise requested). If the channel isn't listed, nothing happens.
channelSelected :: String -> Session e s Bool Source
Check whether a channel is listed in persistent state to be joined.
botMemberOf :: String -> Session e s Bool Source
Check whether, as far as the bot knows, if it currently a member of the given channel. Currently kicks, bans, etc. are fully tracked, therefore this information isn't 100% accurate, but if you aren't planning to ban your bot you can probably rely on it.
addChannelState :: String -> Session e s () Source
Add default channel state for the given channel. It will be stored into the state file. If the channel already has state, nothing will happen.
saveBotState :: Session e s () Source