Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- lambdabotVersion :: String
- telegramPlugins :: [String]
- telegramPlugin :: Module TelegramState
- customHaskellPlugins :: [String]
- newTelegramState :: LB TelegramState
- feed :: Text -> Text -> Text -> Telegram ()
- handleMsg :: IrcMessage -> Telegram ()
- lockRC :: Telegram ()
- unlockRC :: Telegram ()
- args :: String -> String -> [String] -> [String] -> [String]
- isEval :: MonadLB m => String -> m Bool
- dropPrefix :: String -> String
- runGHC :: MonadLB m => String -> m String
- define :: MonadLB m => String -> m String
- mergeModules :: Module -> Module -> Module
- moduleProblems :: Module -> Maybe [Char]
- moveFile :: FilePath -> FilePath -> IO ()
- customComp :: MonadLB m => ChatInfo -> Module -> m String
- resetCustomL_hs :: MonadLB m => ChatInfo -> m ()
- findPristine_hs :: MonadLB m => m FilePath
- findCustomL_hs :: MonadLB m => ChatInfo -> m FilePath
- data ChatInfo = ChatInfo {
- chatInfoChatId :: !Text
- chatInfoType :: !ChatType
- data ChatType
- renderChatType :: ChatType -> String
- readChatInfoFromSource :: String -> ChatInfo
- dropChatInfoFromSource :: ChatInfo -> String -> String
- getDotFilename :: ChatInfo -> String -> FilePath
- getLFilename :: ChatInfo -> FilePath
- editModuleName :: ChatInfo -> String -> String
Lambdabot state
lambdabotVersion :: String Source #
Lambdabot version from 'lambdabot-core' package.
telegramPlugins :: [String] Source #
Exported plugin(s).
telegramPlugin :: Module TelegramState Source #
Telegram plugin for Lambdabot.
Here we redefined eval
plugin to provide multiple sandboxes for different chats.
customHaskellPlugins :: [String] Source #
Eval excluded because we provide it by ourselves.
newTelegramState :: LB TelegramState Source #
Initialise TelegramState
from Lambdabot config and with defaults. Current defaults are:
- Input queue size: 1000000.
- Output queue size: 1000000.
feed :: Text -> Text -> Text -> Telegram () Source #
Commands preprocessing. Commands started with >
, !
would be replaced
with (from Lambdabot config) + "run "
.
Resulted command would be passed to IRC system
plugin.
handleMsg :: IrcMessage -> Telegram () Source #
Transcoding the response from IRC system
plugin and sending message back to Telegram.
Eval
Functions above came from eval
plugin from lambdabot-haskell-plugins
package.
Instead of registering multiple "servers" for each Telegram chat and introducing new entities to manage multiple "servers",
we decided to keep a single "server" and to modify "sandboxes".
Sandbox is a basically single file "L.hs" that populated once IRC received "@let" command.
For every chat used exactly the same file. It means that it was possible to share all definitions across different Telegram chats.
To overcome these limitations we decided to create a separate file and associate it with a chat.
args :: String -> String -> [String] -> [String] -> [String] Source #
Concatenate all input into list of strings to pass to GHC:
args filesToLoad sourceExpressionToEvaluate ghcExtensions trustedPackages
isEval :: MonadLB m => String -> m Bool Source #
Determine whether command belongs to eval
plugin or not.
dropPrefix :: String -> String Source #
Drop command prefix.
runGHC :: MonadLB m => String -> m String Source #
Represents "run" command. Actually run GHC. Response would be handled separately via callbacks.
define :: MonadLB m => String -> m String Source #
"define" command. Define a new binding. It would be stored in corresponding sandbox.
mergeModules :: Module -> Module -> Module Source #
Merge the second module _into_ the first - meaning where merging doesn't make sense, the field from the first will be used.
moveFile :: FilePath -> FilePath -> IO () Source #
Helper for sandboxes. Used to move temporary file.
customComp :: MonadLB m => ChatInfo -> Module -> m String Source #
Custom compilation of temporary files for binding. Used as part of "define" command.
resetCustomL_hs :: MonadLB m => ChatInfo -> m () Source #
Reset sandbox. Associated "L.hs" file would be reset to defaults.
findPristine_hs :: MonadLB m => m FilePath Source #
Find "Pristine.hs"; if not found, we try to install a compiler-specific version from lambdabot's data directory, and finally the default one.
findCustomL_hs :: MonadLB m => ChatInfo -> m FilePath Source #
Find associated with a chat "L.hs" file; if not found, we copy it from "Pristine.hs".
Since Lambdabot is passing String
inside one plugin (see process
for more details), Telegram chat information rendered as String
and attached to every command to pass between commands and callbacks inside a plugin.
ChatInfo
represents an associated Telegram chat. Currently supports private and public chats.
ChatInfo | |
|
renderChatType :: ChatType -> String Source #
Since it's not possible to define module with "L-1000" name and private chats in Telegram are usually represented by negative digits, we simple encode it with a character.
dropChatInfoFromSource :: ChatInfo -> String -> String Source #
Drop ChatInfo
from command string. Original command is returned.