diff options
author | tv <tv@krebsco.de> | 2019-01-23 00:02:42 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-23 00:57:36 +0100 |
commit | d40815fd56bf1895af89b72b1171675a2e0ae5f7 (patch) | |
tree | 83b96a701f16b13915836c3a6c94463732a9f6d8 /src/Reaktor/Plugins/Mention.hs | |
parent | a00da57346c195b1b15d1c6aca2891483901aae6 (diff) |
src: use more simple functionsv0.1.0
Diffstat (limited to 'src/Reaktor/Plugins/Mention.hs')
-rw-r--r-- | src/Reaktor/Plugins/Mention.hs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/Reaktor/Plugins/Mention.hs b/src/Reaktor/Plugins/Mention.hs index 75de87c..379bd38 100644 --- a/src/Reaktor/Plugins/Mention.hs +++ b/src/Reaktor/Plugins/Mention.hs @@ -1,26 +1,22 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Reaktor.Plugins.Mention (plugin) where +{-# LANGUAGE RecordWildCards #-} +module Reaktor.Plugins.Mention (new) where -import Control.Monad (when) -import Data.Aeson +import Prelude.Extended import qualified Data.ByteString.Char8.Extended as BS import qualified Data.Char -import Reaktor.Internal -import Reaktor.Message +import Reaktor -plugin :: Value -> IO Plugin -plugin _ = return (Plugin run False) - - -run :: PluginFunc -run = \case - Message _ "PRIVMSG" (msgtarget:text:[]) -> do - nick <- getNick - when (isMention nick text) $ do - sendMsg (privmsg msgtarget ["I'm famous!"]) - _ -> return () +new :: Actions -> IO (Message -> IO ()) +new Actions{..} = do + pure $ \case + Message _ "PRIVMSG" (msgtarget:text:[]) -> do + nick <- aGetNick + when (isMention nick text) $ do + aSend (privmsg msgtarget ["I'm famous!"]) + _ -> return () where isMention nick text = not (BS.isPrefixOf (nick <> ":") text) && |