commit 58245d32396456f1447d70a7d130b36ddf101fbf
Author: Wim <wim@42.be>
Date: Thu Jan 09 23:54:04 2020 +0000
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index bc93b95..7159b08 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -217 +216 @@ type Bdiscord struct {
c *discordgo.Session
nick string
- useChannelID bool
guildID string
webhookID string
webhookToken string
@@ -17410 +1736 @@ func (b *Bdiscord) JoinChannel(channel config.ChannelInfo) error {
defer b.channelsMutex.Unlock()
b.channelInfoMap[channel.ID] = &channel
- idcheck := strings.Split(channel.Name, "ID:")
- if len(idcheck) > 1 {
- b.useChannelID = true
- }
return nil
}
diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go
index c86a9e8..ab32097 100644
--- a/bridge/discord/handlers.go
+++ b/bridge/discord/handlers.go
@@ -89 +87 @@ import (
func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) { //nolint:unparam
rmsg := config.Message{Account: b.Account, ID: m.ID, Event: config.EventMsgDelete, Text: config.EventMsgDelete}
rmsg.Channel = b.getChannelName(m.ChannelID)
- if b.useChannelID {
- rmsg.Channel = "ID:" + m.ChannelID
- }
+
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
@@ -2411 +227 @@ func (b *Bdiscord) messageDeleteBulk(s *discordgo.Session, m *discordgo.MessageD
ID: msgID,
Event: config.EventMsgDelete,
Text: config.EventMsgDelete,
- Channel: "ID:" + m.ChannelID,
- }
-
- if !b.useChannelID {
- rmsg.Channel = b.getChannelName(m.ChannelID)
+ Channel: b.getChannelName(m.ChannelID),
}
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
@@ -449 +386 @@ func (b *Bdiscord) messageTyping(s *discordgo.Session, m *discordgo.TypingStart)
rmsg := config.Message{Account: b.Account, Event: config.EventUserTyping}
rmsg.Channel = b.getChannelName(m.ChannelID)
- if b.useChannelID {
- rmsg.Channel = "ID:" + m.ChannelID
- }
b.Remote <- rmsg
}
@@ -989 +896 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
// set channel name
rmsg.Channel = b.getChannelName(m.ChannelID)
- if b.useChannelID {
- rmsg.Channel = "ID:" + m.ChannelID
- }
// set username
if !b.GetBool("UseUserName") {
diff --git a/bridge/discord/helpers.go b/bridge/discord/helpers.go
index c094e47..7ea0a36 100644
--- a/bridge/discord/helpers.go
+++ b/bridge/discord/helpers.go
@@ -966 +9613 @@ func (b *Bdiscord) getChannelName(id string) string {
b.channelsMutex.RLock()
defer b.channelsMutex.RUnlock()
+ for _, c := range b.channelInfoMap {
+ if c.Name == "ID:"+id {
+ // if we have ID: specified in our gateway configuration return this
+ return c.Name
+ }
+ }
+
for _, channel := range b.channels {
if channel.ID == id {
return b.getCategoryChannelName(channel.Name, channel.ParentID)