mirror of https://github.com/velour/catbase.git
Merge branch 'master' into emojifyme
This commit is contained in:
commit
e059b51fcf
|
@ -42,7 +42,6 @@ func (mb *MockBot) CheckAdmin(nick string) bool { return false }
|
||||||
func (mb *MockBot) React(channel, reaction string, message msg.Message) {}
|
func (mb *MockBot) React(channel, reaction string, message msg.Message) {}
|
||||||
func (mb *MockBot) GetEmojiList() map[string]string { return make(map[string]string) }
|
func (mb *MockBot) GetEmojiList() map[string]string { return make(map[string]string) }
|
||||||
|
|
||||||
|
|
||||||
func NewMockBot() *MockBot {
|
func NewMockBot() *MockBot {
|
||||||
db, err := sqlx.Open("sqlite3_custom", ":memory:")
|
db, err := sqlx.Open("sqlite3_custom", ":memory:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
|
if tea, _ := regexp.MatchString("(?i)^tea\\. [^.]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
|
||||||
item, err := GetItem(p.DB, nick, ":tea:")
|
item, err := GetItem(p.DB, nick, ":tea:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
||||||
|
|
|
@ -69,6 +69,15 @@ func TestTeaSkieselQuote(t *testing.T) {
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, 0, item.Count)
|
assert.Equal(t, 0, item.Count)
|
||||||
}
|
}
|
||||||
|
func TestTeaUnicodeJapanese(t *testing.T) {
|
||||||
|
mb := bot.NewMockBot()
|
||||||
|
c := New(mb)
|
||||||
|
assert.NotNil(t, c)
|
||||||
|
c.Message(makeMessage("Tea. おちや. Hot."))
|
||||||
|
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, 1, item.Count)
|
||||||
|
}
|
||||||
|
|
||||||
func TestResetMe(t *testing.T) {
|
func TestResetMe(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
|
|
|
@ -439,7 +439,7 @@ func (p *Factoid) forgetLastFact(message msg.Message) bool {
|
||||||
p.Bot.SendMessage(message.Channel, "I refuse.")
|
p.Bot.SendMessage(message.Channel, "I refuse.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if message.User.Admin || message.User.Name == p.LastFact.Owner {
|
|
||||||
err := p.LastFact.delete(p.db)
|
err := p.LastFact.delete(p.db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error removing fact: ", p.LastFact, err)
|
log.Println("Error removing fact: ", p.LastFact, err)
|
||||||
|
@ -448,9 +448,6 @@ func (p *Factoid) forgetLastFact(message msg.Message) bool {
|
||||||
p.LastFact.Verb, p.LastFact.Tidbit)
|
p.LastFact.Verb, p.LastFact.Tidbit)
|
||||||
p.Bot.SendAction(message.Channel, "hits himself over the head with a skillet")
|
p.Bot.SendAction(message.Channel, "hits himself over the head with a skillet")
|
||||||
p.LastFact = nil
|
p.LastFact = nil
|
||||||
} else {
|
|
||||||
p.Bot.SendMessage(message.Channel, "You don't own that fact.")
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -479,12 +476,8 @@ func (p *Factoid) changeFact(message msg.Message) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting facts: ", trigger, err)
|
log.Println("Error getting facts: ", trigger, err)
|
||||||
}
|
}
|
||||||
if !(message.User.Admin && userexp[len(userexp)-1] == 'g') {
|
if userexp[len(userexp)-1] != 'g' {
|
||||||
result = result[:1]
|
result = result[:1]
|
||||||
if result[0].Owner != message.User.Name && !message.User.Admin {
|
|
||||||
p.Bot.SendMessage(message.Channel, "That's not your fact to edit.")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// make the changes
|
// make the changes
|
||||||
msg := fmt.Sprintf("Changing %d facts.", len(result))
|
msg := fmt.Sprintf("Changing %d facts.", len(result))
|
||||||
|
|
Loading…
Reference in New Issue