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

Safe HaskellNone
LanguageHaskell2010

Network.IRC.Fun.Bot.State

Description

This module provides access functions for working with the state stored within a bot session.

Synopsis

Documentation

askConfig :: Session e s Config Source

Fetch the bot configuration.

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.

getMinutes :: Session e s Int64 Source

Get the number of minutes since the epoch using an auto updating counter.

askEnv :: Session e s e Source

Fetch the bot environment, i.e. read-only state.

askEnvS :: (e -> a) -> Session e s a Source

Retrieve a function of the bot environment.

getState :: Session e s s Source

Fetch the current value of the state within the session.

getStateS :: (s -> a) -> Session e s a Source

Get a specific component of the state, using a projection function supplied.

putState :: s -> Session e s () Source

Set the state within the session.

modifyState :: (s -> s) -> Session e s () Source

Update the state to the result of applying a function to the current state.

getHistory :: Session e s (HashMap String (Seq HistoryLine)) Source

Get a mapping between channel names and sequences of their last messages.

getChanInfo :: Session e s (HashMap String ChanInfo) Source

Get channel state information, in the form of a mapping from channel names to their data.

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.