@@ -12,6 +12,22 @@ const (
1212 UnknownUpdateType UpdateType = "unknown"
1313)
1414
15+ type Help struct {
16+ commandList []string
17+ }
18+
19+ func (h * Help ) Add (cmd , text string ) {
20+ h .commandList = append (h .commandList , fmt .Sprintf ("- /%s: %s" , cmd , text ))
21+ }
22+
23+ func (h * Help ) List () []string {
24+ return h .commandList
25+ }
26+
27+ func NewHelp () * Help {
28+ return & Help {commandList : []string {}}
29+ }
30+
1531type UpdateType string
1632
1733type MetricsExporter interface {
@@ -61,14 +77,14 @@ type Bot struct {
6177 commands map [string ]func (c * BotContext )
6278 messenger Messenger
6379 newMembersID map [int64 ]int
64- helps [] string
80+ help * Help
6581}
6682
67- func New (messenger Messenger , helps [] string , newMembersID map [int64 ]int ) * Bot {
83+ func New (messenger Messenger , help * Help , newMembersID map [int64 ]int ) * Bot {
6884 bot := & Bot {
6985 messenger : messenger ,
7086 commands : make (map [string ]func (c * BotContext )),
71- helps : helps ,
87+ help : help ,
7288 newMembersID : newMembersID ,
7389 checkers : []func (c * BotContext ){},
7490 }
@@ -114,7 +130,7 @@ func (b *Bot) BanUser(chatID int64, userID int64) {
114130func (b * Bot ) Command (cmd string , f func (c * BotContext ), help string ) {
115131 b .commands [cmd ] = f
116132 if help != "" {
117- b .helps = append ( b . helps , fmt . Sprintf ( "- /%s: %s" , cmd , help ) )
133+ b .help . Add ( cmd , help )
118134 }
119135}
120136
0 commit comments