Safe Haskell | None |
---|
{-# LANGUAGE OverloadedStrings #-} module MyPlugins.HelloWorld (register) where import Network.Haskbot.Plugin name :: NameStr name = "hello_world" helpText :: HelpStr helpText = "Have Haskbot say _Hello, World!_ in your current channel." handler :: HandlerFn handler slashCom = return $ replySameChan slashCom "Hello, World!" register :: TokenStr -> Plugin register = newPlugin name helpText handler
To run the plugin, create a new Slack slash command integration
corresponding to the command /hello_world
that points to your Haskbot
server. Add the plugin's register
function to your Haskbot server's
plugin registry like detailed in Slack.Haskbot, giving it the Slack
integration's secret token as the remaining argument. Rebuild and run the
server. Typing /hello_word
into any Slack channel should return a
Haskbot response of Hellow, world!
- data Plugin
- plCommand :: Plugin -> Command
- plHelpText :: Plugin -> Text
- plHandler :: Plugin -> HandlerFn
- plToken :: Plugin -> Token
- type NameStr = Text
- type HelpStr = Text
- type HandlerFn = SlashCom -> Haskbot (Maybe Incoming)
- type TokenStr = Text
- newPlugin :: NameStr -> HelpStr -> HandlerFn -> TokenStr -> Plugin
- replySameChan :: SlashCom -> Text -> Maybe Incoming
- replyAsDM :: SlashCom -> Text -> Maybe Incoming
Plugins
PLugin components
plHelpText :: Plugin -> TextSource
Type aliases
Creating a new Plugin
:: NameStr | The text name of the plugin command |
-> HelpStr | Help text displayed in conjunction with the Slack.Haskbot.Plugin.Help plugin |
-> HandlerFn | A function that takes a Slack.Haskbot.SlashCommand
and potentially returns a |
-> TokenStr | The secret token of the Slack slash command integration associated with this plugin |
-> Plugin |
Create a new Plugin
from the components