linklater-3.1.0.0: The fast and fun way to write Slack.com bots

Copyright(c) The Linklaterteers
LicenseBSD-style
Maintainerhi@haolian.org
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Network.Linklater

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.

Synopsis

Documentation

say :: Message -> Config -> IO (Response ByteString) Source

The say function posts a Message, with a capital M, to Slack. It'll, however, need a Config (a.k.a. incoming token) first.

slash :: (Maybe Command -> Application) -> Application Source

A bot server! As if by magic. This acts like a WAI middleware: Linklater wraps around your application. (Really, it just gives you a Command to work with instead of a raw HTTP request.)

slashSimple :: (Maybe Command -> IO Text) -> Application Source

A bot server for people who are in a hurry. Make a function that takes a Command and returns some Text in IO world, and we'll convert it into a WAI application. If you want more control over the request and respond, see slash.

data Channel Source

Where slash commands come from, and where Messages go.

Constructors

GroupChannel Text

A public or private group.

IMChannel Text

A private conversation with your best friend -- or lover ;).

newtype User Source

A username: no at-signs, just text!

Constructors

User Text 

Instances

data Message Source

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.

Instances

data Config Source

Like a curiosity about the world, you'll need one of these to say something.

Constructors

Config 

Fields

_configHookURL :: Text

This is the incoming web hook URL that Slack gave you. It's usually https://hooks.slack.com/services/....

data Command Source

Incoming HTTP requests to the slash function get parsed into one of these babies.

Constructors

Command 

Fields

_commandName :: Text

The command name.

_commandUser :: User

Who ran your slash command.

_commandChannel :: Channel

Where the person ran your slash command.

_commandText :: Maybe Text

Text for the slash command, if any.

newtype Icon Source

The icon next to the messages you say. (Images unsupported right now, sorry.)

Constructors

EmojiIcon Text

For example, ":stars2:".

Instances

data Format Source

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 &amp; that"