diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CliOptions.hs | 8 | ||||
| -rw-r--r-- | src/Plugin/GitHubCommit.hs | 19 | 
2 files changed, 15 insertions, 12 deletions
| diff --git a/src/CliOptions.hs b/src/CliOptions.hs index 9d8baf6..f29704a 100644 --- a/src/CliOptions.hs +++ b/src/CliOptions.hs @@ -1,6 +1,8 @@  module CliOptions      ( Options(..) +    , lang +      , parseOptions      ) where @@ -43,3 +45,9 @@ parseOptions = do           ( fullDesc          <> progDesc "A chat bot with a plugin interface that does a bunch of \              \random things." ) + +-- | A convenience function to get the configured locale. +lang :: IO Locale +lang = do +    opts <- parseOptions +    return $ language opts diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs index b8ecf9e..74658a9 100644 --- a/src/Plugin/GitHubCommit.hs +++ b/src/Plugin/GitHubCommit.hs @@ -12,7 +12,7 @@ import Text.Regex.TDFA  import I18n  import qualified Message as M -import CliOptions (Options(language), parseOptions) +import qualified CliOptions as Cli (lang)  import Plugin.Base  gitHubCommit = defaultPlugin @@ -33,20 +33,15 @@ gitHubCommitAction message = do          :: IO [RepoUrlRow]      close dbConn -    opts <- parseOptions -    let lang = language opts - -    return $ respond rs lang +    respond rs    where -    respond [] lang = -        Left $ translate lang GitHubCommitRepoURLNotFound -    respond ((RepoUrlRow r):_) _ = -        Right $ r `T.append` "/commits/" `T.append` T.pack ( +    respond [] = do +        lang <- Cli.lang +        return $ Left $ translate lang GitHubCommitRepoURLNotFound +    respond ((RepoUrlRow r):_) = +        return $ Right $ r `T.append` "/commits/" `T.append` T.pack (              M.textStr message =~ matchRegex gitHubCommit) --- TODO --- lang ::  -  type Id = Int  type RepoUrl = T.Text | 
