Skip to content

Commit

Permalink
Make .gc and .mem admin only
Browse files Browse the repository at this point in the history
  • Loading branch information
godwhoa committed Feb 25, 2019
1 parent e040fe3 commit c7b3ae4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func Register(deps *oodle.Deps) error {
bot.RegisterCommands(
Echo(),
Version(),
GC(),
Memory(),
GC(irc),
Memory(irc),
List(bot, irc),
Help(bot),
remindin.Command(),
Expand All @@ -71,8 +71,8 @@ func Version() oodle.Command {
}
}

func GC() oodle.Command {
return oodle.Command{
func GC(checker oodle.Checker) oodle.Command {
cmd := oodle.Command{
Prefix: ".",
Name: "gc",
Description: "Runs GC; debug purpose only.",
Expand All @@ -83,10 +83,11 @@ func GC() oodle.Command {
return "Ran runtime.GC() and debug.FreeOSMemory()", nil
},
}
return m.Chain(cmd, m.AdminOnly(checker))
}

func Memory() oodle.Command {
return oodle.Command{
func Memory(checker oodle.Checker) oodle.Command {
cmd := oodle.Command{
Prefix: ".",
Name: "mem",
Description: "Shows memory usage",
Expand All @@ -102,6 +103,7 @@ func Memory() oodle.Command {
return fmt.Sprintf("Alloc: %d MiB TotalAlloc: %d MiB Sys: %d MiB LastGC: %s; https://godoc.org/runtime#MemStats", alloc, talloc, sys, u.FmtTime(gc.LastGC)), nil
},
}
return m.Chain(cmd, m.AdminOnly(checker))
}

// Help gives help info for commands
Expand Down

0 comments on commit c7b3ae4

Please sign in to comment.