Compare commits

..

No commits in common. "c75f36a12666186479b813d9746fb9cfe122f9cc" and "165683ee9f8365a6b7625b89db37ce047dc02a6c" have entirely different histories.

5 changed files with 18 additions and 22 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Morgan McMillian
Copyright (c) 2021 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

View file

@ -2,13 +2,20 @@
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) 2023 Morgan McMillian
Copyright (c) 2021 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
@ -31,3 +38,5 @@ 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

2
go.mod
View file

@ -8,5 +8,5 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1
github.com/smartystreets/goconvey v1.6.4 // indirect
gopkg.in/ini.v1 v1.62.0
mcmillian.dev/go/woodstock v0.3.1
mcmillian.dev/go/woodstock v0.0.0-20220820203043-62b10b5c3c0d
)

4
go.sum
View file

@ -26,5 +26,5 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
mcmillian.dev/go/woodstock v0.3.1 h1:m88zZQ726dw+jBpPXhqbdeTXHL5/rnJ4g1MOzV+oMm0=
mcmillian.dev/go/woodstock v0.3.1/go.mod h1:1CUHYZ1VUVX22aCcG9Pc/W9ZnwtFzHoyN4YHaAguO/I=
mcmillian.dev/go/woodstock v0.0.0-20220820203043-62b10b5c3c0d h1:TTvGSHCAy5HsIV9p5ruxKX+C5XoJyQ/RlcWTmySV9SI=
mcmillian.dev/go/woodstock v0.0.0-20220820203043-62b10b5c3c0d/go.mod h1:1CUHYZ1VUVX22aCcG9Pc/W9ZnwtFzHoyN4YHaAguO/I=

View file

@ -17,11 +17,11 @@ import (
"strings"
"time"
"mcmillian.dev/go/woodstock"
"github.com/gabriel-vasile/mimetype"
"github.com/gorilla/websocket"
"github.com/mitchellh/go-wordwrap"
"gopkg.in/ini.v1"
"mcmillian.dev/go/woodstock"
)
var cfgfile *string
@ -109,11 +109,6 @@ type PnutOembed struct {
Height int `json:"height"`
}
type Raw struct {
Type string `json:"type"`
Value interface{} `json:"value"`
}
func subscribe(connectionID string, accessToken string, rooms []Room) {
params := url.Values{}
params.Set("connection_id", connectionID)
@ -176,17 +171,9 @@ 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: msgtext,
Text: msg.Content.Text,
Username: msg.User.Username,
Gateway: gateway,
}
@ -227,7 +214,7 @@ func bridgeMsgHandler(conf *Config, msg MbMessage) {
channelID := getPnutChannel(conf.Rooms, msg.Gateway)
text := msg.Text
var raw []Raw
var raw []woodstock.Raw
for _, file := range msg.Extra.File {
fdata, err := base64.StdEncoding.DecodeString(file.Data)
if err != nil {
@ -248,7 +235,7 @@ func bridgeMsgHandler(conf *Config, msg MbMessage) {
Width: im.Width,
Height: im.Height,
}
raw = append(raw, Raw{Type: "io.pnut.core.oembed", Value: oembed})
raw = append(raw, woodstock.Raw{Type: "io.pnut.core.oembed", Value: oembed})
} else {
text = text + "\n" + file.URL
}