mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 18:59:24 +00:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
08f442dc7b | |||
8a8b95228c | |||
31a752fa21 | |||
a83831e68d | |||
a12a8d4fe2 | |||
e57f3a7e6c | |||
68fbed9281 | |||
8bfaa007d5 | |||
76360f89c1 | |||
d525230abd | |||
b4aa637d41 | |||
7c4334d0de | |||
062be8d7c9 | |||
db25ee59c5 |
@ -43,6 +43,8 @@ script:
|
||||
|
||||
deploy:
|
||||
provider: bintray
|
||||
edge:
|
||||
branch: v1.8.47
|
||||
file: ci/deploy.json
|
||||
user: 42wim
|
||||
key:
|
||||
|
@ -65,7 +65,7 @@ See https://github.com/42wim/matterbridge/wiki
|
||||
|
||||
# Installing
|
||||
## Binaries
|
||||
* Latest stable release [v1.9.0](https://github.com/42wim/matterbridge/releases/latest)
|
||||
* Latest stable release [v1.9.1](https://github.com/42wim/matterbridge/releases/latest)
|
||||
* Development releases (follows master) can be downloaded [here](https://dl.bintray.com/42wim/nightly/)
|
||||
|
||||
## Building
|
||||
|
@ -92,6 +92,7 @@ type Protocol struct {
|
||||
Password string // IRC,mattermost,XMPP,matrix
|
||||
PrefixMessagesWithNick bool // mattemost, slack
|
||||
Protocol string // all protocols
|
||||
QuoteDisable bool // telegram
|
||||
RejoinDelay int // IRC
|
||||
ReplaceMessages [][]string // all protocols
|
||||
ReplaceNicks [][]string // all protocols
|
||||
|
@ -80,6 +80,9 @@ func (b *Bdiscord) Connect() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, channel := range b.Channels {
|
||||
b.Log.Debugf("found channel %#v", channel)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -127,6 +130,12 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
b.Log.Debugf("Broadcasting using Webhook")
|
||||
for _, f := range msg.Extra["file"] {
|
||||
fi := f.(config.FileInfo)
|
||||
if fi.URL != "" {
|
||||
msg.Text += fi.URL + " "
|
||||
}
|
||||
}
|
||||
err := b.c.WebhookExecute(
|
||||
wID,
|
||||
wToken,
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -88,3 +89,14 @@ func HandleDownloadData(flog *log.Entry, msg *config.Message, name, comment, url
|
||||
}
|
||||
msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data, URL: url, Comment: comment, Avatar: avatar})
|
||||
}
|
||||
|
||||
func RemoveEmptyNewLines(msg string) string {
|
||||
lines := ""
|
||||
for _, line := range strings.Split(msg, "\n") {
|
||||
if line != "" {
|
||||
lines += line + "\n"
|
||||
}
|
||||
}
|
||||
lines = strings.TrimRight(lines, "\n")
|
||||
return lines
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) {
|
||||
// this sends a message only if we received a config.EVENT_FILE_FAILURE_SIZE
|
||||
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
|
||||
matterMessage := matterhook.OMessage{IconURL: b.GetString("IconURL"), Channel: rmsg.Channel, UserName: rmsg.Username, Text: rmsg.Text, Props: make(map[string]interface{})}
|
||||
matterMessage.Props["matterbridge"] = true
|
||||
matterMessage.Props["matterbridge_"+b.mc.User.Id] = true
|
||||
b.mh.Send(matterMessage)
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) {
|
||||
if msg.Avatar != "" {
|
||||
matterMessage.IconURL = msg.Avatar
|
||||
}
|
||||
matterMessage.Props["matterbridge"] = true
|
||||
matterMessage.Props["matterbridge_"+b.mc.User.Id] = true
|
||||
err := b.mh.Send(matterMessage)
|
||||
if err != nil {
|
||||
b.Log.Info(err)
|
||||
@ -415,7 +415,7 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool {
|
||||
|
||||
// Ignore messages sent from matterbridge
|
||||
if message.Post.Props != nil {
|
||||
if _, ok := message.Post.Props["matterbridge"].(bool); ok {
|
||||
if _, ok := message.Post.Props["matterbridge_"+b.mc.User.Id].(bool); ok {
|
||||
b.Log.Debugf("sent by matterbridge, ignoring")
|
||||
return true
|
||||
}
|
||||
|
@ -4,16 +4,17 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/42wim/matterbridge/bridge/helper"
|
||||
"github.com/42wim/matterbridge/matterhook"
|
||||
"github.com/nlopes/slack"
|
||||
"html"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/42wim/matterbridge/bridge/helper"
|
||||
"github.com/42wim/matterbridge/matterhook"
|
||||
"github.com/nlopes/slack"
|
||||
)
|
||||
|
||||
type Bslack struct {
|
||||
@ -176,7 +177,7 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
|
||||
np.IconURL = msg.Avatar
|
||||
}
|
||||
// add a callback ID so we can see we created it
|
||||
np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"})
|
||||
np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge_" + b.si.User.ID})
|
||||
// add file attachments
|
||||
np.Attachments = append(np.Attachments, b.createAttach(msg.Extra)...)
|
||||
// add slack attachments (from another slack bridge)
|
||||
@ -387,7 +388,11 @@ func (b *Bslack) replaceVariable(text string) string {
|
||||
func (b *Bslack) replaceURL(text string) string {
|
||||
results := regexp.MustCompile(`<(.*?)(\|.*?)?>`).FindAllStringSubmatch(text, -1)
|
||||
for _, r := range results {
|
||||
text = strings.Replace(text, r[0], r[1], -1)
|
||||
if len(strings.TrimSpace(r[2])) == 1 { // A display text separator was found, but the text was blank
|
||||
text = strings.Replace(text, r[0], "", -1)
|
||||
} else {
|
||||
text = strings.Replace(text, r[0], r[1], -1)
|
||||
}
|
||||
}
|
||||
return text
|
||||
}
|
||||
@ -639,7 +644,7 @@ func (b *Bslack) skipMessageEvent(ev *slack.MessageEvent) bool {
|
||||
|
||||
// skip messages we made ourselves
|
||||
if len(ev.Attachments) > 0 {
|
||||
if ev.Attachments[0].CallbackID == "matterbridge" {
|
||||
if ev.Attachments[0].CallbackID == "matterbridge_"+b.si.User.ID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package btelegram
|
||||
|
||||
import (
|
||||
"html"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -222,10 +221,13 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
|
||||
if usernameReply == "" {
|
||||
usernameReply = "unknown"
|
||||
}
|
||||
rmsg.Text = rmsg.Text + " (re @" + usernameReply + ":" + message.ReplyToMessage.Text + ")"
|
||||
if !b.GetBool("QuoteDisable") {
|
||||
rmsg.Text = rmsg.Text + " (re @" + usernameReply + ":" + message.ReplyToMessage.Text + ")"
|
||||
}
|
||||
}
|
||||
|
||||
if rmsg.Text != "" || len(rmsg.Extra) > 0 {
|
||||
rmsg.Text = helper.RemoveEmptyNewLines(rmsg.Text)
|
||||
rmsg.Avatar = helper.GetAvatar(b.avatarMap, strconv.Itoa(message.From.ID), b.General)
|
||||
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
|
||||
@ -385,7 +387,6 @@ func (b *Btelegram) sendMessage(chatid int64, username, text string) (string, er
|
||||
m.Text = username + text
|
||||
if b.GetString("MessageFormat") == "HTML" {
|
||||
b.Log.Debug("Using mode HTML")
|
||||
username = html.EscapeString(username)
|
||||
m.Text = username + text
|
||||
m.ParseMode = tgbotapi.ModeHTML
|
||||
}
|
||||
|
12
changelog.md
12
changelog.md
@ -1,3 +1,15 @@
|
||||
# v1.9.1
|
||||
## New features
|
||||
* telegram: Add QuoteDisable option (telegram). Closes #399. See QuoteDisable in matterbridge.toml.sample
|
||||
## Enhancements
|
||||
* discord: Send mediaserver link to Discord in Webhook mode (discord) (#405)
|
||||
* mattermost: Print list of valid team names when team not found (#390)
|
||||
* slack: Strip markdown URLs with blank text (slack) (#392)
|
||||
## Bugfix
|
||||
* slack/mattermost: Make our callbackid more unique. Fixes issue with running multiple matterbridge on the same channel (slack,mattermost)
|
||||
* telegram: fix newlines in multiline messages #399
|
||||
* telegram: Revert #378
|
||||
|
||||
# v1.9.0 (the refactor release)
|
||||
## New features
|
||||
* general: better debug messages
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "1.9.0"
|
||||
version = "1.9.1"
|
||||
githash string
|
||||
)
|
||||
|
||||
|
@ -787,6 +787,10 @@ UseFirstName=false
|
||||
#OPTIONAL (default false)
|
||||
UseInsecureURL=false
|
||||
|
||||
#Disable quoted/reply messages
|
||||
#OPTIONAL (default false)
|
||||
QuoteDisable=false
|
||||
|
||||
#Disable sending of edits to other bridges
|
||||
#OPTIONAL (default false)
|
||||
EditDisable=false
|
||||
@ -832,6 +836,11 @@ Label=""
|
||||
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
|
||||
#The string "{LABEL}" (case sensitive) will be replaced by label= field of the sending bridge
|
||||
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
|
||||
#
|
||||
#WARNING: if you have set MessageFormat="HTML" be sure that this format matches the guidelines
|
||||
#on https://core.telegram.org/bots/api#html-style otherwise the message will not go through to
|
||||
#telegram! eg <{NICK}> should be <{NICK}>
|
||||
#
|
||||
#OPTIONAL (default empty)
|
||||
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
|
||||
|
||||
|
@ -190,7 +190,11 @@ func (m *MMClient) Login() error {
|
||||
}
|
||||
|
||||
if m.Team == nil {
|
||||
return errors.New("team not found")
|
||||
validTeamNames := make([]string, len(m.OtherTeams))
|
||||
for i, t := range m.OtherTeams {
|
||||
validTeamNames[i] = t.Team.Name
|
||||
}
|
||||
return fmt.Errorf("Team '%s' not found in %v", m.Credentials.Team, validTeamNames)
|
||||
}
|
||||
|
||||
m.wsConnect()
|
||||
@ -768,6 +772,14 @@ func (m *MMClient) GetStatus(userId string) string {
|
||||
return "offline"
|
||||
}
|
||||
|
||||
func (m *MMClient) UpdateStatus(userId string, status string) error {
|
||||
_, resp := m.Client.UpdateUserStatus(userId, &model.Status{Status: status})
|
||||
if resp.Error != nil {
|
||||
return resp.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) GetStatuses() map[string]string {
|
||||
var ids []string
|
||||
statuses := make(map[string]string)
|
||||
|
Reference in New Issue
Block a user