Fix username of bot
This commit is contained in:
parent
9d5e850495
commit
609c37cdfe
@ -403,19 +403,25 @@ func (s *SlackService) CreateMessage(message slack.Message, channelID string) co
|
|||||||
|
|
||||||
// Get username from cache
|
// Get username from cache
|
||||||
name, ok := s.UserCache[message.User]
|
name, ok := s.UserCache[message.User]
|
||||||
name, ok = s.UserCache[message.BotID]
|
|
||||||
|
|
||||||
// Name not in cache
|
// Name not in cache
|
||||||
if !ok {
|
if !ok {
|
||||||
if message.BotID != "" {
|
if message.BotID != "" {
|
||||||
// Bot, not in cache get bot info
|
name, ok = s.UserCache[message.BotID]
|
||||||
bot, err := s.Client.GetBotInfo(message.BotID)
|
if !ok {
|
||||||
if err != nil {
|
if message.Username != "" {
|
||||||
name = "unkown"
|
name = message.Username
|
||||||
s.UserCache[message.BotID] = name
|
s.UserCache[message.BotID] = message.Username
|
||||||
} else {
|
} else {
|
||||||
name = bot.Name
|
bot, err := s.Client.GetBotInfo(message.BotID)
|
||||||
s.UserCache[message.BotID] = bot.Name
|
if err != nil {
|
||||||
|
name = "unkown"
|
||||||
|
s.UserCache[message.BotID] = name
|
||||||
|
} else {
|
||||||
|
name = bot.Name
|
||||||
|
s.UserCache[message.BotID] = bot.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not a bot, not in cache, get user info
|
// Not a bot, not in cache, get user info
|
||||||
|
Loading…
Reference in New Issue
Block a user