summaryrefslogtreecommitdiffstats
path: root/bridge/nctalk/nctalk.go
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2021-06-19 15:45:19 -0400
committerGitHub <noreply@github.com>2021-06-19 21:45:19 +0200
commita79e632cdc26f3870b0d8b37f9a94bdcf6f47711 (patch)
tree69a23944ef6ddec50340a2567fc895edec87991a /bridge/nctalk/nctalk.go
parentf36498421b7a3fbbe766c88bde4be656ab3a0b86 (diff)
downloadmatterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.tar.gz
matterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.tar.bz2
matterbridge-msglm-a79e632cdc26f3870b0d8b37f9a94bdcf6f47711.zip
Add support for separate display name (nctalk) (#1506)
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'bridge/nctalk/nctalk.go')
-rw-r--r--bridge/nctalk/nctalk.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go
index 9d0d4517..82acba4b 100644
--- a/bridge/nctalk/nctalk.go
+++ b/bridge/nctalk/nctalk.go
@@ -85,7 +85,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
}
// Ignore messages that are from the bot user
- if msg.ActorID == b.user.User {
+ if msg.ActorID == b.user.User || msg.ActorType == "bridged" {
continue
}
@@ -123,7 +123,7 @@ func (b *Btalk) Send(msg config.Message) (string, error) {
return "", nil
}
- sentMessage, err := r.room.SendMessage(msg.Username + msg.Text)
+ sentMessage, err := b.sendText(r, &msg, msg.Text)
if err != nil {
b.Log.Errorf("Could not send message to room %v from %v: %v", msg.Channel, msg.Username, err)
@@ -158,6 +158,17 @@ func (b *Btalk) getRoom(token string) *Broom {
return nil
}
+func (b *Btalk) sendText(r *Broom, msg *config.Message, text string) (*ocs.TalkRoomMessageData, error) {
+ messageToSend := &room.Message{Message: msg.Username + text}
+
+ if b.GetBool("SeparateDisplayName") {
+ messageToSend.Message = text
+ messageToSend.ActorDisplayName = msg.Username
+ }
+
+ return r.room.SendComplexMessage(messageToSend)
+}
+
func (b *Btalk) handleFiles(mmsg *config.Message, message *ocs.TalkRoomMessageData) error {
for _, parameter := range message.MessageParameters {
if parameter.Type == ocs.ROSTypeFile {
@@ -190,12 +201,12 @@ func (b *Btalk) handleSendingFile(msg *config.Message, r *Broom) error {
continue
}
- message := msg.Username
+ message := ""
if fi.Comment != "" {
message += fi.Comment + " "
}
message += fi.URL
- _, err := r.room.SendMessage(message)
+ _, err := b.sendText(r, msg, message)
if err != nil {
return err
}