lambdabot-core-5.3.1.2: Lambdabot core functionality

Safe Haskell | None
Language | Haskell98

Lambdabot.Plugin

Synopsis

- data Module st = Module {
  - moduleSerialize :: !(Maybe (Serial st))
  - moduleDefState :: !(LB st)
  - moduleSticky :: !Bool
  - moduleCmds :: !(ModuleT st LB [Command (ModuleT st LB)])
  - moduleInit :: !(ModuleT st LB ())
  - moduleExit :: !(ModuleT st LB ())
  - contextual :: !(String -> Cmd (ModuleT st LB) ())
  }
- data ModuleT st (m :: Type -> Type) a
- newModule :: Module st
- data LB a
- class (MonadIO m, MonadBaseControl IO m, MonadConfig m, MonadLogging m, Applicative m, MonadFail m) => MonadLB (m :: Type -> Type) where
  - lb :: LB a -> m a
- lim80 :: Monad m => m String -> Cmd m ()
- ios80 :: forall (m :: Type -> Type). MonadIO m => IO String -> Cmd m ()
- data ChanName
- mkCN :: Nick -> ChanName
- getCN :: ChanName -> Nick
- data Nick = Nick {
  - nTag :: !String
  - nName :: !String
  }
- ircPrivmsg :: Nick -> String -> LB ()
- module Lambdabot.Config
- outputDir :: Config FilePath
- commandPrefixes :: Config [String]
- disabledCommands :: Config [String]
- editDistanceLimit :: Config Int
- enableInsults :: Config Bool
- onStartupCmds :: Config [String]
- dataDir :: Config FilePath
- lbVersion :: Config Version
- textWidth :: Config Int
- uncaughtExceptionHandler :: Config DIH
- replaceRootLogger :: Config Bool
- lbRootLoggerPath :: Config [String]
- consoleLogHandle :: Config Handle
- consoleLogLevel :: Config Priority
- consoleLogFormat :: Config String
- data Command (m :: Type -> Type) = Command {
  - cmdName :: String
  - aliases :: [String]
  - privileged :: Bool
  - help :: Cmd m ()
  - process :: String -> Cmd m ()
  }
- cmdNames :: forall (m :: Type -> Type). Command m -> [String]
- command :: String -> Command Identity
- data Cmd (m :: Type -> Type) a
- getCmdName :: forall (m :: Type -> Type). Monad m => Cmd m String
- withMsg :: forall (m :: Type -> Type) t. Monad m => (forall a. Message a => a -> Cmd m t) -> Cmd m t
- readNick :: forall (m :: Type -> Type). Monad m => String -> Cmd m Nick
- showNick :: forall (m :: Type -> Type). Monad m => Nick -> Cmd m String
- getServer :: forall (m :: Type -> Type). Monad m => Cmd m String
- getSender :: forall (m :: Type -> Type). Monad m => Cmd m Nick
- getTarget :: forall (m :: Type -> Type). Monad m => Cmd m Nick
- getLambdabotName :: forall (m :: Type -> Type). Monad m => Cmd m Nick
- say :: forall (m :: Type -> Type). Monad m => String -> Cmd m ()
- module Lambdabot.State
- module Lambdabot.File
- data Serial s = Serial {
  - serialize :: s -> Maybe ByteString
  - deserialize :: ByteString -> Maybe s
  }
- stdSerial :: (Show s, Read s) => Serial s
- mapSerial :: (Ord k, Show k, Show v, Read k, Read v) => Serial (Map k v)
- mapPackedSerial :: Serial (Map ByteString ByteString)
- assocListPackedSerial :: Serial [(ByteString, ByteString)]
- mapListPackedSerial :: Serial (Map ByteString [ByteString])
- readM :: (MonadFail m, Read a) => String -> m a
- class Packable t where
  - readPacked :: ByteString -> t
  - showPacked :: t -> ByteString
- readOnly :: (ByteString -> b) -> Serial b

# Documentation

data Module st Source #

The Module type class.

Constructors

Module |

Fields

- moduleSerialize :: !(Maybe (Serial st))

  If the module wants its state to be saved, this function should return a Serial.

  The default implementation returns Nothing.

