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

Safe HaskellNone
LanguageHaskell2010

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 () Source #

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 Source #

Constructors

Slack 

Fields

Instances

Monad (Slack s) Source # 

Methods

(>>=) :: Slack s a -> (a -> Slack s b) -> Slack s b #

(>>) :: Slack s a -> Slack s b -> Slack s b #

return :: a -> Slack s a #

fail :: String -> Slack s a #

Functor (Slack s) Source # 

Methods

fmap :: (a -> b) -> Slack s a -> Slack s b #

(<$) :: a -> Slack s b -> Slack s a #

Applicative (Slack s) Source # 

Methods

pure :: a -> Slack s a #

(<*>) :: Slack s (a -> b) -> Slack s a -> Slack s b #

(*>) :: Slack s a -> Slack s b -> Slack s b #

(<*) :: Slack s a -> Slack s b -> Slack s a #

MonadIO (Slack s) Source # 

Methods

liftIO :: IO a -> Slack s a #

MonadState (SlackState s) (Slack s) Source # 

Methods

get :: Slack s (SlackState s)

put :: SlackState s -> Slack s ()

state :: (SlackState s -> (a, SlackState s)) -> Slack s a

type SlackBot s = Event -> Slack s () Source #

data SlackState s Source #

Constructors

SlackState 

Fields

Instances

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

Methods

get :: Slack s (SlackState s)

put :: SlackState s -> Slack s ()

state :: (SlackState s -> (a, SlackState s)) -> Slack s a

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

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

data SlackConfig Source #

Configuration options needed to connect to the Slack API

Constructors

SlackConfig 

Fields