forked from lug/matterbridge
		
	Compare commits
	
		
			10 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | d6ee55e35f | ||
|   | aef64eec32 | ||
|   | c4193d5ccd | ||
|   | 0c94186818 | ||
|   | 9039720013 | ||
|   | a3470f8aec | ||
|   | 01badde21d | ||
|   | a37b232dd9 | ||
|   | 579ee48385 | ||
|   | dd985d1dad | 
| @@ -36,7 +36,7 @@ Has a REST API. | ||||
|  | ||||
| # Requirements | ||||
| Accounts to one of the supported bridges | ||||
| * [Mattermost](https://github.com/mattermost/platform/) 3.8.x - 3.10.x, 4.0.x - 4.1.x | ||||
| * [Mattermost](https://github.com/mattermost/platform/) 3.8.x - 3.10.x, 4.0.x - 4.2.x | ||||
| * [IRC](http://www.mirc.com/servers.html) | ||||
| * [XMPP](https://jabber.org) | ||||
| * [Gitter](https://gitter.im) | ||||
| @@ -53,7 +53,7 @@ See https://github.com/42wim/matterbridge/wiki | ||||
|  | ||||
| # Installing | ||||
| ## Binaries | ||||
| * Latest stable release [v1.1.1](https://github.com/42wim/matterbridge/releases/latest) | ||||
| * Latest stable release [v1.1.2](https://github.com/42wim/matterbridge/releases/latest) | ||||
| * Development releases (follows master) can be downloaded [here](https://dl.bintray.com/42wim/nightly/)   | ||||
|  | ||||
| ## Building | ||||
|   | ||||
| @@ -88,6 +88,7 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error { | ||||
| 						rmsg.Event = config.EVENT_USER_ACTION | ||||
| 						rmsg.Text = strings.Replace(rmsg.Text, "@"+ev.Message.From.Username+" ", "", -1) | ||||
| 					} | ||||
| 					flog.Debugf("Message is %#v", rmsg) | ||||
| 					b.Remote <- rmsg | ||||
| 				} | ||||
| 			case *gitter.GitterConnectionClosed: | ||||
|   | ||||
| @@ -195,6 +195,7 @@ func (b *Bmattermost) handleMatter() { | ||||
| 		} | ||||
| 		rmsg.Text = text | ||||
| 		flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) | ||||
| 		flog.Debugf("Message is %#v", rmsg) | ||||
| 		b.Remote <- rmsg | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -257,65 +257,60 @@ func (b *Bslack) handleSlack() { | ||||
| } | ||||
|  | ||||
| func (b *Bslack) handleSlackClient(mchan chan *MMMessage) { | ||||
| 	count := 0 | ||||
| 	for msg := range b.rtm.IncomingEvents { | ||||
| 		switch ev := msg.Data.(type) { | ||||
| 		case *slack.MessageEvent: | ||||
| 			// ignore first message | ||||
| 			if count > 0 { | ||||
| 				flog.Debugf("Receiving from slackclient %#v", ev) | ||||
| 				if len(ev.Attachments) > 0 { | ||||
| 					// skip messages we made ourselves | ||||
| 					if ev.Attachments[0].CallbackID == "matterbridge" { | ||||
| 						continue | ||||
| 					} | ||||
| 			flog.Debugf("Receiving from slackclient %#v", ev) | ||||
| 			if len(ev.Attachments) > 0 { | ||||
| 				// skip messages we made ourselves | ||||
| 				if ev.Attachments[0].CallbackID == "matterbridge" { | ||||
| 					continue | ||||
| 				} | ||||
| 				if !b.Config.EditDisable && ev.SubMessage != nil && ev.SubMessage.ThreadTimestamp != ev.SubMessage.Timestamp { | ||||
| 					flog.Debugf("SubMessage %#v", ev.SubMessage) | ||||
| 					ev.User = ev.SubMessage.User | ||||
| 					ev.Text = ev.SubMessage.Text + b.Config.EditSuffix | ||||
| 				} | ||||
| 				// use our own func because rtm.GetChannelInfo doesn't work for private channels | ||||
| 				channel, err := b.getChannelByID(ev.Channel) | ||||
| 			} | ||||
| 			if !b.Config.EditDisable && ev.SubMessage != nil && ev.SubMessage.ThreadTimestamp != ev.SubMessage.Timestamp { | ||||
| 				flog.Debugf("SubMessage %#v", ev.SubMessage) | ||||
| 				ev.User = ev.SubMessage.User | ||||
| 				ev.Text = ev.SubMessage.Text + b.Config.EditSuffix | ||||
| 			} | ||||
| 			// use our own func because rtm.GetChannelInfo doesn't work for private channels | ||||
| 			channel, err := b.getChannelByID(ev.Channel) | ||||
| 			if err != nil { | ||||
| 				continue | ||||
| 			} | ||||
| 			m := &MMMessage{} | ||||
| 			if ev.BotID == "" { | ||||
| 				user, err := b.rtm.GetUserInfo(ev.User) | ||||
| 				if err != nil { | ||||
| 					continue | ||||
| 				} | ||||
| 				m := &MMMessage{} | ||||
| 				if ev.BotID == "" { | ||||
| 					user, err := b.rtm.GetUserInfo(ev.User) | ||||
| 					if err != nil { | ||||
| 						continue | ||||
| 					} | ||||
| 					m.UserID = user.ID | ||||
| 					m.Username = user.Name | ||||
| 				} | ||||
| 				m.Channel = channel.Name | ||||
| 				m.Text = ev.Text | ||||
| 				if m.Text == "" { | ||||
| 					for _, attach := range ev.Attachments { | ||||
| 						if attach.Text != "" { | ||||
| 							m.Text = attach.Text | ||||
| 						} else { | ||||
| 							m.Text = attach.Fallback | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				m.Raw = ev | ||||
| 				m.Text = b.replaceMention(m.Text) | ||||
| 				// when using webhookURL we can't check if it's our webhook or not for now | ||||
| 				if ev.BotID != "" && b.Config.WebhookURL == "" { | ||||
| 					bot, err := b.rtm.GetBotInfo(ev.BotID) | ||||
| 					if err != nil { | ||||
| 						continue | ||||
| 					} | ||||
| 					if bot.Name != "" { | ||||
| 						m.Username = bot.Name | ||||
| 						m.UserID = bot.ID | ||||
| 					} | ||||
| 				} | ||||
| 				mchan <- m | ||||
| 				m.UserID = user.ID | ||||
| 				m.Username = user.Name | ||||
| 			} | ||||
| 			count++ | ||||
| 			m.Channel = channel.Name | ||||
| 			m.Text = ev.Text | ||||
| 			if m.Text == "" { | ||||
| 				for _, attach := range ev.Attachments { | ||||
| 					if attach.Text != "" { | ||||
| 						m.Text = attach.Text | ||||
| 					} else { | ||||
| 						m.Text = attach.Fallback | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			m.Raw = ev | ||||
| 			m.Text = b.replaceMention(m.Text) | ||||
| 			// when using webhookURL we can't check if it's our webhook or not for now | ||||
| 			if ev.BotID != "" && b.Config.WebhookURL == "" { | ||||
| 				bot, err := b.rtm.GetBotInfo(ev.BotID) | ||||
| 				if err != nil { | ||||
| 					continue | ||||
| 				} | ||||
| 				if bot.Name != "" { | ||||
| 					m.Username = bot.Name | ||||
| 					m.UserID = bot.ID | ||||
| 				} | ||||
| 			} | ||||
| 			mchan <- m | ||||
| 		case *slack.OutgoingErrorEvent: | ||||
| 			flog.Debugf("%#v", ev.Error()) | ||||
| 		case *slack.ChannelJoinedEvent: | ||||
|   | ||||
| @@ -1,3 +1,9 @@ | ||||
| # v1.1.2 | ||||
| * general: also build darwin binaries | ||||
| * mattermost: add support for mattermost 4.2.x | ||||
| * mattermost: Send images when text is empty regression. (mattermost). Closes #254 | ||||
| * slack: also send the first messsage after connect. #252 | ||||
|  | ||||
| # v1.1.1 | ||||
| ## Bugfix | ||||
| * mattermost: fix public links | ||||
|   | ||||
| @@ -2,9 +2,10 @@ | ||||
| go version |grep go1.9 || exit | ||||
| VERSION=$(git describe --tags) | ||||
| mkdir ci/binaries | ||||
| GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-win64.exe | ||||
| GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-linux64 | ||||
| GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-windows-amd64.exe | ||||
| GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-linux-amd64 | ||||
| GOOS=linux GOARCH=arm go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-linux-arm | ||||
| GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-darwin-amd64 | ||||
| cd ci | ||||
| cat > deploy.json <<EOF | ||||
| { | ||||
|   | ||||
| @@ -11,7 +11,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	version = "1.1.1" | ||||
| 	version = "1.1.2" | ||||
| 	githash string | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -383,7 +383,6 @@ WebhookURL="https://hooks.slack.com/services/yourhook" | ||||
| #AND DEDICATED BOT USER WHEN POSSIBLE! | ||||
| #Address to listen on for outgoing webhook requests from slack | ||||
| #See account settings - integrations - outgoing webhooks on slack | ||||
| #This setting will not be used when useAPI is eanbled | ||||
| #webhooks | ||||
| #OPTIONAL | ||||
| WebhookBindAddress="0.0.0.0:9999" | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
|  | ||||
| [mattermost] | ||||
|     [mattermost.work] | ||||
|     useAPI=true | ||||
|     #do not prefix it wit http:// or https:// | ||||
|     Server="yourmattermostserver.domain"  | ||||
|     Team="yourteam" | ||||
|   | ||||
| @@ -277,6 +277,13 @@ func (m *MMClient) WsReceiver() { | ||||
| 			// check if we didn't empty the message | ||||
| 			if msg.Text != "" { | ||||
| 				m.MessageChan <- msg | ||||
| 				continue | ||||
| 			} | ||||
| 			// if we have file attached but the message is empty, also send it | ||||
| 			if msg.Post != nil { | ||||
| 				if msg.Text != "" || len(msg.Post.FileIds) > 0 { | ||||
| 					m.MessageChan <- msg | ||||
| 				} | ||||
| 			} | ||||
| 			continue | ||||
| 		} | ||||
| @@ -600,9 +607,9 @@ func (m *MMClient) createCookieJar(token string) *cookiejar.Jar { | ||||
| func (m *MMClient) SendDirectMessage(toUserId string, msg string) { | ||||
| 	m.log.Debugf("SendDirectMessage to %s, msg %s", toUserId, msg) | ||||
| 	// create DM channel (only happens on first message) | ||||
| 	_, err := m.Client.CreateDirectChannel(m.User.Id, toUserId) | ||||
| 	if err != nil { | ||||
| 		m.log.Debugf("SendDirectMessage to %#v failed: %s", toUserId, err) | ||||
| 	_, resp := m.Client.CreateDirectChannel(m.User.Id, toUserId) | ||||
| 	if resp.Error != nil { | ||||
| 		m.log.Debugf("SendDirectMessage to %#v failed: %s", toUserId, resp.Error) | ||||
| 		return | ||||
| 	} | ||||
| 	channelName := model.GetDMNameFromIds(toUserId, m.User.Id) | ||||
| @@ -854,7 +861,8 @@ func supportedVersion(version string) bool { | ||||
| 		strings.HasPrefix(version, "3.9.0") || | ||||
| 		strings.HasPrefix(version, "3.10.0") || | ||||
| 		strings.HasPrefix(version, "4.0") || | ||||
| 		strings.HasPrefix(version, "4.1") { | ||||
| 		strings.HasPrefix(version, "4.1") || | ||||
| 		strings.HasPrefix(version, "4.2") { | ||||
| 		return true | ||||
| 	} | ||||
| 	return false | ||||
|   | ||||
		Reference in New Issue
	
	Block a user