commit 10ebc49ce064f2779439ae8e20d505ede383a84e
Author: Wim <wim@42.be>
Date: Sat Feb 24 23:22:15 2018 +0000
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index eb74dd8..7e5a01d 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -127 +127 @@ import (
"sync"
)
-type bdiscord struct {
+type Bdiscord struct {
c *discordgo.Session
Channels []*discordgo.Channel
Nick string
@@ -338 +338 @@ func init() {
flog = log.WithFields(log.Fields{"prefix": protocol})
}
-func New(cfg *config.BridgeConfig) *bdiscord {
- b := &bdiscord{BridgeConfig: cfg}
+func New(cfg *config.BridgeConfig) *Bdiscord {
+ b := &Bdiscord{BridgeConfig: cfg}
b.userMemberMap = make(map[string]*discordgo.Member)
b.channelInfoMap = make(map[string]*config.ChannelInfo)
if b.Config.WebhookURL != "" {
@@ -447 +447 @@ func New(cfg *config.BridgeConfig) *bdiscord {
return b
}
-func (b *bdiscord) Connect() error {
+func (b *Bdiscord) Connect() error {
var err error
flog.Info("Connecting")
if b.Config.WebhookURL == "" {
@@ -8911 +8911 @@ func (b *bdiscord) Connect() error {
return nil
}
-func (b *bdiscord) Disconnect() error {
+func (b *Bdiscord) Disconnect() error {
return nil
}
-func (b *bdiscord) JoinChannel(channel config.ChannelInfo) error {
+func (b *Bdiscord) JoinChannel(channel config.ChannelInfo) error {
b.channelInfoMap[channel.ID] = &channel
idcheck := strings.Split(channel.Name, "ID:")
if len(idcheck) > 1 {
@@ -1027 +1027 @@ func (b *bdiscord) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *bdiscord) Send(msg config.Message) (string, error) {
+func (b *Bdiscord) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
channelID := b.getChannelID(msg.Channel)
@@ -1817 +1817 @@ func (b *bdiscord) Send(msg config.Message) (string, error) {
return res.ID, err
}
-func (b *bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) {
+func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) {
rmsg := config.Message{Account: b.Account, ID: m.ID, Event: config.EVENT_MSG_DELETE, Text: config.EVENT_MSG_DELETE}
rmsg.Channel = b.getChannelName(m.ChannelID)
if b.UseChannelID {
@@ -1927 +1927 @@ func (b *bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelet
b.Remote <- rmsg
}
-func (b *bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
+func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
if b.Config.EditDisable {
return
}
@@ -2047 +2047 @@ func (b *bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdat
}
}
-func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
+func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
var err error
// not relay our own messages
@@ -2737 +2737 @@ func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
b.Remote <- rmsg
}
-func (b *bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
+func (b *Bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
b.Lock()
if _, ok := b.userMemberMap[m.Member.User.ID]; ok {
flog.Debugf("%s: memberupdate: user %s (nick %s) changes nick to %s", b.Account, m.Member.User.Username, b.userMemberMap[m.Member.User.ID].Nick, m.Member.Nick)
@@ -2827 +2827 @@ func (b *bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUp
b.Unlock()
}
-func (b *bdiscord) getNick(user *discordgo.User) string {
+func (b *Bdiscord) getNick(user *discordgo.User) string {
var err error
b.Lock()
defer b.Unlock()
@@ -3097 +3097 @@ func (b *bdiscord) getNick(user *discordgo.User) string {
return user.Username
}
-func (b *bdiscord) getChannelID(name string) string {
+func (b *Bdiscord) getChannelID(name string) string {
idcheck := strings.Split(name, "ID:")
if len(idcheck) > 1 {
return idcheck[1]
@@ -3227 +3227 @@ func (b *bdiscord) getChannelID(name string) string {
return ""
}
-func (b *bdiscord) getChannelName(id string) string {
+func (b *Bdiscord) getChannelName(id string) string {
for _, channel := range b.Channels {
if channel.ID == id {
return channel.Name
@@ -3317 +3317 @@ func (b *bdiscord) getChannelName(id string) string {
return ""
}
-func (b *bdiscord) replaceChannelMentions(text string) string {
+func (b *Bdiscord) replaceChannelMentions(text string) string {
var err error
re := regexp.MustCompile("<#[0-9]+>")
text = re.ReplaceAllStringFunc(text, func(m string) string {
@@ -35021 +35021 @@ func (b *bdiscord) replaceChannelMentions(text string) string {
return text
}
-func (b *bdiscord) replaceAction(text string) (string, bool) {
+func (b *Bdiscord) replaceAction(text string) (string, bool) {
if strings.HasPrefix(text, "_") && strings.HasSuffix(text, "_") {
return strings.Replace(text, "_", "", -1), true
}
return text, false
}
-func (b *bdiscord) stripCustomoji(text string) string {
+func (b *Bdiscord) stripCustomoji(text string) string {
// <:doge:302803592035958784>
re := regexp.MustCompile("<(:.*?:)[0-9]+>")
return re.ReplaceAllString(text, `$1`)
}
// splitURL splits a webhookURL and returns the id and token
-func (b *bdiscord) splitURL(url string) (string, string) {
+func (b *Bdiscord) splitURL(url string) (string, string) {
webhookURLSplit := strings.Split(url, "/")
if len(webhookURLSplit) != 7 {
log.Fatalf("%s is no correct discord WebhookURL", url)
@@ -3737 +3737 @@ func (b *bdiscord) splitURL(url string) (string, string) {
}
// useWebhook returns true if we have a webhook defined somewhere
-func (b *bdiscord) useWebhook() bool {
+func (b *Bdiscord) useWebhook() bool {
if b.Config.WebhookURL != "" {
return true
}
@@ -3867 +3867 @@ func (b *bdiscord) useWebhook() bool {
}
// isWebhookID returns true if the specified id is used in a defined webhook
-func (b *bdiscord) isWebhookID(id string) bool {
+func (b *Bdiscord) isWebhookID(id string) bool {
if b.Config.WebhookURL != "" {
wID, _ := b.splitURL(b.Config.WebhookURL)
if wID == id {
@@ -4057 +4057 @@ func (b *bdiscord) isWebhookID(id string) bool {
}
// handleUploadFile handles native upload of files
-func (b *bdiscord) handleUploadFile(msg *config.Message, channelID string) (string, error) {
+func (b *Bdiscord) handleUploadFile(msg *config.Message, channelID string) (string, error) {
var err error
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index b94f42b..e333580 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -147 +147 @@ import (
type Bmattermost struct {
mh *matterhook.Client
mc *matterclient.MMClient
- TeamId string
+ TeamID string
*config.BridgeConfig
avatarMap map[string]string
}
@@ -1007 +1007 @@ func (b *Bmattermost) Connect() error {
go b.handleMatter()
}
if b.Config.WebhookBindAddress == "" && b.Config.WebhookURL == "" && b.Config.Login == "" && b.Config.Token == "" {
- return errors.New("No connection method found. See that you have WebhookBindAddress, WebhookURL or Token/Login/Password/Server/Team configured.")
+ return errors.New("no connection method found. See that you have WebhookBindAddress, WebhookURL or Token/Login/Password/Server/Team configured")
}
return nil
}
@@ -2747 +2747 @@ func (b *Bmattermost) apiLogin() error {
return err
}
flog.Info("Connection succeeded")
- b.TeamId = b.mc.GetTeamId()
+ b.TeamID = b.mc.GetTeamId()
go b.mc.WsReceiver()
go b.mc.StatusLoop()
return nil
@@ -3277 +3277 @@ func (b *Bmattermost) handleDownloadFile(rmsg *config.Message, id string) error
if resp.Error != nil {
return resp.Error
}
- err := helper.HandleDownloadSize(flog, rmsg, finfo.Name, int64(finfo.Size), b.General)
+ err := helper.HandleDownloadSize(flog, rmsg, finfo.Name, finfo.Size, b.General)
if err != nil {
return err
}
@@ -4367 +4367 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool {
}
// ignore messages from other teams than ours
- if message.Raw.Data["team_id"].(string) != b.TeamId {
+ if message.Raw.Data["team_id"].(string) != b.TeamID {
return true
}