From d40815fd56bf1895af89b72b1171675a2e0ae5f7 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 23 Jan 2019 00:02:42 +0100 Subject: src: use more simple functions --- src/Reaktor/Plugins/Ping.hs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/Reaktor/Plugins/Ping.hs') diff --git a/src/Reaktor/Plugins/Ping.hs b/src/Reaktor/Plugins/Ping.hs index de3fe53..436ebe2 100644 --- a/src/Reaktor/Plugins/Ping.hs +++ b/src/Reaktor/Plugins/Ping.hs @@ -1,15 +1,15 @@ +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Reaktor.Plugins.Ping (plugin) where - -import Control.Monad (when) -import Data.Aeson (Value(Null)) -import Reaktor.Internal - - -plugin :: Value -> IO Plugin -plugin = simplePlugin (\Null -> run) - -run :: PluginFunc -run (Message _ ircCommand args) = - when (ircCommand == "PING") $ - sendMsg (Message Nothing "PONG" args) +{-# LANGUAGE RecordWildCards #-} +module Reaktor.Plugins.Ping where + +import Prelude.Extended +import Reaktor + +new :: Actions -> IO (Message -> IO ()) +new Actions{..} = + return $ \case + Message _ cmd args -> + when (cmd == "PING") $ + aSend (Message Nothing "PONG" args) + _ -> pure () -- cgit v1.2.3