Merge branch 'master' into emojifyme

This commit is contained in:
Scott Kiesel 2017-07-25 06:17:11 -04:00 committed by GitHub
commit e059b51fcf
4 changed files with 19 additions and 18 deletions

View File

@ -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) GetEmojiList() map[string]string { return make(map[string]string) }
func NewMockBot() *MockBot {
db, err := sqlx.Open("sqlite3_custom", ":memory:")
if err != nil {

View File

@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
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:")
if err != nil {
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)

View File

@ -69,6 +69,15 @@ func TestTeaSkieselQuote(t *testing.T) {
assert.Nil(t, err)
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) {
mb := bot.NewMockBot()

View File

@ -439,7 +439,7 @@ func (p *Factoid) forgetLastFact(message msg.Message) bool {
p.Bot.SendMessage(message.Channel, "I refuse.")
return true
}
if message.User.Admin || message.User.Name == p.LastFact.Owner {
err := p.LastFact.delete(p.db)
if err != nil {
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.Bot.SendAction(message.Channel, "hits himself over the head with a skillet")
p.LastFact = nil
} else {
p.Bot.SendMessage(message.Channel, "You don't own that fact.")
}
return true
}
@ -479,12 +476,8 @@ func (p *Factoid) changeFact(message msg.Message) bool {
if err != nil {
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]
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
msg := fmt.Sprintf("Changing %d facts.", len(result))