Added an idle command to list all idles

This commit is contained in:
Chris Sexton 2013-01-28 13:35:41 -05:00
parent de5c2f808c
commit 290d687be4
1 changed files with 13 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import (
"labix.org/v2/mgo" "labix.org/v2/mgo"
"labix.org/v2/mgo/bson" "labix.org/v2/mgo/bson"
"log" "log"
"sort"
"strings" "strings"
"time" "time"
) )
@ -71,10 +72,18 @@ func (p *DowntimePlugin) Message(message bot.Message) bool {
ret = true ret = true
} else if parts[0] == "idle" && len(parts) == 1 { } else if parts[0] == "idle" && len(parts) == 1 {
// Find all idle times, report them. // Find all idle times, report them.
// var entries idleEntries var entries idleEntries
// p.Coll.Find(nil).All(entries) p.Coll.Find(nil).All(&entries)
// sort.Sort(entries) sort.Sort(entries)
// fmt.Printf("%+v\n", entries) tops := "The top entries are: "
for _, e := range entries {
// filter out ZNC entries
if !strings.HasPrefix(e.Nick, "*") {
tops = fmt.Sprintf("%s%s: %s ", tops, e.Nick, time.Now().Sub(e.LastSeen))
}
}
p.Bot.SendMessage(channel, tops)
} }
p.record(strings.ToLower(message.User.Name)) p.record(strings.ToLower(message.User.Name))