mirror of https://github.com/velour/catbase.git
commit
0e0878ec90
|
@ -38,8 +38,8 @@ func GetItems(db *sqlx.DB, nick string) ([]Item, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Don't forget to embed the DB into all of that shiz
|
// Don't forget to embed the DB into all of that shiz
|
||||||
for _, i := range items {
|
for i := range items {
|
||||||
i.DB = db
|
items[i].DB = db
|
||||||
}
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,20 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if message.Command && parts[0] == "inspect" && len(parts) == 2 {
|
if message.Command && message.Body == "reset me" {
|
||||||
|
items, err := GetItems(p.DB, strings.ToLower(nick))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error getting items to reset %s: %s", nick, err)
|
||||||
|
p.Bot.SendMessage(channel, "Something is technically wrong with your counters.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
log.Printf("Items: %+v", items)
|
||||||
|
for _, item := range items {
|
||||||
|
item.Delete()
|
||||||
|
}
|
||||||
|
p.Bot.SendMessage(channel, fmt.Sprintf("%s, you are as new, my son.", nick))
|
||||||
|
return true
|
||||||
|
} else if message.Command && parts[0] == "inspect" && len(parts) == 2 {
|
||||||
var subject string
|
var subject string
|
||||||
|
|
||||||
if parts[1] == "me" {
|
if parts[1] == "me" {
|
||||||
|
|
|
@ -26,6 +26,17 @@ func makeMessage(payload string) msg.Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResetMe(t *testing.T) {
|
||||||
|
mb := bot.NewMockBot()
|
||||||
|
c := New(mb)
|
||||||
|
assert.NotNil(t, c)
|
||||||
|
c.Message(makeMessage("test++"))
|
||||||
|
c.Message(makeMessage("!reset me"))
|
||||||
|
items, err := GetItems(mb.DB(), "tester")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Len(t, items, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCounterOne(t *testing.T) {
|
func TestCounterOne(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
c := New(mb)
|
c := New(mb)
|
||||||
|
|
Loading…
Reference in New Issue