4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-27 04:09:24 +00:00

Compare commits

...

13 Commits

19 changed files with 178 additions and 25 deletions

View File

@ -42,7 +42,7 @@ Accounts to one of the supported bridges
# Installing # Installing
## Binaries ## Binaries
Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/) Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/)
* Latest stable release [v0.14.0](https://github.com/42wim/matterbridge/releases/latest) * Latest stable release [v0.15.0](https://github.com/42wim/matterbridge/releases/latest)
## Building ## Building
Go 1.6+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed, including setting up your [GOPATH] (https://golang.org/doc/code.html#GOPATH) Go 1.6+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed, including setting up your [GOPATH] (https://golang.org/doc/code.html#GOPATH)

View File

@ -21,6 +21,7 @@ type Api struct {
type ApiMessage struct { type ApiMessage struct {
Text string `json:"text"` Text string `json:"text"`
Username string `json:"username"` Username string `json:"username"`
UserID string `json:"userid"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
Gateway string `json:"gateway"` Gateway string `json:"gateway"`
} }
@ -81,6 +82,7 @@ func (b *Api) handlePostMessage(c echo.Context) error {
b.Remote <- config.Message{ b.Remote <- config.Message{
Text: message.Text, Text: message.Text,
Username: message.Username, Username: message.Username,
UserID: message.UserID,
Channel: "api", Channel: "api",
Avatar: message.Avatar, Avatar: message.Avatar,
Account: b.Account, Account: b.Account,

View File

@ -19,6 +19,7 @@ type Message struct {
Text string `json:"text"` Text string `json:"text"`
Channel string `json:"channel"` Channel string `json:"channel"`
Username string `json:"username"` Username string `json:"username"`
UserID string `json:"userid"` // userid on the bridge
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
Account string `json:"account"` Account string `json:"account"`
Event string `json:"event"` Event string `json:"event"`
@ -44,6 +45,7 @@ type Protocol struct {
EditDisable bool // mattermost, slack, discord, telegram, gitter EditDisable bool // mattermost, slack, discord, telegram, gitter
IconURL string // mattermost, slack IconURL string // mattermost, slack
IgnoreNicks string // all protocols IgnoreNicks string // all protocols
IgnoreMessages string // all protocols
Jid string // xmpp Jid string // xmpp
Login string // mattermost, matrix Login string // mattermost, matrix
Muc string // xmpp Muc string // xmpp

View File

@ -142,7 +142,8 @@ func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
m.Message.Content = b.stripCustomoji(m.Message.Content) m.Message.Content = b.stripCustomoji(m.Message.Content)
m.Message.Content = b.replaceChannelMentions(m.Message.Content) m.Message.Content = b.replaceChannelMentions(m.Message.Content)
b.Remote <- config.Message{Username: username, Text: m.ContentWithMentionsReplaced(), Channel: channelName, b.Remote <- config.Message{Username: username, Text: m.ContentWithMentionsReplaced(), Channel: channelName,
Account: b.Account, 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",
UserID: m.Author.ID}
} }
func (b *bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { func (b *bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
@ -169,10 +170,11 @@ func (b *bdiscord) getNick(user *discordgo.User) string {
} }
} }
// if we didn't find nick, search for it // if we didn't find nick, search for it
b.userMemberMap[user.ID], err = b.c.GuildMember(b.guildID, user.ID) member, err := b.c.GuildMember(b.guildID, user.ID)
if err != nil { if err != nil {
return user.Username return user.Username
} }
b.userMemberMap[user.ID] = member
// only return if nick is set // only return if nick is set
if b.userMemberMap[user.ID].Nick != "" { if b.userMemberMap[user.ID].Nick != "" {
return b.userMemberMap[user.ID].Nick return b.userMemberMap[user.ID].Nick

View File

@ -82,7 +82,7 @@ func (b *Bgitter) JoinChannel(channel string) error {
if !strings.HasSuffix(ev.Message.Text, "") { if !strings.HasSuffix(ev.Message.Text, "") {
flog.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.Account) flog.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.Account)
b.Remote <- config.Message{Username: ev.Message.From.Username, Text: ev.Message.Text, Channel: room, b.Remote <- config.Message{Username: ev.Message.From.Username, Text: ev.Message.Text, Channel: room,
Account: b.Account, Avatar: b.getAvatar(ev.Message.From.Username)} Account: b.Account, Avatar: b.getAvatar(ev.Message.From.Username), UserID: ev.Message.From.ID}
} }
case *gitter.GitterConnectionClosed: case *gitter.GitterConnectionClosed:
flog.Errorf("connection with gitter closed for room %s", room) flog.Errorf("connection with gitter closed for room %s", room)

View File

@ -23,6 +23,7 @@ type Birc struct {
connected chan struct{} connected chan struct{}
Local chan config.Message // local queue for flood control Local chan config.Message // local queue for flood control
Account string Account string
FirstConnection bool
} }
var flog *log.Entry var flog *log.Entry
@ -49,6 +50,7 @@ func New(cfg config.Protocol, account string, c chan config.Message) *Birc {
if b.Config.MessageLength == 0 { if b.Config.MessageLength == 0 {
b.Config.MessageLength = 400 b.Config.MessageLength = 400
} }
b.FirstConnection = true
return b return b
} }
@ -74,6 +76,8 @@ func (b *Birc) Connect() error {
i.SASLLogin = b.Config.NickServNick i.SASLLogin = b.Config.NickServNick
i.SASLPassword = b.Config.NickServPassword i.SASLPassword = b.Config.NickServPassword
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.SkipTLSVerify} i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.SkipTLSVerify}
i.KeepAlive = time.Minute
i.PingFreq = time.Minute
if b.Config.Password != "" { if b.Config.Password != "" {
i.Password = b.Config.Password i.Password = b.Config.Password
} }
@ -90,6 +94,14 @@ func (b *Birc) Connect() error {
return fmt.Errorf("connection timed out") return fmt.Errorf("connection timed out")
} }
i.Debug = false i.Debug = false
// clear on reconnects
i.ClearCallback(ircm.RPL_WELCOME)
i.AddCallback(ircm.RPL_WELCOME, func(event *irc.Event) {
b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
// set our correct nick on reconnect if necessary
b.Nick = event.Nick
})
go i.Loop()
go b.doSend() go b.doSend()
return nil return nil
} }
@ -192,8 +204,11 @@ func (b *Birc) handleJoinPart(event *irc.Event) {
return return
} }
} }
if event.Nick != b.Nick {
flog.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account) flog.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account)
b.Remote <- config.Message{Username: "system", Text: event.Nick + " " + strings.ToLower(event.Code) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE} b.Remote <- config.Message{Username: "system", Text: event.Nick + " " + strings.ToLower(event.Code) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
return
}
flog.Debugf("handle %#v", event) flog.Debugf("handle %#v", event)
} }
@ -214,6 +229,11 @@ func (b *Birc) handleOther(event *irc.Event) {
} }
func (b *Birc) handlePrivMsg(event *irc.Event) { func (b *Birc) handlePrivMsg(event *irc.Event) {
b.Nick = b.i.GetNick()
// freenode doesn't send 001 as first reply
if event.Code == "NOTICE" {
return
}
// don't forward queries to the bot // don't forward queries to the bot
if event.Arguments[0] == b.Nick { if event.Arguments[0] == b.Nick {
return return
@ -232,7 +252,7 @@ func (b *Birc) handlePrivMsg(event *irc.Event) {
re := regexp.MustCompile(`[[:cntrl:]](\d+,|)\d+`) re := regexp.MustCompile(`[[:cntrl:]](\d+,|)\d+`)
msg = re.ReplaceAllString(msg, "") msg = re.ReplaceAllString(msg, "")
flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.Account) flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.Account)
b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Account: b.Account} b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Account: b.Account, UserID: event.User + "@" + event.Host}
} }
func (b *Birc) handleTopicWhoTime(event *irc.Event) { func (b *Birc) handleTopicWhoTime(event *irc.Event) {

View File

@ -109,7 +109,7 @@ func (b *Bmatrix) handlematrix() error {
username = re.ReplaceAllString(username, `$1`) username = re.ReplaceAllString(username, `$1`)
} }
flog.Debugf("Sending message from %s on %s to gateway", ev.Sender, b.Account) flog.Debugf("Sending message from %s on %s to gateway", ev.Sender, b.Account)
b.Remote <- config.Message{Username: username, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account} b.Remote <- config.Message{Username: username, Text: ev.Content["body"].(string), Channel: channel, Account: b.Account, UserID: ev.Sender}
} }
flog.Debugf("Received: %#v", ev) flog.Debugf("Received: %#v", ev)
}) })

View File

@ -21,6 +21,7 @@ type MMMessage struct {
Text string Text string
Channel string Channel string
Username string Username string
UserID string
} }
type Bmattermost struct { type Bmattermost struct {
@ -127,7 +128,7 @@ func (b *Bmattermost) handleMatter() {
} }
for message := range mchan { for message := range mchan {
flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
b.Remote <- config.Message{Text: message.Text, Username: message.Username, Channel: message.Channel, Account: b.Account} b.Remote <- config.Message{Text: message.Text, Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID}
} }
} }
@ -141,12 +142,16 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) {
b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE} b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
continue continue
} }
if (message.Raw.Event == "post_edited") && b.Config.EditDisable {
continue
}
// do not post our own messages back to irc // do not post our own messages back to irc
// only listen to message from our team // only listen to message from our team
if (message.Raw.Event == "posted" || message.Raw.Event == "post_edited") && if (message.Raw.Event == "posted" || message.Raw.Event == "post_edited") &&
b.mc.User.Username != message.Username && message.Raw.Data["team_id"].(string) == b.TeamId { b.mc.User.Username != message.Username && message.Raw.Data["team_id"].(string) == b.TeamId {
flog.Debugf("Receiving from matterclient %#v", message) flog.Debugf("Receiving from matterclient %#v", message)
m := &MMMessage{} m := &MMMessage{}
m.UserID = message.UserID
m.Username = message.Username m.Username = message.Username
m.Channel = message.Channel m.Channel = message.Channel
m.Text = message.Text m.Text = message.Text
@ -168,6 +173,7 @@ func (b *Bmattermost) handleMatterHook(mchan chan *MMMessage) {
message := b.mh.Receive() message := b.mh.Receive()
flog.Debugf("Receiving from matterhook %#v", message) flog.Debugf("Receiving from matterhook %#v", message)
m := &MMMessage{} m := &MMMessage{}
m.UserID = message.UserID
m.Username = message.UserName m.Username = message.UserName
m.Text = message.Text m.Text = message.Text
m.Channel = message.ChannelName m.Channel = message.ChannelName

View File

@ -82,6 +82,6 @@ func (b *Brocketchat) handleRocketHook() {
continue continue
} }
flog.Debugf("Sending message from %s on %s to gateway", message.UserName, b.Account) flog.Debugf("Sending message from %s on %s to gateway", message.UserName, b.Account)
b.Remote <- config.Message{Text: message.Text, Username: message.UserName, Channel: message.ChannelName, Account: b.Account} b.Remote <- config.Message{Text: message.Text, Username: message.UserName, Channel: message.ChannelName, Account: b.Account, UserID: message.UserID}
} }
} }

View File

@ -15,6 +15,7 @@ type MMMessage struct {
Text string Text string
Channel string Channel string
Username string Username string
UserID string
Raw *slack.MessageEvent Raw *slack.MessageEvent
} }
@ -185,7 +186,7 @@ func (b *Bslack) handleSlack() {
texts := strings.Split(message.Text, "\n") texts := strings.Split(message.Text, "\n")
for _, text := range texts { for _, text := range texts {
flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
b.Remote <- config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username)} b.Remote <- config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID}
} }
} }
} }
@ -213,6 +214,7 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
continue continue
} }
m := &MMMessage{} m := &MMMessage{}
m.UserID = user.ID
m.Username = user.Name m.Username = user.Name
m.Channel = channel.Name m.Channel = channel.Name
m.Text = ev.Text m.Text = ev.Text

View File

@ -114,9 +114,31 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
if username == "" { if username == "" {
username = "unknown" username = "unknown"
} }
if message.Sticker != nil {
text = text + " " + b.getFileDirectURL(message.Sticker.FileID)
}
if message.Video != nil {
text = text + " " + b.getFileDirectURL(message.Video.FileID)
}
if message.Photo != nil {
photos := *message.Photo
// last photo is the biggest
text = text + " " + b.getFileDirectURL(photos[len(photos)-1].FileID)
}
if message.Document != nil {
text = text + " " + message.Document.FileName + " : " + b.getFileDirectURL(message.Document.FileID)
}
if text != "" { if text != "" {
flog.Debugf("Sending message from %s on %s to gateway", username, b.Account) flog.Debugf("Sending message from %s on %s to gateway", username, b.Account)
b.Remote <- config.Message{Username: username, Text: text, Channel: channel, Account: b.Account} b.Remote <- config.Message{Username: username, Text: text, Channel: channel, Account: b.Account, UserID: strconv.Itoa(message.From.ID)}
} }
} }
} }
func (b *Btelegram) getFileDirectURL(id string) string {
res, err := b.c.GetFileDirectURL(id)
if err != nil {
return ""
}
return res
}

View File

@ -128,7 +128,7 @@ func (b *Bxmpp) handleXmpp() error {
} }
if nick != b.Config.Nick && v.Stamp == nodelay && v.Text != "" { if nick != b.Config.Nick && v.Stamp == nodelay && v.Text != "" {
flog.Debugf("Sending message from %s on %s to gateway", nick, b.Account) flog.Debugf("Sending message from %s on %s to gateway", nick, b.Account)
b.Remote <- config.Message{Username: nick, Text: v.Text, Channel: channel, Account: b.Account} b.Remote <- config.Message{Username: nick, Text: v.Text, Channel: channel, Account: b.Account, UserID: v.Remote}
} }
} }
case xmpp.Presence: case xmpp.Presence:

View File

@ -1,3 +1,20 @@
# v0.15.0
## New features
* general: add option IgnoreMessages for all protocols (see mattebridge.toml.sample)
Messages matching these regexp will be ignored and not sent to other bridges
e.g. IgnoreMessages="^~~ badword"
* telegram: add support for sticker/video/photo/document #184
## Changes
* api: add userid to each message #200
## Bugfix
* discord: fix crash in memberupdate #198
* mattermost: Fix incorrect behaviour of EditDisable (mattermost). Fixes #197
* irc: Do not relay join/part of ourselves (irc). Closes #190
* irc: make reconnections more robust. #153
* gitter: update library, fixes possible crash
# v0.14.0 # v0.14.0
## New features ## New features
* api: add token authentication * api: add token authentication

View File

@ -5,6 +5,7 @@ import (
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"regexp"
"strings" "strings"
"time" "time"
) )
@ -230,6 +231,20 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
return true return true
} }
} }
// TODO do not compile regexps everytime
for _, entry := range strings.Fields(gw.Bridges[msg.Account].Config.IgnoreMessages) {
if entry != "" {
re, err := regexp.Compile(entry)
if err != nil {
log.Errorf("incorrect regexp %s for %s", entry, msg.Account)
continue
}
if re.MatchString(msg.Text) {
log.Debugf("matching %s. ignoring %s from %s", entry, msg.Text, msg.Account)
return true
}
}
}
return false return false
} }

View File

@ -12,7 +12,7 @@ import (
) )
var ( var (
version = "0.14.0" version = "0.15.0"
githash string githash string
) )

View File

@ -63,6 +63,12 @@ MessageLength=400
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -115,6 +121,12 @@ SkipTLSVerify=true
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -159,6 +171,12 @@ Nick="yourlogin"
#OPTIONAL #OPTIONAL
IgnoreNicks="spammer1 spammer2" IgnoreNicks="spammer1 spammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -261,6 +279,12 @@ EditSuffix=" (edited)"
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -294,6 +318,12 @@ Token="Yourtokenhere"
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -383,6 +413,12 @@ PrefixMessagesWithNick=false
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -427,6 +463,12 @@ EditSuffix=" (edited)"
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -477,6 +519,12 @@ EditSuffix=" (edited)"
#OPTIONAL #OPTIONAL
IgnoreNicks="spammer1 spammer2" IgnoreNicks="spammer1 spammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -535,6 +583,12 @@ PrefixMessagesWithNick=false
#OPTIONAL #OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2" IgnoreNicks="ircspammer1 ircspammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -584,6 +638,12 @@ PrefixMessagesWithNick=false
#OPTIONAL #OPTIONAL
IgnoreNicks="spammer1 spammer2" IgnoreNicks="spammer1 spammer2"
#Messages you want to ignore.
#Messages matching these regexp will be ignored and not sent to other bridges
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword"
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -681,7 +741,7 @@ enable=true
#telegram - chatid (a large negative number, eg -123456789) #telegram - chatid (a large negative number, eg -123456789)
# see (https://www.linkedin.com/pulse/telegram-bots-beginners-marco-frau) # see (https://www.linkedin.com/pulse/telegram-bots-beginners-marco-frau)
#hipchat - id_channel (see https://www.hipchat.com/account/xmpp for the correct channel) #hipchat - id_channel (see https://www.hipchat.com/account/xmpp for the correct channel)
#rocketchat - #channel (# is required) #rocketchat - #channel (# is required (also needed for private channels!)
#matrix - #channel:server (eg #yourchannel:matrix.org) #matrix - #channel:server (eg #yourchannel:matrix.org)
# - encrypted rooms are not supported in matrix # - encrypted rooms are not supported in matrix
#REQUIRED #REQUIRED

View File

@ -37,6 +37,7 @@ type Message struct {
Username string Username string
Text string Text string
Type string Type string
UserID string
} }
type Team struct { type Team struct {
@ -290,6 +291,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) {
} }
rmsg.Username = m.GetUserName(data.UserId) rmsg.Username = m.GetUserName(data.UserId)
rmsg.Channel = m.GetChannelName(data.ChannelId) rmsg.Channel = m.GetChannelName(data.ChannelId)
rmsg.UserID = data.UserId
rmsg.Type = data.Type rmsg.Type = data.Type
teamid, _ := rmsg.Raw.Data["team_id"].(string) teamid, _ := rmsg.Raw.Data["team_id"].(string)
// edit messsages have no team_id for some reason // edit messsages have no team_id for some reason

View File

@ -137,7 +137,10 @@ func (stream *Stream) connect() {
res, err := stream.gitter.getResponse(stream.url, stream) res, err := stream.gitter.getResponse(stream.url, stream)
if err != nil || res.StatusCode != 200 { if err != nil || res.StatusCode != 200 {
stream.gitter.log(fmt.Sprintf("Failed to get response, trying reconnect (Status code: %v)", res.StatusCode)) stream.gitter.log("Failed to get response, trying reconnect")
if res != nil {
stream.gitter.log(fmt.Sprintf("Status code: %v", res.StatusCode))
}
stream.gitter.log(err) stream.gitter.log(err)
// sleep and wait // sleep and wait

2
vendor/manifest vendored
View File

@ -384,7 +384,7 @@
"importpath": "github.com/sromku/go-gitter", "importpath": "github.com/sromku/go-gitter",
"repository": "https://github.com/sromku/go-gitter", "repository": "https://github.com/sromku/go-gitter",
"vcs": "git", "vcs": "git",
"revision": "0b9f26da1844acd3c6c2fd4ee2bdd30eb1a40568", "revision": "16aadfbb65c6641501ea8eebb6bcf23b9011912b",
"branch": "master", "branch": "master",
"notests": true "notests": true
}, },