aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin/Base.hs
blob: d4194eeff64f877e0273a09b64feb33351725b8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{-# LANGUAGE OverloadedStrings #-}

module Plugin.Base
    ( PluginAction

    , Plugin(..)
    , defaultPlugin
    ) where

import qualified Data.Text as T

import Database.SQLite.Simple

import Message

type PluginAction = Message -> IO (Either T.Text T.Text)

data Plugin = Plugin
    { matchRegex  :: String
    , perform     :: PluginAction
    , command     :: T.Text
    , description :: T.Text
    , queryOnly   :: Bool
    }

instance Show Plugin where
    show (Plugin r _ _ _ _) = "matchRegex = " ++ r

defaultPlugin :: Plugin
defaultPlugin = Plugin
    { matchRegex  = ""
    , perform     = \m -> return (Left "")
    , command     = ""
    , description = ""
    , queryOnly   = False
    }