lambdabot-core 5.3.0.2 → 5.3.1
raw patch · 3 files changed
+20/−34 lines, 3 filesdep −random-sourcedep ~randomdep ~random-funew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: random-source
Dependency ranges changed: random, random-fu
API changes (from Hackage documentation)
- Lambdabot.Bot: instance Data.Random.Internal.Source.MonadRandom Lambdabot.Monad.LB
- Lambdabot.State: type family LBState m;
+ Lambdabot.State: type LBState m;
Files
- lambdabot-core.cabal +4/−5
- src/Lambdabot/Bot.hs +10/−26
- src/Lambdabot/Util.hs +6/−3
lambdabot-core.cabal view
@@ -1,5 +1,5 @@ name: lambdabot-core-version: 5.3.0.2+version: 5.3.1 license: GPL license-file: LICENSE@@ -19,7 +19,7 @@ build-type: Simple cabal-version: >= 1.10-tested-with: GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4+tested-with: GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4, GHC == 9.0.2, GHC == 9.2.4 extra-source-files: AUTHORS.md COMMENTARY.md@@ -89,9 +89,8 @@ network-bsd >= 2.7 && < 2.9, parsec >= 3, prim-uniq >= 0.2 && < 0.4,- random >= 1,- random-fu >= 0.2.6.2,- random-source >= 0.3,+ random >= 1.2,+ random-fu >= 0.3.0.0, regex-tdfa >= 1.1 && < 1.4, SafeSemaphore >= 0.9, split >= 0.2,
src/Lambdabot/Bot.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-} -- | The guts of lambdabot. -- -- The LB/Lambdabot monad@@ -11,7 +10,7 @@ , ircUnloadModule , checkPrivs , checkIgnore- + , ircCodepage , ircGetChannels , ircQuit@@ -37,7 +36,6 @@ import Control.Monad.Reader import Control.Monad.State import qualified Data.Map as M-import Data.Random.Source import qualified Data.Set as S ------------------------------------------------------------------------@@ -47,18 +45,18 @@ ircLoadModule :: String -> Module st -> LB () ircLoadModule mName m = do infoM ("Loading module " ++ show mName)- + savedState <- readGlobalState m mName mState <- maybe (moduleDefState m) return savedState- + mInfo <- registerModule mName m mState- + flip runModuleT mInfo (do moduleInit m registerCommands =<< moduleCmds m) `E.catch` \e@SomeException{} -> do errorM ("Module " ++ show mName ++ " failed to load. Exception thrown: " ++ show e)- + unregisterModule mName fail "Refusing to load due to a broken plugin" @@ -68,17 +66,17 @@ ircUnloadModule :: String -> LB () ircUnloadModule mName = do infoM ("Unloading module " ++ show mName)- + inModuleNamed mName (fail "module not loaded") $ do m <- asks theModule when (moduleSticky m) $ fail "module is sticky"- + moduleExit m- `E.catch` \e@SomeException{} -> + `E.catch` \e@SomeException{} -> errorM ("Module " ++ show mName ++ " threw the following exception in moduleExit: " ++ show e)- + writeGlobalState- + unregisterModule mName ------------------------------------------------------------------------@@ -136,17 +134,3 @@ ircPrivmsg' :: Nick -> String -> LB () ircPrivmsg' who "" = ircPrivmsg' who " " ircPrivmsg' who msg = send $ privmsg who msg----------------------------------------------------------------------------monadRandom [d|-- instance MonadRandom LB where- getRandomWord8 = liftIO getRandomWord8- getRandomWord16 = liftIO getRandomWord16- getRandomWord32 = liftIO getRandomWord32- getRandomWord64 = liftIO getRandomWord64- getRandomDouble = liftIO getRandomDouble- getRandomNByteInteger n = liftIO (getRandomNByteInteger n)-- |]
src/Lambdabot/Util.hs view
@@ -23,14 +23,15 @@ randomSuccessMsg ) where +import Control.Concurrent.Lifted import Control.Monad.Trans+import Control.Monad.Trans.Control import Data.Char import Data.List import Data.Random-import Control.Concurrent.Lifted-import Control.Monad.Trans.Control import Lambdabot.Config import Lambdabot.Config.Core+import System.Random.Stateful (newIOGenM, newStdGen) ------------------------------------------------------------------------ @@ -63,7 +64,9 @@ -- | Pick a random element of the list. random :: MonadIO m => [a] -> m a-random = io . sample . randomElement+random l = do+ g <- newIOGenM =<< newStdGen+ sampleFrom g (randomElement l) ------------------------------------------------------------------------