haskbot-core-0.0.1.0: Easily-extensible chatbot for Slack messaging service

Safe HaskellNone

Network.Haskbot.Plugin

Contents

Description

 {-# 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!

Synopsis

Plugins

PLugin components

Type aliases

Creating a new Plugin

newPluginSource

Arguments

:: 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 Incoming

-> TokenStr

The secret token of the Slack slash command integration associated with this plugin

-> Plugin 

Create a new Plugin from the components

Slack replies

replySameChan :: SlashCom -> Text -> Maybe IncomingSource

Send a Slack reply to the same channel as where the corresponding /slash command/ was invoked, formatted according to Slack

replyAsDM :: SlashCom -> Text -> Maybe IncomingSource

Send a Slack reply as a DM to the user who invoked the slash command, formatted according to Slack