slack-api-0.7: Bindings to the Slack RTM API.

Safe HaskellNone
LanguageHaskell98

Web.Slack

Description

This module exposes functionality to write bots which responds to Events sent by the RTM API. By using the user state parameter s complicated interactions can be established.

This basic example echos every message the bot recieves. Other examples can be found in the examples directory.

myConfig :: SlackConfig
myConfig = SlackConfig
        { _slackApiToken = "..." -- Specify your API token here
        }

-- type SlackBot s = Event -> Slack s ()
echoBot :: SlackBot ()
echoBot (Message cid _ msg _ _ _) = sendMessage cid msg
echoBot _ = return ()

main :: IO ()
main = runBot myConfig echoBot ()

Synopsis

Documentation

runBot :: forall s. SlackConfig -> SlackBot s -> s -> IO ()

Run a SlackBot. The supplied bot will respond to all events sent by the Slack RTM API.

Be warned that this function will throw an IOError if the connection to the Slack API fails.

newtype Slack s a

Constructors

Slack 

Fields

runSlack :: StateT (SlackState s) IO a
 

Instances

Monad (Slack s) 
Functor (Slack s) 
Applicative (Slack s) 
MonadIO (Slack s) 
MonadState (SlackState s) (Slack s) 

type SlackBot s = Event -> Slack s ()

data SlackState s

Constructors

SlackState 

Fields

_meta :: Metainfo

Information about the connection

_session :: SlackSession

Information about the session at the start of the connection

_userState :: s

User defined state

_config :: SlackConfig

A copy of the initial configuration

Instances

Show s => Show (SlackState s) 
MonadState (SlackState s) (Slack s) 

userState :: forall s s. Lens (SlackState s) (SlackState s) s s

session :: forall s. Lens' (SlackState s) SlackSession