diff options
author | tv <tv@krebsco.de> | 2019-01-13 23:52:05 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-21 02:12:00 +0100 |
commit | ce276eee82ec0b8c4106beb4c51d6f9eb77335c4 (patch) | |
tree | e41019c40471a45659fefba1671fa68395f062d6 /src/Reaktor/Plugins.hs | |
parent | dffc580ca255cd118a0dfcdae7a5bb67f4824dcc (diff) |
src: initv0.0.0
Diffstat (limited to 'src/Reaktor/Plugins.hs')
-rw-r--r-- | src/Reaktor/Plugins.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Reaktor/Plugins.hs b/src/Reaktor/Plugins.hs new file mode 100644 index 0000000..83677bb --- /dev/null +++ b/src/Reaktor/Plugins.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE OverloadedStrings #-} +module Reaktor.Plugins (get,registry) where + +import Data.Aeson (Value) +import qualified Data.Map as M +import qualified Data.Text as T +import qualified Reaktor.Plugins.Mention +import qualified Reaktor.Plugins.NickServ +import qualified Reaktor.Plugins.Ping +import qualified Reaktor.Plugins.Register +import qualified Reaktor.Plugins.System +import Reaktor.Types (Plugin) + + +get :: T.Text -> Value -> IO Plugin +get name = + case M.lookup name registry of + Just p -> p + Nothing -> error ("unknown plugin: " <> T.unpack name) + +registry :: M.Map T.Text (Value -> IO Plugin) +registry = M.fromList [ + ("mention", Reaktor.Plugins.Mention.plugin), + ("NickServ", Reaktor.Plugins.NickServ.plugin), + ("ping", Reaktor.Plugins.Ping.plugin), + ("register", Reaktor.Plugins.Register.plugin), + ("system", Reaktor.Plugins.System.plugin) + ] |