Refactor channel and user management (slack) (#766)

This commit is contained in:
Duco van Amstel
2019-03-15 20:23:09 +00:00
committed by Wim
parent b638f7037a
commit fb2667631d
4 changed files with 138 additions and 94 deletions

View File

@@ -15,7 +15,7 @@ import (
// router before we apply message-dependent modifications.
func (b *Bslack) populateReceivedMessage(ev *slack.MessageEvent) (*config.Message, error) {
// Use our own func because rtm.GetChannelInfo doesn't work for private channels.
channel, err := b.getChannelByID(ev.Channel)
channel, err := b.channels.getChannelByID(ev.Channel)
if err != nil {
return nil, err
}
@@ -77,7 +77,7 @@ func (b *Bslack) populateMessageWithUserInfo(ev *slack.MessageEvent, rmsg *confi
return nil
}
user := b.getUser(userID)
user := b.users.getUser(userID)
if user == nil {
return fmt.Errorf("could not find information for user with id %s", ev.User)
}
@@ -148,7 +148,7 @@ func (b *Bslack) extractTopicOrPurpose(text string) (string, string) {
func (b *Bslack) replaceMention(text string) string {
replaceFunc := func(match string) string {
userID := strings.Trim(match, "@<>")
if username := b.getUsername(userID); userID != "" {
if username := b.users.getUsername(userID); userID != "" {
return "@" + username
}
return match