diff options
author | Teddy Wing | 2017-11-04 03:00:38 +0100 |
---|---|---|
committer | Teddy Wing | 2017-11-19 19:31:52 +0100 |
commit | eb732a97b82f9d03f68247d79301ee26b84b650b (patch) | |
tree | f8b6d389fc0a2396d76a1adce252f6d3901d4b9e /src/IRC.hs | |
parent | affb573718b28e2df9f5c5f10fb7a1fff434495e (diff) | |
download | sorbot-eb732a97b82f9d03f68247d79301ee26b84b650b.tar.bz2 |
Bot(privmsgFromPlugin): Try to use the `Bot` monad instead of `IO`
Convert this function and `Plugins(performPlugin)` to use a
`Bot`-wrapped plugin.
Still having a lot of trouble with this, unable to get past
monad-related compilation errors. The plan is to leave this as-is for
now and attack the problem from a different place, looking at the `main`
function next, applying our plugins with `runBot`, and then passing
those monad-wrapped plugins to `connectIRC`. Once that's taken care of,
we'll see what we need to modify in this middle strata of the stack.
Diffstat (limited to 'src/IRC.hs')
-rw-r--r-- | src/IRC.hs | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -13,6 +13,7 @@ import qualified Data.Text as T import qualified Network.IRC.Client as IRC +import Bot (Bot) import Message import Plugin (matchPlugin, performPlugin) import Plugin.Base (queryOnly) @@ -61,10 +62,11 @@ handlePrivmsg = IRC.EventHandler Nothing -> return () Just r -> sequence_ r -privmsgFromPlugin :: Message -> MaybeT IO [IRC.StatefulIRC s ()] +privmsgFromPlugin :: Message -> MaybeT Bot [IRC.StatefulIRC s ()] privmsgFromPlugin message = do plugin <- liftMaybe $ matchPlugin message - response <- liftIO $ performPlugin plugin message + response <- lift $ performPlugin plugin message + -- plugin' <- liftMaybe plugin return $ case response of Left err -> [IRC.send $ IRC.Privmsg (toChannel plugin message) |