Compare commits
No commits in common. "b5420da560c33e56f32b3b16b14349f362a6259f" and "c75f36a12666186479b813d9746fb9cfe122f9cc" have entirely different histories.
b5420da560
...
c75f36a126
3 changed files with 2 additions and 41 deletions
2
go.mod
2
go.mod
|
@ -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.4.0
|
||||
mcmillian.dev/go/woodstock v0.3.1
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -28,5 +28,3 @@ 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.4.0 h1:3ROqcfnfuihKMcyQ3TsaP4Z1vACEjEyvwtBM2HYfuhc=
|
||||
mcmillian.dev/go/woodstock v0.4.0/go.mod h1:1CUHYZ1VUVX22aCcG9Pc/W9ZnwtFzHoyN4YHaAguO/I=
|
||||
|
|
|
@ -181,42 +181,6 @@ func pnutMsgHandler(conf *Config, msg woodstock.Message) {
|
|||
for _, v := range msg.Content.Entities.Links {
|
||||
linktext = "| " + linktext + v.URL + "\n"
|
||||
}
|
||||
for rawtype, value := range msg.Raw {
|
||||
if rawtype == "io.pnut.core.oembed" {
|
||||
for _, v := range value {
|
||||
var embed woodstock.RawEmbed
|
||||
byteData, _ := json.Marshal(v)
|
||||
jerr := json.Unmarshal(byteData, &embed)
|
||||
if jerr != nil {
|
||||
log.Println("Error unmarshaling raw", jerr)
|
||||
}
|
||||
switch embed.Type {
|
||||
case "photo":
|
||||
var photo woodstock.PhotoEmbed
|
||||
jerr := json.Unmarshal(byteData, &photo)
|
||||
if jerr != nil {
|
||||
log.Println("Error unmarshaling photo", jerr)
|
||||
}
|
||||
linktext = linktext + "🖼️\n" + photo.URL + "\n"
|
||||
case "video":
|
||||
var video woodstock.VideoEmbed
|
||||
jerr := json.Unmarshal(byteData, &video)
|
||||
if jerr != nil {
|
||||
log.Println("Error unmarshaling video", jerr)
|
||||
}
|
||||
linktext = linktext + "📽️\n" + video.URL + "\n"
|
||||
case "audio":
|
||||
var audio woodstock.AudioEmbed
|
||||
jerr := json.Unmarshal(byteData, &audio)
|
||||
if jerr != nil {
|
||||
log.Println("Error unmarshaling audio", jerr)
|
||||
}
|
||||
linktext = linktext + "🔈\n" + audio.URL + "\n"
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(linktext) > 0 {
|
||||
msgtext = msgtext + "\n\n" + linktext
|
||||
}
|
||||
|
@ -298,7 +262,7 @@ func bridgeMsgHandler(conf *Config, msg MbMessage) {
|
|||
line := msg.Username + " " + line
|
||||
log.Printf(">> sending message from %s to channel %s ...", msg.Gateway, channelID)
|
||||
newmessage := woodstock.NewMessage{Text: line, Raw: raw}
|
||||
_, err := client.CreateMessage(channelID, newmessage, url.Values{})
|
||||
_, err := client.CreateMessage(channelID, newmessage)
|
||||
if err != nil {
|
||||
log.Println("!! problem posting message to pnut.io", err)
|
||||
}
|
||||
|
@ -352,7 +316,6 @@ func main() {
|
|||
|
||||
params := url.Values{}
|
||||
params.Set("access_token", conf.PnutAccessToken)
|
||||
params.Set("include_raw", "1")
|
||||
|
||||
socketURL := "wss://stream.pnut.io/v1/user?" + params.Encode()
|
||||
conn, _, err := websocket.DefaultDialer.Dial(socketURL, nil)
|
||||
|
|
Loading…
Reference in a new issue