diff options
author | Teddy Wing | 2017-09-11 00:50:43 +0200 |
---|---|---|
committer | Teddy Wing | 2017-09-13 04:47:08 +0200 |
commit | 515de5dd5d44fb361fe7ca68d698776e84c4d523 (patch) | |
tree | b51d945d554600fde04dbf59574c61b0bc0afc91 /src | |
parent | 3698d614bca4f88c2ffb0c4bf7867e8c5b140b8a (diff) | |
download | sorbot-515de5dd5d44fb361fe7ca68d698776e84c4d523.tar.bz2 |
GitHubCommit: Use `Cli.language` to get language
Since we're trying to get the language from an `Options` type in the
reader, we need to use the `language` helper instead of our custom
`lang` (which operates on `IO`).
Diffstat (limited to 'src')
-rw-r--r-- | src/Plugin/GitHubCommit.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs index fef4474..a1e5ce4 100644 --- a/src/Plugin/GitHubCommit.hs +++ b/src/Plugin/GitHubCommit.hs @@ -7,7 +7,7 @@ module Plugin.GitHubCommit import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Class (lift) -import Control.Monad.Trans.Reader (ask) +import Control.Monad.Trans.Reader (ask, asks) import qualified Data.Text as T import Database.SQLite.Simple @@ -18,18 +18,19 @@ import Text.Regex.TDFA import Bot (Bot, runBot, BotConfig) import I18n import qualified Message as M -import qualified CliOptions as Cli (lang) +import qualified CliOptions as Cli (lang, language) import Plugin.Base -- gitHubCommit :: BotConfig m => m Plugin gitHubCommit :: Bot Plugin gitHubCommit = do + -- cfg <- asks Cli.language cfg <- ask return defaultPlugin { matchRegex = "^[0-9a-f]{40}$" , perform = gitHubCommitAction , command = "<git_sha>" - , description = translate (lang cfg) GitHubCommitDescription + , description = translate (Cli.language cfg) GitHubCommitDescription -- "Generate a commit URL based on the given SHA." } @@ -48,9 +49,10 @@ gitHubCommitAction message = do where respond :: Bot (Either T.Text T.Text) respond [] = do - lang <- Cli.lang + cfg <- ask + -- lang <- Cli.lang -- TODO: remove need for `lang` - return $ Left $ translate (lang cfg) GitHubCommitRepoURLNotFound + return $ Left $ translate (Cli.language cfg) GitHubCommitRepoURLNotFound respond ((RepoUrlRow r):_) = do -- bot <- ask -- plugin <- runBot bot >>= gitHubCommit |