diff --git a/src/EuphApi/Utils/Botrulez.hs b/src/EuphApi/Utils/Botrulez.hs index 519c238..8f21cbd 100644 --- a/src/EuphApi/Utils/Botrulez.hs +++ b/src/EuphApi/Utils/Botrulez.hs @@ -45,21 +45,27 @@ generalPingCommand pingText = E.command "ping" $ \msg -> -- | Specific help command: @!help \@botname@ -- +-- The function passed as the first argument receives the bot's current nick as argument. +-- -- Bots should reply with a detailed help message. -- -- Bots __should implement__ this command. -helpCommand :: T.Text -> E.Command b c -helpCommand helpText = E.specificCommand "help" $ \msg -> - void $ E.reply (E.msgID msg) helpText +helpCommand :: (T.Text -> T.Text) -> E.Command b c +helpCommand f = E.specificCommand "help" $ \msg -> do + s <- E.sessName <$> E.getOwnView + void $ E.reply (E.msgID msg) (f s) -- | General version of 'helpCommand': @!help@ -- +-- The function passed as the first argument receives the bot's current nick as argument. +-- -- Bots should reply with a short description of their function. -- -- Bots __may implement__ this command. -generalHelpCommand :: T.Text -> E.Command b c -generalHelpCommand helpText = E.command "help" $ \msg -> - void $ E.reply (E.msgID msg) helpText +generalHelpCommand :: (T.Text -> T.Text) -> E.Command b c +generalHelpCommand f = E.command "help" $ \msg -> do + s <- E.sessName <$> E.getOwnView + void $ E.reply (E.msgID msg) (f s) uptime :: E.Message -> E.Bot b c () uptime msg = do diff --git a/test/bot_with_botrulez.hs b/test/bot_with_botrulez.hs index 3d8454e..a78b4a9 100644 --- a/test/bot_with_botrulez.hs +++ b/test/bot_with_botrulez.hs @@ -23,12 +23,12 @@ myCommands :: [Command] myCommands = [ E.pingCommand "Pong!" , E.generalPingCommand "Pong!" - , E.helpCommand "Some specific placeholder help" - , E.generalHelpCommand "I help test @Garmy's EuphApi" + , E.helpCommand (\n -> "Some specific placeholder help for " <> E.atMention n <> ".") + , E.generalHelpCommand (const "I help test @Garmy's EuphApi.") , E.uptimeCommand , E.generalUptimeCommand -- most bots don't do this , E.killCommand "Bye!" - , E.restartCommand "brb" + , E.restartCommand "brb." ] myBotHandler :: E.EventType -> Bot ()