From 81cc0dc55bde04761506fbc714befb0942171e7c Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Wed, 29 Jan 2020 12:18:28 -0500 Subject: [PATCH] config: add push command * you can now run `push ` to add values to a setting --- plugins/admin/admin.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/admin/admin.go b/plugins/admin/admin.go index d64989d..d8fd18b 100644 --- a/plugins/admin/admin.go +++ b/plugins/admin/admin.go @@ -104,7 +104,17 @@ func (p *AdminPlugin) message(conn bot.Connector, k bot.Kind, message msg.Messag } p.bot.Send(conn, bot.Message, message.Channel, fmt.Sprintf("Set %s", parts[1])) return true + } else if parts[0] == "push" && len(parts) > 2 { + items := p.cfg.GetArray(parts[1], []string{}) + items = append(items, strings.Join(parts[2:], "")) + if err := p.cfg.Set(parts[1], strings.Join(items, ";;")); err != nil { + p.bot.Send(conn, bot.Message, message.Channel, fmt.Sprintf("Set error: %s", err)) + return true + } + p.bot.Send(conn, bot.Message, message.Channel, fmt.Sprintf("Set %s", parts[1])) + return true } + if parts[0] == "get" && len(parts) == 2 && forbiddenKeys[parts[1]] { p.bot.Send(conn, bot.Message, message.Channel, "You cannot access that key") return true