Add botrulez documentation
This commit is contained in:
parent
2d9491d2fb
commit
0e0596765e
2 changed files with 23 additions and 3 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
-- | This module implements a few commands defined in the
|
||||||
|
-- [botrulez](https://github.com/jedevc/botrulez). If you need more advanced
|
||||||
|
-- behaviour, it should be pretty easy to reimplement the commands as necessary.
|
||||||
|
|
||||||
module Haboli.Euphoria.Botrulez
|
module Haboli.Euphoria.Botrulez
|
||||||
( botrulezPingGeneral
|
( botrulezPingGeneral
|
||||||
, botrulezPingSpecific
|
, botrulezPingSpecific
|
||||||
|
|
@ -20,22 +24,32 @@ import Haboli.Euphoria.Command
|
||||||
import Haboli.Euphoria.Command.Simple
|
import Haboli.Euphoria.Command.Simple
|
||||||
import Haboli.Euphoria.Util
|
import Haboli.Euphoria.Util
|
||||||
|
|
||||||
|
-- | @'botrulezPingGeneral'@ replies to commands of the form @!ping@ with
|
||||||
|
-- @Pong!@.
|
||||||
botrulezPingGeneral :: Command e
|
botrulezPingGeneral :: Command e
|
||||||
botrulezPingGeneral = cmdGeneral "ping" $ \msg ->
|
botrulezPingGeneral = cmdGeneral "ping" $ \msg ->
|
||||||
void $ reply msg "Pong!"
|
void $ reply msg "Pong!"
|
||||||
|
|
||||||
|
-- | @'botrulezPingSpecific' nick@ replies to commands of the form @!ping
|
||||||
|
-- \@nick@ with @Pong!@.
|
||||||
botrulezPingSpecific :: T.Text -> Command e
|
botrulezPingSpecific :: T.Text -> Command e
|
||||||
botrulezPingSpecific name = cmdSpecific "ping" name $ \msg ->
|
botrulezPingSpecific name = cmdSpecific "ping" name $ \msg ->
|
||||||
void $ reply msg "Pong!"
|
void $ reply msg "Pong!"
|
||||||
|
|
||||||
|
-- | @'botrulezHelpGeneral' helpText@ replies to commands of the form @!help@
|
||||||
|
-- with @helpText@.
|
||||||
botrulezHelpGeneral :: T.Text -> Command e
|
botrulezHelpGeneral :: T.Text -> Command e
|
||||||
botrulezHelpGeneral help = cmdGeneral "help" $ \msg ->
|
botrulezHelpGeneral help = cmdGeneral "help" $ \msg ->
|
||||||
void $ reply msg help
|
void $ reply msg help
|
||||||
|
|
||||||
|
-- | @'botrulezHelpSpecific' nick helpText@ replies to commands of the form
|
||||||
|
-- @!help \@nick@ with @helpText@.
|
||||||
botrulezHelpSpecific :: T.Text -> T.Text -> Command e
|
botrulezHelpSpecific :: T.Text -> T.Text -> Command e
|
||||||
botrulezHelpSpecific name help = cmdSpecific "help" name $ \msg ->
|
botrulezHelpSpecific name help = cmdSpecific "help" name $ \msg ->
|
||||||
void $ reply msg help
|
void $ reply msg help
|
||||||
|
|
||||||
|
-- | @'botrulezUptimeSpecific' nick startTime@ replies to commands of the form
|
||||||
|
-- @!uptime \@nick@ with the time since @startTime@.
|
||||||
botrulezUptimeSpecific :: T.Text -> UTCTime -> Command e
|
botrulezUptimeSpecific :: T.Text -> UTCTime -> Command e
|
||||||
botrulezUptimeSpecific name since = cmdSpecific "uptime" name $ \msg -> do
|
botrulezUptimeSpecific name since = cmdSpecific "uptime" name $ \msg -> do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
|
|
@ -48,6 +62,8 @@ botrulezUptimeSpecific name since = cmdSpecific "uptime" name $ \msg -> do
|
||||||
, ")"
|
, ")"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | @'botrulezKillSpecific' nick@ replies to commands of the form @!kill
|
||||||
|
-- \@nick@ with @/me dies@. It then throws an exception.
|
||||||
botrulezKillSpecific :: T.Text -> Command T.Text
|
botrulezKillSpecific :: T.Text -> Command T.Text
|
||||||
botrulezKillSpecific name = cmdSpecific "kill" name $ \msg -> do
|
botrulezKillSpecific name = cmdSpecific "kill" name $ \msg -> do
|
||||||
void $ reply msg "/me dies"
|
void $ reply msg "/me dies"
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,17 @@ runCommands (c:cs) msg = do
|
||||||
then pure True
|
then pure True
|
||||||
else runCommands cs msg
|
else runCommands cs msg
|
||||||
|
|
||||||
-- | Run a list of 'Command's on all 'EventSend's. Passes through all events
|
-- | @'respondingToCommands' getEvent getCommands@ runs a list of 'Command's on
|
||||||
-- unmodified.
|
-- all 'EventSend's. It passes through all events unmodified.
|
||||||
|
--
|
||||||
|
-- The @getEvent@ action is used to obtain the next 'Event'. The @getCommands@
|
||||||
|
-- action is used to obtain the currently available commands. @getCommands@ is
|
||||||
|
-- called directly after a new 'Event' becomes available through @getEvent@.
|
||||||
--
|
--
|
||||||
-- This utility function is meant to be wrapped directly or indirectly around
|
-- This utility function is meant to be wrapped directly or indirectly around
|
||||||
-- 'nextEvent':
|
-- 'nextEvent':
|
||||||
--
|
--
|
||||||
-- > event <- respondingToCommands commands nextEvent
|
-- > event <- respondingToCommands nextEvent commands
|
||||||
respondingToCommands :: Client e Event -> Client e [Command e] -> Client e Event
|
respondingToCommands :: Client e Event -> Client e [Command e] -> Client e Event
|
||||||
respondingToCommands getEvent getCommands = do
|
respondingToCommands getEvent getCommands = do
|
||||||
event <- getEvent
|
event <- getEvent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue