| Copyright | (c) The Linklaterteers |
|---|---|
| License | BSD-style |
| Maintainer | hi@haolian.org |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.Linklater
Contents
Description
Here's a /jpgto bot! If you run this program and then tell Slack
about your server (incoming hook and custom slash command) and then
type /jpgto baby corgi in one of your channels, you'll get the
image from http://baby.corgi.jpg.to.
https://github.com/hlian/linklater/blob/master/examples/JointPhotographicExpertsGroupTonga.hs
One /jpgto baby corgi, et voila.

- data Channel = Channel !ChannelID !Text
- newtype User = User Text
- data Message
- = SimpleMessage !Icon !Text !Channel !Text
- | FormattedMessage !Icon !Text !Channel ![Format]
- data Config = Config {
- _configHookURL :: !Text
- data Command = Command {
- _commandName :: !Text
- _commandUser :: !User
- _commandChannel :: !Channel
- _commandText :: !(Maybe Text)
- newtype Icon = EmojiIcon Text
- data Format
- = FormatAt !User
- | FormatUser !User !Text
- | FormatLink !Text !Text
- | FormatString !Text
- say :: (MonadError RequestError m, MonadIO m) => Message -> Config -> m ()
- startRTM :: (MonadError RequestError m, MonadIO m) => APIToken -> m URI
- startRTMWithOptions :: (MonadError RequestError m, MonadIO m) => Options -> m URI
- slash :: (Command -> Application) -> Application
- slashSimple :: (Command -> IO Text) -> Application
Types
Where slash commands come from and where Messages go.
A username: no at-signs, just text!
Here's how you talk: you make one of these and pass it to say.
Before the day is done, Linklater will convert this to a JSON blob
using Aeson.
- Simple messages are parsed by Slack with parse=full (i.e. as if you had typed it into the input box).
- Complex messages are parsed according to Slack formatting. See
Format.
Constructors
| SimpleMessage !Icon !Text !Channel !Text | |
| FormattedMessage !Icon !Text !Channel ![Format] |
Like a curiosity about the world, you'll need one of these to
say something.
Constructors
| Config | |
Fields
| |
Incoming HTTP requests to the slash function get parsed into one of these babies.
Constructors
| Command | |
Fields
| |
The icon next to the messages you say. (Images unsupported
right now, sorry.)
A little DSL for Slack formatting.
Constructors
| FormatAt !User | "<@user|user>" |
| FormatUser !User !Text | "<@user|user did this and that>" |
| FormatLink !Text !Text | "<http://example.com|user did this and that>" |
| FormatString !Text | "user did this & that" |
API calls
say :: (MonadError RequestError m, MonadIO m) => Message -> Config -> m () Source #
startRTM :: (MonadError RequestError m, MonadIO m) => APIToken -> m URI Source #
I GET a WebSocket URI from Slack's real-time messaging
endpoint. However, I need an APIToken (configured through Slack
administration) first.
Guaranted to not throw an unchecked exception.
startRTMWithOptions :: (MonadError RequestError m, MonadIO m) => Options -> m URI Source #
HTTP bot servers
slash :: (Command -> Application) -> Application Source #