diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-07-13T17·39-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-07-13T17·42+0000 |
commit | 68df913b8aeeaca8537953dc9fd5e000ff6e0de2 (patch) | |
tree | ead9ed26205bebc553a60e681c00cffab5a27bc4 | |
parent | 2eb90cbca1c5a45243008912684cd9ea71d304c6 (diff) |
feat(owothia): Make chance configurable r/1271
Make the chance of an owo configurable via an _OWO_CHANCE env var. Change-Id: Ia4d0e426b2825c6a7becc073ff99ae8037637032 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1132 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
-rw-r--r-- | users/glittershark/owothia/src/Main.hs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/users/glittershark/owothia/src/Main.hs b/users/glittershark/owothia/src/Main.hs index 315f07492b94..9c6ec529e15f 100644 --- a/users/glittershark/owothia/src/Main.hs +++ b/users/glittershark/owothia/src/Main.hs @@ -6,17 +6,16 @@ import Control.Lens import NLP.POS import NLP.Types (POSTagger) import NLP.Types.Tree -import qualified NLP.Types.Tree import qualified NLP.Corpora.Conll as Conll import NLP.Corpora.Conll (Tag) import qualified Data.ByteString as BS -import qualified Data.Text as T import System.Random import System.Envy -------------------------------------------------------------------------------- data Config = Config { _nickservPassword :: Text + , _owoChance :: Int } deriving stock (Show, Eq, Generic) deriving anyclass (FromEnv) @@ -41,11 +40,9 @@ randomVerb tagger txt = do owo :: Text -> Text owo = (<> " me owo") -owoChance = 10 - -doOwo :: MonadIO m => m Bool -doOwo = do - n <- liftIO (randomRIO @Int (0, owoChance)) +doOwo :: MonadIO m => Config -> m Bool +doOwo conf = do + n <- liftIO (randomRIO @Int (0, conf ^. owoChance)) liftIO $ putStrLn $ "rolled " <> show n pure $ n == 0 @@ -62,7 +59,7 @@ owothiaHandler conf state tagger = EventHandler Just $ \src ev -> do case (src, ev ^. message) of (Channel "##tvl" nick, Privmsg _ (Right m)) -> do - willOwo <- doOwo + willOwo <- doOwo conf when willOwo $ owoMessage m _ -> pure () @@ -93,5 +90,4 @@ run host port = do runClient conn cfg () main :: IO () -main = do - run "irc.freenode.net" 6667 +main = run "irc.freenode.net" 6667 |