summaryrefslogtreecommitdiffstats
path: root/bridge/discord
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-13 23:09:06 +0100
committerWim <wim@42.be>2016-11-13 23:09:06 +0100
commit497633867759601d658233257447b5b86aa1b01e (patch)
treebc732d5333ddcd0343e1c2d7fd0a025c23822196 /bridge/discord
parent4fb0544b0e25bf6409811fc3e574bf45efea369d (diff)
parent99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (diff)
downloadmatterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.gz
matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.bz2
matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.zip
Merge branch 'refactor'
Diffstat (limited to 'bridge/discord')
-rw-r--r--bridge/discord/discord.go31
1 files changed, 6 insertions, 25 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 62bc85ce..4497ce3a 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -11,8 +11,7 @@ type bdiscord struct {
c *discordgo.Session
Config *config.Protocol
Remote chan config.Message
- protocol string
- origin string
+ Account string
Channels []*discordgo.Channel
Nick string
UseChannelID bool
@@ -25,12 +24,11 @@ func init() {
flog = log.WithFields(log.Fields{"module": protocol})
}
-func New(cfg config.Protocol, origin string, c chan config.Message) *bdiscord {
+func New(cfg config.Protocol, account string, c chan config.Message) *bdiscord {
b := &bdiscord{}
b.Config = &cfg
b.Remote = c
- b.protocol = protocol
- b.origin = origin
+ b.Account = account
return b
}
@@ -72,10 +70,6 @@ func (b *bdiscord) Connect() error {
return nil
}
-func (b *bdiscord) FullOrigin() string {
- return b.protocol + "." + b.origin
-}
-
func (b *bdiscord) JoinChannel(channel string) error {
idcheck := strings.Split(channel, "ID:")
if len(idcheck) > 1 {
@@ -84,18 +78,6 @@ func (b *bdiscord) JoinChannel(channel string) error {
return nil
}
-func (b *bdiscord) Name() string {
- return b.protocol + "." + b.origin
-}
-
-func (b *bdiscord) Protocol() string {
- return b.protocol
-}
-
-func (b *bdiscord) Origin() string {
- return b.origin
-}
-
func (b *bdiscord) Send(msg config.Message) error {
flog.Debugf("Receiving %#v", msg)
channelID := b.getChannelID(msg.Channel)
@@ -103,8 +85,7 @@ func (b *bdiscord) Send(msg config.Message) error {
flog.Errorf("Could not find channelID for %v", msg.Channel)
return nil
}
- nick := config.GetNick(&msg, b.Config)
- b.c.ChannelMessageSend(channelID, nick+msg.Text)
+ b.c.ChannelMessageSend(channelID, msg.Username+msg.Text)
return nil
}
@@ -121,13 +102,13 @@ func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
if m.Content == "" {
return
}
- flog.Debugf("Sending message from %s on %s to gateway", m.Author.Username, b.FullOrigin())
+ flog.Debugf("Sending message from %s on %s to gateway", m.Author.Username, b.Account)
channelName := b.getChannelName(m.ChannelID)
if b.UseChannelID {
channelName = "ID:" + m.ChannelID
}
b.Remote <- config.Message{Username: m.Author.Username, Text: m.ContentWithMentionsReplaced(), Channel: channelName,
- Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin(), Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg"}
+ Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg"}
}
func (b *bdiscord) getChannelID(name string) string {