mirror of https://github.com/velour/catbase.git
Fixes #1: Make quotes multiline
This commit is contained in:
parent
74a5647d2d
commit
54899c74ca
|
@ -55,8 +55,14 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
|
|||
// we have a remember!
|
||||
// look through the logs and find parts[1] as a user, if not,
|
||||
// fuck this hoser
|
||||
nick := parts[1]
|
||||
snip := strings.Join(parts[2:], " ")
|
||||
snips := strings.Split(strings.Join(parts[1:], " "), "$and")
|
||||
var msgs []string
|
||||
var trigger string
|
||||
|
||||
for _, snip := range snips {
|
||||
snipParts := strings.Split(snip, " ")
|
||||
nick := snipParts[0]
|
||||
snip := strings.Join(snipParts[1:], " ")
|
||||
|
||||
for i := len(p.Log[message.Channel]) - 1; i >= 0; i-- {
|
||||
entry := p.Log[message.Channel][i]
|
||||
|
@ -66,18 +72,24 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
|
|||
strings.ToLower(entry.Body),
|
||||
strings.ToLower(snip),
|
||||
) {
|
||||
// insert new remember entry
|
||||
var msg string
|
||||
|
||||
// check if it's an action
|
||||
if entry.Action {
|
||||
msg = fmt.Sprintf("*%s* %s", entry.User.Name, entry.Body)
|
||||
msgs = append(msgs, fmt.Sprintf("*%s* %s", entry.User.Name, entry.Body))
|
||||
} else {
|
||||
msg = fmt.Sprintf("<%s> %s", entry.User.Name, entry.Body)
|
||||
msgs = append(msgs, fmt.Sprintf("<%s> %s", entry.User.Name, entry.Body))
|
||||
}
|
||||
|
||||
trigger := fmt.Sprintf("%s quotes", entry.User.Name)
|
||||
if trigger == "" {
|
||||
trigger = fmt.Sprintf("%s quotes", entry.User.Name)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(msgs) == len(snips) {
|
||||
msg := strings.Join(msgs, "$and")
|
||||
var funcres bson.M
|
||||
err := p.Bot.Db.Run(
|
||||
bson.M{"eval": "return counter(\"factoid\");"},
|
||||
|
@ -112,7 +124,7 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
|
|||
p.Log[message.Channel] = append(p.Log[message.Channel], message)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
p.Bot.SendMessage(message.Channel, "Sorry, I don't know that phrase.")
|
||||
p.Log[message.Channel] = append(p.Log[message.Channel], message)
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue