@@ -8,6 +8,7 @@ module Bot.Help
88 , startRefreshHelpGistTimer
99 ) where
1010
11+ import Bot.CustomCommand
1112import Bot.GitHub
1213import Bot.Replies
1314import Command
@@ -71,18 +72,39 @@ refreshHelpGistId =
7172 cmapR (const " Scheduled to refresh the Help Gist Page" ) $
7273 Reaction replyMessage
7374
74- gistRenderBuiltinCommand :: (T. Text , BuiltinCommand ) -> T. Text
75- gistRenderBuiltinCommand (name, command) =
76- [qms ||{name}|{bcDescription command}|{bcGitHubLocation command}||]
77-
7875gistRenderCommandTable :: CommandTable -> T. Text
79- gistRenderCommandTable = T. unlines . map gistRenderBuiltinCommand . M. toList
76+ gistRenderCommandTable =
77+ ([qms |* Builtin Commands\n{header}\n|-\n|] <> ) .
78+ T. unlines . map renderRow . M. toList
79+ where
80+ header :: T. Text
81+ header = " |Name|Description|Location|"
82+ renderRow :: (T. Text , BuiltinCommand ) -> T. Text
83+ renderRow (name, command) =
84+ [qms ||{name}|{bcDescription command}|{location}||]
85+ where
86+ location :: T. Text
87+ location = [qms |[[{bcGitHubLocation command}][Source↗]]|]
88+
89+ gistRenderCustomCommandsTable :: [Entity CustomCommand ] -> T. Text
90+ gistRenderCustomCommandsTable =
91+ ([qms |* Custom commands\n{header}\n|-\n|] <> ) .
92+ T. unlines . map (renderRow . entityPayload)
93+ where
94+ header :: T. Text
95+ header = " |Name|Definition|%times|"
96+ renderRow (CustomCommand name message times) =
97+ [qms ||{name}|{message}|{times}||]
8098
81- -- TODO(#649): Help Gist Page does not include CustomCommands
8299refreshHelpGist :: CommandTable -> GistId -> Effect ()
83100refreshHelpGist commandTable gistId = do
84- let gistText = gistRenderCommandTable commandTable
85- updateGistFile helpGistFileName (FileContent gistText) gistId
101+ customsList <- selectEntities Proxy All
102+ updateGistFile
103+ helpGistFileName
104+ (FileContent
105+ (gistRenderCommandTable commandTable <> " \n " <>
106+ gistRenderCustomCommandsTable customsList))
107+ gistId
86108
87109startRefreshHelpGistTimer :: CommandTable -> Effect ()
88110startRefreshHelpGistTimer commandTable =
0 commit comments