| Copyright | (c) 2020 Tom McLaughlin |
|---|---|
| License | MIT |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Web.Slack.ProgressBar
Contents
Description
This is a simple library for creating and updating Slack messages that contain progressbars. It can be used to display the progress of a long-running task in a Slack channel, for example as part of CI tooling.
main :: IO ()
main = do
let mySlackConfig = SlackConfig { slackApiToken = "my-slack-api-token" }
let progressBarInfo = def { progressBarInfoTopMessage = Just "Top message"
, progressBarInfoSize = Just 0 }
result <- runExceptT $ do
progressBar <- ExceptT $ createProgressBar mySlackConfig "test-channel" progressBarInfo
forM_ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] $ \size -> do
threadDelay 1000000
ExceptT $ updateProgressBar mySlackConfig progressBar (progressBarInfo { progressBarInfoSize = Just size })
putStrLn [i|Result: '#{result}'|]
Synopsis
- createProgressBar :: SlackConfig -> ChannelName -> ProgressBarInfo -> IO (Either Text ProgressBar)
- updateProgressBar :: SlackConfig -> ProgressBar -> ProgressBarInfo -> IO (Either Text ())
- data ProgressBarInfo = ProgressBarInfo {}
- data ProgressBarAttachment = ProgressBarAttachment {}
- data ProgressBar
- type ChannelName = Text
- newtype SlackConfig = SlackConfig {}
Documentation
createProgressBar :: SlackConfig -> ChannelName -> ProgressBarInfo -> IO (Either Text ProgressBar) Source #
Create a progress bar message on the given channel.
Returns a ProgressBar which can be used to update the message by calling updateProgressBar.
updateProgressBar :: SlackConfig -> ProgressBar -> ProgressBarInfo -> IO (Either Text ()) Source #
Update an existing progress bar.
data ProgressBarInfo Source #
The state of a progress bar message.
Constructors
| ProgressBarInfo | |
Fields
| |
data ProgressBarAttachment Source #
A Slack attachment.
Constructors
| ProgressBarAttachment | |
Fields
| |
Instances
| ToJSON ProgressBarAttachment Source # | |
Defined in Web.Slack.ProgressBar Methods toJSON :: ProgressBarAttachment -> Value # toEncoding :: ProgressBarAttachment -> Encoding # toJSONList :: [ProgressBarAttachment] -> Value # toEncodingList :: [ProgressBarAttachment] -> Encoding # | |
data ProgressBar Source #
An opaque type representing an existing Slack message.
type ChannelName = Text Source #
Re-exports
newtype SlackConfig Source #
Configuration options needed to connect to the Slack API
Constructors
| SlackConfig | |
Fields
| |
Instances
| Show SlackConfig Source # | |
Defined in Web.Slack.ProgressBar Methods showsPrec :: Int -> SlackConfig -> ShowS # show :: SlackConfig -> String # showList :: [SlackConfig] -> ShowS # | |