mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-15 00:19:24 +01:00
This commit is contained in:
parent
9d84d6dd64
commit
4c44515f9d
@ -21,7 +21,6 @@ type Bdiscord struct {
|
|||||||
c *discordgo.Session
|
c *discordgo.Session
|
||||||
|
|
||||||
nick string
|
nick string
|
||||||
useChannelID bool
|
|
||||||
guildID string
|
guildID string
|
||||||
webhookID string
|
webhookID string
|
||||||
webhookToken string
|
webhookToken string
|
||||||
@ -174,10 +173,6 @@ func (b *Bdiscord) JoinChannel(channel config.ChannelInfo) error {
|
|||||||
defer b.channelsMutex.Unlock()
|
defer b.channelsMutex.Unlock()
|
||||||
|
|
||||||
b.channelInfoMap[channel.ID] = &channel
|
b.channelInfoMap[channel.ID] = &channel
|
||||||
idcheck := strings.Split(channel.Name, "ID:")
|
|
||||||
if len(idcheck) > 1 {
|
|
||||||
b.useChannelID = true
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,7 @@ import (
|
|||||||
func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) { //nolint:unparam
|
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 := config.Message{Account: b.Account, ID: m.ID, Event: config.EventMsgDelete, Text: config.EventMsgDelete}
|
||||||
rmsg.Channel = b.getChannelName(m.ChannelID)
|
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("<= Sending message from %s to gateway", b.Account)
|
||||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
@ -24,11 +22,7 @@ func (b *Bdiscord) messageDeleteBulk(s *discordgo.Session, m *discordgo.MessageD
|
|||||||
ID: msgID,
|
ID: msgID,
|
||||||
Event: config.EventMsgDelete,
|
Event: config.EventMsgDelete,
|
||||||
Text: config.EventMsgDelete,
|
Text: config.EventMsgDelete,
|
||||||
Channel: "ID:" + m.ChannelID,
|
Channel: b.getChannelName(m.ChannelID),
|
||||||
}
|
|
||||||
|
|
||||||
if !b.useChannelID {
|
|
||||||
rmsg.Channel = b.getChannelName(m.ChannelID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
||||||
@ -44,9 +38,6 @@ func (b *Bdiscord) messageTyping(s *discordgo.Session, m *discordgo.TypingStart)
|
|||||||
|
|
||||||
rmsg := config.Message{Account: b.Account, Event: config.EventUserTyping}
|
rmsg := config.Message{Account: b.Account, Event: config.EventUserTyping}
|
||||||
rmsg.Channel = b.getChannelName(m.ChannelID)
|
rmsg.Channel = b.getChannelName(m.ChannelID)
|
||||||
if b.useChannelID {
|
|
||||||
rmsg.Channel = "ID:" + m.ChannelID
|
|
||||||
}
|
|
||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +89,6 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
|||||||
|
|
||||||
// set channel name
|
// set channel name
|
||||||
rmsg.Channel = b.getChannelName(m.ChannelID)
|
rmsg.Channel = b.getChannelName(m.ChannelID)
|
||||||
if b.useChannelID {
|
|
||||||
rmsg.Channel = "ID:" + m.ChannelID
|
|
||||||
}
|
|
||||||
|
|
||||||
// set username
|
// set username
|
||||||
if !b.GetBool("UseUserName") {
|
if !b.GetBool("UseUserName") {
|
||||||
|
@ -96,6 +96,13 @@ func (b *Bdiscord) getChannelName(id string) string {
|
|||||||
b.channelsMutex.RLock()
|
b.channelsMutex.RLock()
|
||||||
defer b.channelsMutex.RUnlock()
|
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 {
|
for _, channel := range b.channels {
|
||||||
if channel.ID == id {
|
if channel.ID == id {
|
||||||
return b.getCategoryChannelName(channel.Name, channel.ParentID)
|
return b.getCategoryChannelName(channel.Name, channel.ParentID)
|
||||||
|
Loading…
Reference in New Issue
Block a user