Include embedded links from pnut messages being sent to bridge
All checks were successful
thrrgilag/pnut-bridge/pipeline/pr-main This commit looks good

Resolves issue #1
This commit is contained in:
Morgan McMillian 2023-12-10 10:07:23 -08:00
parent 18698a578e
commit 9c019a3abf
3 changed files with 11 additions and 12 deletions

View file

@ -1,6 +1,6 @@
MIT 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -2,20 +2,13 @@
A [matterbridge] API plugin allowing you to connect message channels on [pnut.io] to other supported chat services. 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 ## License
``` ```
MIT 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -38,5 +31,3 @@ SOFTWARE.
[matterbridge]: https://github.com/42wim/matterbridge [matterbridge]: https://github.com/42wim/matterbridge
[pnut.io]: https://pnut.io [pnut.io]: https://pnut.io
[email]: https://morgan.mcmillian.dev/contact
[#devel:mcmillian.ems.host]: https://matrix.to/#/#devel:mcmillian.ems.host

View file

@ -176,9 +176,17 @@ func pnutMsgHandler(conf *Config, msg woodstock.Message) {
if msg.User.Username == conf.PnutUsername { if msg.User.Username == conf.PnutUsername {
return 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) log.Printf(">> sending message from channel %s to %s ...", msg.ChannelID, gateway)
data := MbOutMsg{ data := MbOutMsg{
Text: msg.Content.Text, Text: msgtext,
Username: msg.User.Username, Username: msg.User.Username,
Gateway: gateway, Gateway: gateway,
} }