From 9c019a3abfa5f7723329b4790fe4732c206f7bc8 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sun, 10 Dec 2023 10:07:23 -0800 Subject: [PATCH] Include embedded links from pnut messages being sent to bridge Resolves issue #1 --- LICENSE | 2 +- README.md | 11 +---------- pnut-bridge.go | 10 +++++++++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index 3906dbd..41c2357 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Morgan McMillian +Copyright (c) 2023 Morgan McMillian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 72d334e..7e71076 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,13 @@ A [matterbridge] API plugin allowing you to connect message channels on [pnut.io] to other supported chat services. -## Contributing - -Report bugs or submit patches via [email]. - -Join my public chat room for development discussion. - -- [#devel:mcmillian.ems.host] ## License ``` MIT License -Copyright (c) 2021 Morgan McMillian +Copyright (c) 2023 Morgan McMillian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -38,5 +31,3 @@ SOFTWARE. [matterbridge]: https://github.com/42wim/matterbridge [pnut.io]: https://pnut.io -[email]: https://morgan.mcmillian.dev/contact -[#devel:mcmillian.ems.host]: https://matrix.to/#/#devel:mcmillian.ems.host diff --git a/pnut-bridge.go b/pnut-bridge.go index 03e023e..e8c86e5 100644 --- a/pnut-bridge.go +++ b/pnut-bridge.go @@ -176,9 +176,17 @@ func pnutMsgHandler(conf *Config, msg woodstock.Message) { if msg.User.Username == conf.PnutUsername { return } + msgtext := msg.Content.Text + linktext := "" + for _, v := range msg.Content.Entities.Links { + linktext = "| " + linktext + v.URL + "\n" + } + if len(linktext) > 0 { + msgtext = msgtext + "\n\n" + linktext + } log.Printf(">> sending message from channel %s to %s ...", msg.ChannelID, gateway) data := MbOutMsg{ - Text: msg.Content.Text, + Text: msgtext, Username: msg.User.Username, Gateway: gateway, }