commit 5bfb3483018a474940c0d9a4b3a515f2db9949dc
Author: Wim <wim@42.be>
Date: Fri Jul 14 00:35:01 2017 +0000
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 2cf56c0..8e0fe06 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -8810 +887 @@ func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Brid
func (b *Bridge) JoinChannels() error {
err := b.joinChannels(b.Channels, b.Joined)
- if err != nil {
- return err
- }
- return nil
+ return err
}
func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map[string]bool) error {
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 69a13e4..2bac2e7 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -2097 +2097 @@ func Deprecated(cfg Protocol, account string) bool {
log.Printf("ERROR: %s BindAddress is deprecated, you need to change it to WebhookBindAddress.", account)
} else if cfg.URL != "" {
log.Printf("ERROR: %s URL is deprecated, you need to change it to WebhookURL.", account)
- } else if cfg.UseAPI == true {
+ } else if cfg.UseAPI {
log.Printf("ERROR: %s UseAPI is deprecated, it's enabled by default, please remove it from your config file.", account)
} else {
return false
diff --git a/bridge/irc/helper.go b/bridge/irc/helper.go
index 355dc55..dd1cc46 100644
--- a/bridge/irc/helper.go
+++ b/bridge/irc/helper.go
@@ -46 +47 @@ import (
"strings"
)
+/*
func tableformatter(nicks []string, nicksPerRow int, continued bool) string {
result := "|IRC users"
if continued {
@@ -296 +307 @@ func tableformatter(nicks []string, nicksPerRow int, continued bool) string {
}
return result
}
+*/
func plainformatter(nicks []string, nicksPerRow int) string {
return strings.Join(nicks, ", ") + " currently on IRC"
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index b86ff50..a5f047d 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -1489 +1489 @@ func (b *Birc) Send(msg config.Message) error {
func (b *Birc) doSend() {
rate := time.Millisecond * time.Duration(b.Config.MessageDelay)
- throttle := time.Tick(rate)
+ throttle := time.NewTicker(rate)
for msg := range b.Local {
- <-throttle
+ <-throttle.C
b.i.Privmsg(msg.Channel, msg.Username+msg.Text)
}
}
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 222522e..d425834 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -129 +128 @@ type MMhook struct {
}
type MMapi struct {
- mc *matterclient.MMClient
- mmMap map[string]string
- mmIgnoreNicks []string
+ mc *matterclient.MMClient
+ mmMap map[string]string
}
type MMMessage struct {
@@ -297 +286 @@ type Bmattermost struct {
MMapi
Config *config.Protocol
Remote chan config.Message
- name string
TeamId string
Account string
}
diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go
index 8eb788f..1b731f9 100644
--- a/bridge/rocketchat/rocketchat.go
+++ b/bridge/rocketchat/rocketchat.go
@@ -167 +166 @@ type Brocketchat struct {
MMhook
Config *config.Protocol
Remote chan config.Message
- name string
Account string
}
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index c1e324a..6555d40 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -1207 +1207 @@ func (b *Bslack) Send(msg config.Message) error {
return err
}
np := slack.NewPostMessageParameters()
- if b.Config.PrefixMessagesWithNick == true {
+ if b.Config.PrefixMessagesWithNick {
np.AsUser = true
}
np.Username = nick
diff --git a/bridge/steam/steam.go b/bridge/steam/steam.go
index 5f40972..ad4b198 100644
--- a/bridge/steam/steam.go
+++ b/bridge/steam/steam.go
@@ -1367 +1367 @@ func (b *Bsteam) handleEvents() {
myLoginInfo.AuthCode = code
}
default:
- log.Errorf("LogOnFailedEvent: ", e.Result)
+ log.Errorf("LogOnFailedEvent: %#v ", e.Result)
// TODO: Handle EResult_InvalidLoginAuthCode
return
}
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 03d6aa9..fa1e634 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -9631 +9628 @@ func (gw *Gateway) Start() error {
}
func (gw *Gateway) handleReceive() {
- for {
- select {
- case msg := <-gw.Message:
- if msg.Event == config.EVENT_FAILURE {
- for _, br := range gw.Bridges {
- if msg.Account == br.Account {
- go gw.reconnectBridge(br)
- }
+ for msg := range gw.Message {
+ if msg.Event == config.EVENT_FAILURE {
+ for _, br := range gw.Bridges {
+ if msg.Account == br.Account {
+ go gw.reconnectBridge(br)
}
}
- if msg.Event == config.EVENT_REJOIN_CHANNELS {
- for _, br := range gw.Bridges {
- if msg.Account == br.Account {
- br.Joined = make(map[string]bool)
- br.JoinChannels()
- }
+ }
+ if msg.Event == config.EVENT_REJOIN_CHANNELS {
+ for _, br := range gw.Bridges {
+ if msg.Account == br.Account {
+ br.Joined = make(map[string]bool)
+ br.JoinChannels()
}
- continue
}
- if !gw.ignoreMessage(&msg) {
- msg.Timestamp = time.Now()
- gw.modifyMessage(&msg)
- for _, br := range gw.Bridges {
- gw.handleMessage(msg, br)
- }
+ continue
+ }
+ if !gw.ignoreMessage(&msg) {
+ msg.Timestamp = time.Now()
+ gw.modifyMessage(&msg)
+ for _, br := range gw.Bridges {
+ gw.handleMessage(msg, br)
}
}
}
@@ -3178 +3148 @@ func (gw *Gateway) validGatewayDest(msg *config.Message, channel *config.Channel
// check if we are running a samechannelgateway.
// if it is and the channel name matches it's ok, otherwise we shouldn't use this channel.
- for k, _ := range GIDmap {
- if channel.SameChannel[k] == true {
+ for k := range GIDmap {
+ if channel.SameChannel[k] {
if msg.Channel == channel.Name {
// add the gateway to our message
msg.Gateway = k
@@ -3298 +3268 @@ func (gw *Gateway) validGatewayDest(msg *config.Message, channel *config.Channel
}
}
// check if we are in the correct gateway
- for k, _ := range GIDmap {
- if channel.GID[k] == true {
+ for k := range GIDmap {
+ if channel.GID[k] {
// add the gateway to our message
msg.Gateway = k
return true
@@ -3408 +3375 @@ func (gw *Gateway) validGatewayDest(msg *config.Message, channel *config.Channel
}
func isApi(account string) bool {
- if strings.HasPrefix(account, "api.") {
- return true
- }
- return false
+ return strings.HasPrefix(account, "api.")
}
diff --git a/hook/rockethook/rockethook.go b/hook/rockethook/rockethook.go
index eafd4f4..063be74 100644
--- a/hook/rockethook/rockethook.go
+++ b/hook/rockethook/rockethook.go
@@ -9910 +999 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Receive returns an incoming message from mattermost outgoing webhooks URL.
func (c *Client) Receive() Message {
- for {
- select {
- case msg := <-c.In:
- return msg
- }
+ var msg Message
+ for msg = range c.In {
+ return msg
}
+ return msg
}
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go
index 47fb211..75d883f 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -887 +887 @@ func (m *MMClient) SetLogLevel(level string) {
func (m *MMClient) Login() error {
// check if this is a first connect or a reconnection
firstConnection := true
- if m.WsConnected == true {
+ if m.WsConnected {
firstConnection = false
}
m.WsConnected = false
@@ -1497 +1497 @@ func (m *MMClient) Login() error {
return errors.New("invalid " + model.SESSION_COOKIE_TOKEN)
}
} else {
- myinfo, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
+ _, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
}
if appErr != nil {
d := b.Duration()
@@ -3297 +3296 @@ func (m *MMClient) parseActionPost(rmsg *Message) {
}
rmsg.Text = data.Message
rmsg.Post = data
- return
}
func (m *MMClient) UpdateUsers() error {
@@ -5357 +5347 @@ func (m *MMClient) UpdateLastViewed(channelId string) {
if m.mmVersion() >= 3.08 {
view := model.ChannelView{ChannelId: channelId}
res, _ := m.Client.ViewChannel(view)
- if res == false {
+ if !res {
m.log.Errorf("ChannelView update for %s failed", channelId)
}
return
@@ -68313 +68213 @@ func (m *MMClient) GetUsers() map[string]*model.User {
func (m *MMClient) GetUser(userId string) *model.User {
m.Lock()
defer m.Unlock()
- u, ok := m.Users[userId]
+ _, ok := m.Users[userId]
if !ok {
res, err := m.Client.GetProfilesByIds([]string{userId})
if err != nil {
return nil
}
- u = res.Data.(map[string]*model.User)[userId]
+ u := res.Data.(map[string]*model.User)[userId]
m.Users[userId] = u
}
return m.Users[userId]
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index 7d02ef4..a269080 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -13412 +13411 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Receive returns an incoming message from mattermost outgoing webhooks URL.
func (c *Client) Receive() IMessage {
- for {
- select {
- case msg := <-c.In:
- return msg
- }
+ var msg IMessage
+ for msg := range c.In {
+ return msg
}
+ return msg
}
// Send sends a msg to mattermost incoming webhooks URL.