Skip to content

Commit

Permalink
karma throwbacks hotfix: support @mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaln7 committed Oct 22, 2017
1 parent f82ac81 commit c12bccd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ karmabot is a Slack bot that listens for and performs karma operations (aka upvo
### Build from Source

1. clone the repo:
1. `git clone -b v1.4.5 https://github.com/kamaln7/karmabot.git`
1. `git clone -b v1.4.6 https://github.com/kamaln7/karmabot.git`
2. run `go get` and then `go build` in `/cmd/karmabot` and `/cmd/karmabotctl`
1. `cd karmabot`
2. `go get`
Expand Down
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,21 @@ func (b *Bot) getThrowback(ev *slack.MessageEvent) {
return
}

user, err := b.getUserNameByID(ev.User)
if b.handleError(err, ev.Channel, ev.ThreadTimestamp) {
return
}

var (
user string
err error
)
if match[1] != "" {
user = strings.ToLower(match[1])
user, err = b.parseUser(match[1])
if b.handleError(err, ev.Channel, ev.ThreadTimestamp) {
return
}
user = strings.ToLower(user)
} else {
user, err = b.getUserNameByID(ev.User)
if b.handleError(err, ev.Channel, ev.ThreadTimestamp) {
return
}
}

throwback, err := b.Config.DB.GetThrowback(user)
Expand Down
1 change: 1 addition & 0 deletions regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (r *karmaRegex) GetThrowback() *regexp.Regexp {
[]string{
`^karma(?:bot)? (?:throwback) ?(`,
r.user,
r.autocomplete,
`)?$`,
},
"",
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package karmabot

// Version is the current version of karmabot.
const Version = "1.4.5"
const Version = "1.4.6"

0 comments on commit c12bccd

Please sign in to comment.