diff options
author | Wim <wim@42.be> | 2016-11-13 23:06:37 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-13 23:06:37 +0100 |
commit | 99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (patch) | |
tree | 8799742a6713d28050f5af14ba8d2b1d62cd766a /bridge/discord/discord.go | |
parent | 14830d9f1c4e9435ee7a15e0839876ad1f4d1a9f (diff) | |
download | matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.gz matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.bz2 matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.zip |
Refactor
Diffstat (limited to 'bridge/discord/discord.go')
-rw-r--r-- | bridge/discord/discord.go | 31 |
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 { |