- moduleDefState :: !(LB st)

  If the module maintains state, this method specifies the default state (for example in case the state can't be read from a state).

  The default implementation returns an error and assumes the state is never accessed.

- moduleSticky :: !Bool

  Is the module sticky? Sticky modules (as well as static ones) can't be unloaded. By default, modules are not sticky.

- moduleCmds :: !(ModuleT st LB [Command (ModuleT st LB)])

  The commands the module listens to.

- moduleInit :: !(ModuleT st LB ())

  Initialize the module. The default implementation does nothing.

- moduleExit :: !(ModuleT st LB ())

  Finalize the module. The default implementation does nothing.

- contextual :: !(String -> Cmd (ModuleT st LB) ())

  Process contextual input. A plugin that implements `contextual` is able to respond to text not part of a normal command.

data ModuleT st (m :: Type -> Type) a Source #

This transformer encodes the additional information a module might need to access its name or its state.

#### Instances

Instances details

MonadBaseControl b m => MonadBaseControl b (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftBaseWith :: (RunInBase (ModuleT st m) b -> b a) -> ModuleT st m a Source # restoreM :: StM (ModuleT st m) a -> ModuleT st m a Source #
MonadBase b m => MonadBase b (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftBase :: b α -> ModuleT st m α Source #
MonadTransControl (ModuleT st) Source # |
Instance details Defined in Lambdabot.Module Methods liftWith :: Monad m => (Run (ModuleT st) -> m a) -> ModuleT st m a Source # restoreT :: Monad m => m (StT (ModuleT st) a) -> ModuleT st m a Source #
MonadTrans (ModuleT st) Source # |
Instance details Defined in Lambdabot.Module Methods lift :: Monad m => m a -> ModuleT st m a Source #
Monad m => MonadReader (ModuleInfo st) (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods ask :: ModuleT st m (ModuleInfo st) Source # local :: (ModuleInfo st -> ModuleInfo st) -> ModuleT st m a -> ModuleT st m a Source # reader :: (ModuleInfo st -> a) -> ModuleT st m a Source #
MonadIO m => MonadIO (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftIO :: IO a -> ModuleT st m a Source #
MonadCatch m => MonadCatch (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods catch :: (HasCallStack, Exception e) => ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a Source #
MonadMask m => MonadMask (ModuleT st m) Source # |

Instance details

Defined in Lambdabot.Module

Methods

mask :: HasCallStack => ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b) -> ModuleT st m b Source #

uninterruptibleMask :: HasCallStack => ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b) -> ModuleT st m b Source #

generalBracket :: HasCallStack => ModuleT st m a -> (a -> ExitCase b -> ModuleT st m c) -> (a -> ModuleT st m b) -> ModuleT st m (b, c) Source #

MonadThrow m => MonadThrow (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods throwM :: (HasCallStack, Exception e) => e -> ModuleT st m a Source #
Applicative m => Applicative (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods pure :: a -> ModuleT st m a Source # (<*>) :: ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b Source # liftA2 :: (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c Source # (*>) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m b Source # (<*) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m a Source #
Functor m => Functor (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods fmap :: (a -> b) -> ModuleT st m a -> ModuleT st m b Source # (<$) :: a -> ModuleT st m b -> ModuleT st m a Source #
Monad m => Monad (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods (>>=) :: ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b Source # (>>) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m b Source # return :: a -> ModuleT st m a Source #
MonadFail m => MonadFail (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods fail :: String -> ModuleT st m a Source #
MonadConfig m => MonadConfig (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods getConfig :: Config a -> ModuleT st m a Source #
MonadLogging m => MonadLogging (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods getCurrentLogger :: ModuleT st m [String] Source # logM :: String -> Priority -> String -> ModuleT st m () Source #
MonadLB m => MonadLB (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> ModuleT st m a Source #
MonadLB m => MonadLBState (ModuleT st m) Source # |

Instance details

Defined in Lambdabot.State

Associated Types

type LBState (ModuleT st m) |
Instance details Defined in Lambdabot.State type LBState (ModuleT st m) = st

Methods

withMS :: (LBState (ModuleT st m) -> (LBState (ModuleT st m) -> ModuleT st m ()) -> ModuleT st m a) -> ModuleT st m a Source #

type StT (ModuleT st) a Source # |
Instance details Defined in Lambdabot.Module type StT (ModuleT st) a = a
type LBState (ModuleT st m) Source # |
Instance details Defined in Lambdabot.State type LBState (ModuleT st m) = st
type StM (ModuleT st m) a Source # |
Instance details Defined in Lambdabot.Module type StM (ModuleT st m) a = ComposeSt (ModuleT st) m a

newModule :: Module st Source #

data LB a Source #

The IRC Monad. The reader transformer holds information about the connection to the IRC server.

instances Monad, Functor, MonadIO, MonadState, MonadError

#### Instances

Instances details

MonadIO LB Source # |
Instance details Defined in Lambdabot.Monad Methods liftIO :: IO a -> LB a Source #
MonadCatch LB Source # |
Instance details Defined in Lambdabot.Monad Methods catch :: (HasCallStack, Exception e) => LB a -> (e -> LB a) -> LB a Source #
MonadMask LB Source # |
Instance details Defined in Lambdabot.Monad Methods mask :: HasCallStack => ((forall a. LB a -> LB a) -> LB b) -> LB b Source # uninterruptibleMask :: HasCallStack => ((forall a. LB a -> LB a) -> LB b) -> LB b Source # generalBracket :: HasCallStack => LB a -> (a -> ExitCase b -> LB c) -> (a -> LB b) -> LB (b, c) Source #
MonadThrow LB Source # |
Instance details Defined in Lambdabot.Monad Methods throwM :: (HasCallStack, Exception e) => e -> LB a Source #
Applicative LB Source # |
Instance details Defined in Lambdabot.Monad Methods pure :: a -> LB a Source # (<*>) :: LB (a -> b) -> LB a -> LB b Source # liftA2 :: (a -> b -> c) -> LB a -> LB b -> LB c Source # (*>) :: LB a -> LB b -> LB b Source # (<*) :: LB a -> LB b -> LB a Source #
Functor LB Source # |
Instance details Defined in Lambdabot.Monad Methods fmap :: (a -> b) -> LB a -> LB b Source # (<$) :: a -> LB b -> LB a Source #
Monad LB Source # |
Instance details Defined in Lambdabot.Monad Methods (>>=) :: LB a -> (a -> LB b) -> LB b Source # (>>) :: LB a -> LB b -> LB b Source # return :: a -> LB a Source #
MonadFail LB Source # |
Instance details Defined in Lambdabot.Monad Methods fail :: String -> LB a Source #
MonadConfig LB Source # |
Instance details Defined in Lambdabot.Monad Methods getConfig :: Config a -> LB a Source #
MonadLogging LB Source # |
Instance details Defined in Lambdabot.Monad Methods getCurrentLogger :: LB [String] Source # logM :: String -> Priority -> String -> LB () Source #
MonadLB LB Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> LB a Source #
MonadBaseControl IO LB Source # |

Instance details

Defined in Lambdabot.Monad

Associated Types

type StM LB a |
Instance details Defined in Lambdabot.Monad type StM LB a = StM (ReaderT (IRCRState, IORef IRCRWState) IO) a

Methods

liftBaseWith :: (RunInBase LB IO -> IO a) -> LB a Source #

restoreM :: StM LB a -> LB a Source #

MonadState IRCRWState LB Source # |
Instance details Defined in Lambdabot.Monad Methods get :: LB IRCRWState Source # put :: IRCRWState -> LB () Source # state :: (IRCRWState -> (a, IRCRWState)) -> LB a Source #
MonadBase IO LB Source # |
Instance details Defined in Lambdabot.Monad Methods liftBase :: IO α -> LB α Source #
type StM LB a Source # |
Instance details Defined in Lambdabot.Monad type StM LB a = StM (ReaderT (IRCRState, IORef IRCRWState) IO) a

class (MonadIO m, MonadBaseControl IO m, MonadConfig m, MonadLogging m, Applicative m, MonadFail m) => MonadLB (m :: Type -> Type) where Source #

Methods

lb :: LB a -> m a Source #

#### Instances

Instances details

MonadLB LB Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> LB a Source #
MonadLB m => MonadLB (Cmd m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> Cmd m a Source #
MonadLB m => MonadLB (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> ModuleT st m a Source #

lim80 :: Monad m => m String -> Cmd m () Source #

ios80 :: forall (m :: Type -> Type). MonadIO m => IO String -> Cmd m () Source #

convenience, similar to ios but also cut output to channel to 80 characters usage: `process _ _ to _ s = ios80 to (plugs s)`

data ChanName Source #

#### Instances

Instances details

Eq ChanName Source # |
Instance details Defined in Lambdabot.ChanName Methods (==) :: ChanName -> ChanName -> Bool Source # (/=) :: ChanName -> ChanName -> Bool Source #
Ord ChanName Source # |
Instance details Defined in Lambdabot.ChanName Methods compare :: ChanName -> ChanName -> Ordering Source # (<) :: ChanName -> ChanName -> Bool Source # (<=) :: ChanName -> ChanName -> Bool Source # (>) :: ChanName -> ChanName -> Bool Source # (>=) :: ChanName -> ChanName -> Bool Source # max :: ChanName -> ChanName -> ChanName Source # min :: ChanName -> ChanName -> ChanName Source #

mkCN :: Nick -> ChanName Source #

getCN :: ChanName -> Nick Source #

data Nick Source #

The type of nicknames isolated from a message.

Constructors

Nick |

Fields

- nTag :: !String

  The tag of the server this nick is on

- nName :: !String

  The server-specific nickname of this nick

#### Instances

Instances details

Eq Nick Source # |
Instance details Defined in Lambdabot.Nick Methods (==) :: Nick -> Nick -> Bool Source # (/=) :: Nick -> Nick -> Bool Source #
Ord Nick Source # |
Instance details Defined in Lambdabot.Nick Methods compare :: Nick -> Nick -> Ordering Source # (<) :: Nick -> Nick -> Bool Source # (<=) :: Nick -> Nick -> Bool Source # (>) :: Nick -> Nick -> Bool Source # (>=) :: Nick -> Nick -> Bool Source # max :: Nick -> Nick -> Nick Source # min :: Nick -> Nick -> Nick Source #

ircPrivmsg Source #

Arguments

:: Nick | The channel/user.
-> String | The message.
-> LB () |

Send a message to a channel/user, applying all output filters

module Lambdabot.Config

outputDir :: Config FilePath Source #

commandPrefixes :: Config [String] Source #

disabledCommands :: Config [String] Source #

editDistanceLimit :: Config Int Source #

enableInsults :: Config Bool Source #

onStartupCmds :: Config [String] Source #

dataDir :: Config FilePath Source #

lbVersion :: Config Version Source #

textWidth :: Config Int Source #

uncaughtExceptionHandler :: Config DIH Source #

replaceRootLogger :: Config Bool Source #

lbRootLoggerPath :: Config [String] Source #

consoleLogHandle :: Config Handle Source #

consoleLogLevel :: Config Priority Source #

consoleLogFormat :: Config String Source #

data Command (m :: Type -> Type) Source #

Constructors

Command |

Fields

- cmdName :: String
- aliases :: [String]
- privileged :: Bool
- help :: Cmd m ()
- process :: String -> Cmd m ()

cmdNames :: forall (m :: Type -> Type). Command m -> [String] Source #

command :: String -> Command Identity Source #

data Cmd (m :: Type -> Type) a Source #

#### Instances

Instances details

MonadTransControl Cmd Source # |

Instance details

Defined in Lambdabot.Command

Associated Types

type StT Cmd a |
Instance details Defined in Lambdabot.Command type StT Cmd a = (a, [String])

Methods

liftWith :: Monad m => (Run Cmd -> m a) -> Cmd m a Source #

restoreT :: Monad m => m (StT Cmd a) -> Cmd m a Source #

MonadTrans Cmd Source # |
Instance details Defined in Lambdabot.Command Methods lift :: Monad m => m a -> Cmd m a Source #
MonadBaseControl b m => MonadBaseControl b (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods liftBaseWith :: (RunInBase (Cmd m) b -> b a) -> Cmd m a Source # restoreM :: StM (Cmd m) a -> Cmd m a Source #
MonadBase b m => MonadBase b (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods liftBase :: b α -> Cmd m α Source #
MonadIO m => MonadIO (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods liftIO :: IO a -> Cmd m a Source #
Applicative f => Applicative (Cmd f) Source # |
Instance details Defined in Lambdabot.Command Methods pure :: a -> Cmd f a Source # (<*>) :: Cmd f (a -> b) -> Cmd f a -> Cmd f b Source # liftA2 :: (a -> b -> c) -> Cmd f a -> Cmd f b -> Cmd f c Source # (*>) :: Cmd f a -> Cmd f b -> Cmd f b Source # (<*) :: Cmd f a -> Cmd f b -> Cmd f a Source #
Functor f => Functor (Cmd f) Source # |
Instance details Defined in Lambdabot.Command Methods fmap :: (a -> b) -> Cmd f a -> Cmd f b Source # (<$) :: a -> Cmd f b -> Cmd f a Source #
Monad m => Monad (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods (>>=) :: Cmd m a -> (a -> Cmd m b) -> Cmd m b Source # (>>) :: Cmd m a -> Cmd m b -> Cmd m b Source # return :: a -> Cmd m a Source #
MonadFail m => MonadFail (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods fail :: String -> Cmd m a Source #
MonadConfig m => MonadConfig (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods getConfig :: Config a -> Cmd m a Source #
MonadLogging m => MonadLogging (Cmd m) Source # |
Instance details Defined in Lambdabot.Command Methods getCurrentLogger :: Cmd m [String] Source # logM :: String -> Priority -> String -> Cmd m () Source #
MonadLB m => MonadLB (Cmd m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> Cmd m a Source #
MonadLBState m => MonadLBState (Cmd m) Source # |

Instance details

Defined in Lambdabot.State

Associated Types

type LBState (Cmd m) |
Instance details Defined in Lambdabot.State type LBState (Cmd m) = LBState m

Methods

withMS :: (LBState (Cmd m) -> (LBState (Cmd m) -> Cmd m ()) -> Cmd m a) -> Cmd m a Source #

type StT Cmd a Source # |
Instance details Defined in Lambdabot.Command type StT Cmd a = (a, [String])
type LBState (Cmd m) Source # |
Instance details Defined in Lambdabot.State type LBState (Cmd m) = LBState m
type StM (Cmd m) a Source # |
Instance details Defined in Lambdabot.Command type StM (Cmd m) a = ComposeSt Cmd m a

getCmdName :: forall (m :: Type -> Type). Monad m => Cmd m String Source #

withMsg :: forall (m :: Type -> Type) t. Monad m => (forall a. Message a => a -> Cmd m t) -> Cmd m t Source #

readNick :: forall (m :: Type -> Type). Monad m => String -> Cmd m Nick Source #

showNick :: forall (m :: Type -> Type). Monad m => Nick -> Cmd m String Source #

getServer :: forall (m :: Type -> Type). Monad m => Cmd m String Source #

getSender :: forall (m :: Type -> Type). Monad m => Cmd m Nick Source #

getTarget :: forall (m :: Type -> Type). Monad m => Cmd m Nick Source #

getLambdabotName :: forall (m :: Type -> Type). Monad m => Cmd m Nick Source #

say :: forall (m :: Type -> Type). Monad m => String -> Cmd m () Source #

module Lambdabot.State

module Lambdabot.File

data Serial s Source #

Constructors

Serial |

Fields

- serialize :: s -> Maybe ByteString
- deserialize :: ByteString -> Maybe s

stdSerial :: (Show s, Read s) => Serial s Source #

Default `instance' for a Serial

mapSerial :: (Ord k, Show k, Show v, Read k, Read v) => Serial (Map k v) Source #

Serializes a `Map` type if both the key and the value are instances of Read and Show. The serialization is done by converting the map to and from lists. Results are saved line-wise, for better editing and revision control.

mapPackedSerial :: Serial (Map ByteString ByteString) Source #

assocListPackedSerial :: Serial [(ByteString, ByteString)] Source #

mapListPackedSerial :: Serial (Map ByteString [ByteString]) Source #

readM :: (MonadFail m, Read a) => String -> m a Source #

`readM` behaves like read, but catches failure in a monad. this allocates a 20-30 M on startup...

class Packable t where Source #

Methods

readPacked :: ByteString -> t Source #

showPacked :: t -> ByteString Source #

#### Instances

Instances details

Packable [(ByteString, ByteString)] Source # |
Instance details Defined in Lambdabot.Util.Serial Methods readPacked :: ByteString -> [(ByteString, ByteString)] Source # showPacked :: [(ByteString, ByteString)] -> ByteString Source #
Packable (Map ByteString ByteString) Source # |
Instance details Defined in Lambdabot.Util.Serial Methods readPacked :: ByteString -> Map ByteString ByteString Source # showPacked :: Map ByteString ByteString -> ByteString Source #
Packable (Map ByteString (Bool, [(ByteString, Int)])) Source # |
Instance details Defined in Lambdabot.Util.Serial Methods readPacked :: ByteString -> Map ByteString (Bool, [(ByteString, Int)]) Source # showPacked :: Map ByteString (Bool, [(ByteString, Int)]) -> ByteString Source #
Packable (Map ByteString [ByteString]) Source # | An instance for Map Packed [Packed] uses gzip compression
Instance details Defined in Lambdabot.Util.Serial Methods readPacked :: ByteString -> Map ByteString [ByteString] Source # showPacked :: Map ByteString [ByteString] -> ByteString Source #

readOnly :: (ByteString -> b) -> Serial b Source #