| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.Linklater.Types
- type ChannelID = Text
- data Channel = Channel !ChannelID !Text
- newtype User = User 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
- data Message
- = SimpleMessage !Icon !Text !Channel !Text
- | FormattedMessage !Icon !Text !Channel ![Format]
- data Config = Config {
- _configHookURL :: !Text
- newtype APIToken = APIToken Text
- type Response = Response ByteString
- data RequestError = RequestError {}
- unformat :: Format -> Text
- commandOfParams :: Map Text Text -> Either String Command
- tryRequest :: (MonadIO m, MonadError RequestError m) => IO Response -> m Response
- promoteEither :: MonadError RequestError m => Response -> (l -> String) -> Either l r -> m r
- promoteMaybe :: MonadError RequestError m => Response -> String -> Maybe r -> m r
- asList :: [a] -> [a]
Documentation
type ChannelID = Text Source #
The unique 'C<number>' Slack assigns to each channel. Used to
say things.
Where slash commands come from and where Messages go.
A username: no at-signs, just text!
Constructors
| User Text |
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.)
Constructors
| EmojiIcon Text | For example, ":stars2:". |
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" |
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
| |
An API token, either a tester token or one obtained through OAuth.
See:
Constructors
| APIToken Text |
type Response = Response ByteString Source #
data RequestError Source #
Rather than throwing unchecked exceptions from our HTTP requests,
we catch all unchecked exceptions and convert them to checked
RequestError values.
Constructors
| RequestError | |
Fields
| |
Instances
tryRequest :: (MonadIO m, MonadError RequestError m) => IO Response -> m Response Source #
promoteEither :: MonadError RequestError m => Response -> (l -> String) -> Either l r -> m r Source #
promoteMaybe :: MonadError RequestError m => Response -> String -> Maybe r -> m r Source #