@@ -8,14 +8,15 @@ module Bot.Help
88 , startRefreshHelpGistTimer
99 ) where
1010
11+ import Data.Proxy
12+ import Bot.CustomCommand
1113import Bot.GitHub
1214import Bot.Replies
1315import Command
1416import Data.Bool.Extra
1517import Data.Functor
1618import qualified Data.Map as M
1719import Data.Maybe
18- import Data.Proxy
1920import qualified Data.Text as T
2021import Effect
2122import Entity
@@ -75,14 +76,28 @@ gistRenderBuiltinCommand :: (T.Text, BuiltinCommand) -> T.Text
7576gistRenderBuiltinCommand (name, command) =
7677 [qms ||{name}|{bcDescription command}|{bcGitHubLocation command}||]
7778
79+ gistRenderCustomCommand :: CustomCommand -> T. Text
80+ gistRenderCustomCommand (CustomCommand name message times) =
81+ [qms ||{name}|{message}|{times}||]
82+
7883gistRenderCommandTable :: CommandTable -> T. Text
79- gistRenderCommandTable = T. unlines . map gistRenderBuiltinCommand . M. toList
84+ gistRenderCommandTable = (" * Builtin Commands \n " <> ) .
85+ T. unlines . map gistRenderBuiltinCommand . M. toList
8086
8187-- TODO(#649): Help Gist Page does not include CustomCommands
8288refreshHelpGist :: CommandTable -> GistId -> Effect ()
8389refreshHelpGist commandTable gistId = do
84- let gistText = gistRenderCommandTable commandTable
85- updateGistFile helpGistFileName (FileContent gistText) gistId
90+ customsList <- getCustomCommands
91+ let customCommands = T. unlines $ gistRenderCustomCommand . entityPayload <$> customsList
92+ updateGistFile
93+ helpGistFileName
94+ (FileContent (gistText <> " \n * Custom commands \n " <> customCommands))
95+ gistId
96+ where
97+ gistText = gistRenderCommandTable commandTable
98+
99+ getCustomCommands :: Effect ([Entity CustomCommand ])
100+ getCustomCommands = selectEntities Proxy All
86101
87102startRefreshHelpGistTimer :: CommandTable -> Effect ()
88103startRefreshHelpGistTimer commandTable =
0 commit comments