- Timestamp:
- Jun 8, 2020, 8:30:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/service.go
r325 r328 41 41 handle func(dc *downstreamConn, params []string) error 42 42 children serviceCommandSet 43 admin bool 43 44 } 44 45 … … 69 70 if err != nil { 70 71 sendServicePRIVMSG(dc, fmt.Sprintf(`error: %v (type "help" for a list of commands)`, err)) 72 return 73 } 74 if cmd.admin && !dc.user.Admin { 75 sendServicePRIVMSG(dc, fmt.Sprintf(`error: you must be an admin to use this command`)) 71 76 return 72 77 } … … 166 171 } 167 172 168 func appendServiceCommandSetHelp(cmds serviceCommandSet, prefix []string, l *[]string) {173 func appendServiceCommandSetHelp(cmds serviceCommandSet, prefix []string, admin bool, l *[]string) { 169 174 for name, cmd := range cmds { 175 if cmd.admin && !admin { 176 continue 177 } 170 178 words := append(prefix, name) 171 179 if len(cmd.children) == 0 { … … 173 181 *l = append(*l, s) 174 182 } else { 175 appendServiceCommandSetHelp(cmd.children, words, l)183 appendServiceCommandSetHelp(cmd.children, words, admin, l) 176 184 } 177 185 } … … 188 196 if len(cmd.children) > 0 { 189 197 var l []string 190 appendServiceCommandSetHelp(cmd.children, words, &l)198 appendServiceCommandSetHelp(cmd.children, words, dc.user.Admin, &l) 191 199 sendServicePRIVMSG(dc, "available commands: "+strings.Join(l, ", ")) 192 200 } else { … … 201 209 } else { 202 210 var l []string 203 appendServiceCommandSetHelp(serviceCommands, nil, &l)211 appendServiceCommandSetHelp(serviceCommands, nil, dc.user.Admin, &l) 204 212 sendServicePRIVMSG(dc, "available commands: "+strings.Join(l, ", ")) 205 213 }
Note:
See TracChangeset
for help on using the changeset viewer.