mirror of https://github.com/velour/catbase.git
Added helptext to list variables
This commit is contained in:
parent
c2bf96f897
commit
ac8bc9a145
|
@ -52,7 +52,7 @@ func (b *Bot) checkuser(nick string) *User {
|
|||
func (b *Bot) checkHelp(channel string, parts []string) {
|
||||
if len(parts) == 1 {
|
||||
// just print out a list of help topics
|
||||
topics := "Help topics: about"
|
||||
topics := "Help topics: about variables"
|
||||
for name, _ := range b.Plugins {
|
||||
topics = fmt.Sprintf("%s, %s", topics, name)
|
||||
}
|
||||
|
@ -63,6 +63,10 @@ func (b *Bot) checkHelp(channel string, parts []string) {
|
|||
b.Help(channel, parts)
|
||||
return
|
||||
}
|
||||
if parts[1] == "variables" {
|
||||
b.listVars(channel, parts)
|
||||
return
|
||||
}
|
||||
plugin := b.Plugins[parts[1]]
|
||||
if plugin != nil {
|
||||
plugin.Help(channel, parts)
|
||||
|
@ -206,6 +210,19 @@ func (b *Bot) Filter(message Message, input string) string {
|
|||
return input
|
||||
}
|
||||
|
||||
func (b *Bot) listVars(channel string, parts []string) {
|
||||
var result []string
|
||||
err := b.varColl.Find(bson.M{}).Distinct("variable", &result)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
msg := "I know: $who, $someone, $digit, $nonzero"
|
||||
for _, variable := range result {
|
||||
msg = fmt.Sprintf("%s, %s", msg, variable)
|
||||
}
|
||||
b.SendMessage(channel, msg)
|
||||
}
|
||||
|
||||
func (b *Bot) Help(channel string, parts []string) {
|
||||
msg := fmt.Sprintf("Hi, I'm based on godeepintir version %s. I'm written in Go, and you "+
|
||||
"can find my source code on the internet here: "+
|
||||
|
|
|
@ -31,6 +31,7 @@ func NewAdminPlugin(bot *bot.Bot) *AdminPlugin {
|
|||
// Otherwise, the function returns false and the bot continues execution of other plugins.
|
||||
func (p *AdminPlugin) Message(message bot.Message) bool {
|
||||
// This bot does not reply to anything
|
||||
|
||||
if !message.User.Admin {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue