From 02487f0d608be44350b6df631df0a695de64b568 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 20 Feb 2018 06:43:52 +0000 Subject: [PATCH] Make ping command customizable --- src/EuphApi/Utils/Botrulez.hs | 12 ++++++------ test/bot_with_botrulez.hs | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/EuphApi/Utils/Botrulez.hs b/src/EuphApi/Utils/Botrulez.hs index 91843ad..f4542a2 100644 --- a/src/EuphApi/Utils/Botrulez.hs +++ b/src/EuphApi/Utils/Botrulez.hs @@ -20,13 +20,13 @@ import qualified EuphApi.Bot as B import qualified EuphApi.Types as E import qualified EuphApi.Utils as E -pingCommand :: E.Command b c -pingCommand = E.specificCommand "ping" $ \msg -> - void $ B.reply (E.msgID msg) "Pong!" +pingCommand :: T.Text -> E.Command b c +pingCommand pingText = E.specificCommand "ping" $ \msg -> + void $ B.reply (E.msgID msg) pingText -generalPingCommand :: E.Command b c -generalPingCommand = E.command "ping" $ \msg -> - void $ B.reply (E.msgID msg) "Pong!" +generalPingCommand :: T.Text -> E.Command b c +generalPingCommand pingText = E.command "ping" $ \msg -> + void $ B.reply (E.msgID msg) pingText helpCommand :: T.Text -> E.Command b c helpCommand helpText = E.specificCommand "help" $ \msg -> diff --git a/test/bot_with_botrulez.hs b/test/bot_with_botrulez.hs index 75311f3..4b9d1ef 100644 --- a/test/bot_with_botrulez.hs +++ b/test/bot_with_botrulez.hs @@ -17,15 +17,16 @@ import qualified EuphApi.Utils.Botrulez as E myCommands :: [E.Command b c] myCommands = - [ E.pingCommand - , E.generalPingCommand + [ E.pingCommand "Pong!" + , E.generalPingCommand "Pong!" , E.helpCommand "Some specific placeholder help" , E.generalHelpCommand "I help test @Garmy's EuphApi" , E.uptimeCommand - , E.generalUptimeCommand + , E.generalUptimeCommand -- most bots don't do this , E.command "whatsmynick" (\msg -> do nick <- E.sessName <$> B.getOwnView - let content = nick <> "\n" <> E.mention nick <> "\n" <> E.atMention nick <> "\n" <> E.mentionReduce nick + let content = nick <> "\n" <> E.mention nick <> "\n" <> E.atMention nick + <> "\n" <> E.mentionReduce nick void $ B.reply (E.msgID msg) content ) ]