/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 0 - 2 0 2 1 ĠVMware ĠInc . Ġor Ġits Ġaffiliates , ĠAll ĠRights ĠReserved . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠ Ġhttps :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġio . project reactor . bot . service ; ĊĊ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . fasterxml . jackson . databind . node . Array Node Ċ import Ġorg . springframework . stereotype . Service Ċ Ċ /** Ċ Ġ* Ġ@ author ĠSimon ĠBas lÃ© Ċ Ġ*/ Ċ @ Service Ċ class ĠHelp Service ( private Ġval Ġjson Mapper : ĠObjectMapper ) Ġ{ ĊĊ ĉ val Ġhelp By Category Ġ= Ġmutable Map Of < Help Category , ĠMutable Map < String , ĠString >>() ĊĊ ĉ fun Ġadd Help ( category : ĠHelp Category , Ġcommand : ĠString , Ġdescription : ĠString ) Ġ= Ċĉ ĉ help By Category . compute If Absent ( category ) Ġ{ Ġmutable Map Of () Ġ} Ċĉĉĉ ĉ . put ( command , Ġdescription ) ĊĊ ĉ fun Ġdump Help Markdown (): ĠString Ġ{ Ċĉ ĉ var Ġhelp Message Ġ= Ġ" The Ġfollowing Ġcommands Ġare Ġknown Ġto Ġthe Ġbot Ġin Ġthe Ġdifferent Ġchannels :\ n " Ċĉ ĉ help By Category . forEach Ġ{ Ġcat Ġ-> Ċĉĉ ĉ help Message Ġ+= Ġ" ### Ġ${ cat . key } :\ n " Ċĉĉ ĉ cat . value . forEach Ġ{ Ċĉĉĉ ĉ help Message Ġ+= Ġ" Ġ- Ġ`${ it . key }`; Ġ${ it . value }\ n " Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġhelp Message Ċ ĉ } ĊĊ ĉ fun Ġdump Help Slack Blocks Json (): ĠArray Node Ġ{ Ċĉ ĉ val Ġblocks Ġ= Ġjson Mapper . create Array Node () ĊĊĉ ĉ blocks . add Object () Ċĉĉĉ ĉ . put (" type ", Ġ" context ") Ċĉĉĉ ĉ . put Array (" elements ") Ċĉĉĉ ĉ . add Object () Ċĉĉĉ ĉ . put (" type ", Ġ" mr kd wn ") Ċĉĉĉ ĉ . put (" text ", Ġ" The ĠRe actor ĠBot Ġw atches Ġthe Ġfollowing Ġ* MEDIUM * Ġfor Ġthe Ġgiven Ġ` commands `: ") ĊĊĉ ĉ help By Category . forEach Ġ{ Ġcat Ġ-> Ċĉĉ ĉ val Ġsection Ġ= Ġblocks . add Object () Ċĉĉĉĉ ĉ . put (" type ", Ġ" section ") Ċĉĉĉĉ ĉ . put Object (" text ") ĊĊĉĉ ĉ section . put (" type ", Ġ" mr kd wn ") ĊĊĉĉ ĉ var Ġtext Ġ= Ġ": mag _ right : Ġ* ${ cat . key } *" Ċĉĉ ĉ cat . value . forEach Ġ{ Ċĉĉĉ ĉ text Ġ+= Ġ"\ n \ t Ġ- Ġ`${ it . key }` Ġ: Ġ_ ${ it . value }_ " Ċĉĉ ĉ } Ċĉĉ ĉ section . put (" text ", Ġtext ) Ċĉ ĉ } Ċĉ ĉ return Ġblocks Ċ ĉ } Ċ } Ċ Ċ enum Ġclass ĠHelp Category Ġ{ Ċ ĉ GITHUB , Ċ ĉ SL ACK , Ċ ĉ MISC Ċ }