Skip to content

Commit 2570c60

Browse files
committed
Simplify GetUserInfo
Use a more lightweight call to do the same thing. Signed-off-by: Andrea Barberio <insomniac@slackware.it>
1 parent 57d82ee commit 2570c60

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

irc_context.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,12 @@ func (ic *IrcContext) PostTextMessage(target, text, targetTs string) {
161161
// GetUserInfo returns a slack.User instance from a given user ID, or nil if
162162
// no user with that ID was found
163163
func (ic *IrcContext) GetUserInfo(userID string) *slack.User {
164-
users := ic.GetUsers(false)
165-
if len(users) == 0 {
164+
user, err := ic.SlackClient.GetUserInfo(userID)
165+
if err != nil {
166+
log.Warningf("Failed to get user info for user ID %s: %v", userID, err)
166167
return nil
167168
}
168-
// XXX this may be slow, convert user list to map?
169-
for _, user := range users {
170-
if user.ID == userID {
171-
return &user
172-
}
173-
}
174-
return nil
169+
return user
175170
}
176171

177172
// GetUserInfoByName returns a slack.User instance from a given user name, or

0 commit comments

Comments
 (0)