alaingilbert / ttapi Goto Github PK
View Code? Open in Web Editor NEWGolang Turntable.fm api
Home Page: https://pkg.go.dev/github.com/alaingilbert/ttapi
License: MIT License
Golang Turntable.fm api
Home Page: https://pkg.go.dev/github.com/alaingilbert/ttapi
License: MIT License
Hey, think I debugged this issue down to the root cause. Right now it looks like ttapi is only sending a presence update when it receives a heartbeat message from the server or when there is no session. From inspecting the web traffic in Chrome we should actually be sending the presence update every 10 seconds (or whatever interval the server is returning). I see right now by inspecting the websocket from Chrome that I am normally sending a presence update every 10 seconds as seen below:
I see in the logrus output when I turn on debug logs that every time ttapi sends out a presence update that a message is returned with an interval that ttapi is then not using:
DEBU[0135] < {"api":"presence.update","client":"web","clientid":"dunno_if_this_is_secret","msgid":20,"status":"available","userauth":"edited_this_out","userid":"edited_this_out_too"}
DEBU[0135] > ~m~72~m~{"msgid": 20, "now": 1623878255.079107, "success": true, "interval": 10}
Can we update ttapi to send the presence update at the correct interval? I believe that should fix the issue. For now I just started a goroutine that is sending a presence update manually every 10 seconds and that fixed the issue but I feel like ttapi should properly fix this as well for anyone else that wants to use this library.
Hi there,
I don't know why, but while I can process other events without problems, I get this error when I try to consume the OnNoSong
:
bot.OnNoSong(func(e ttapi.NoSongEvt) { /* do something */ })
Here's the error:
ERRO[0453] unexpected crashinterface conversion: interface {} is func(ttapi.NoSongEvt), not func(ttapi.H)
goroutine 100 [running]:
runtime/debug.Stack()
/.asdf/installs/golang/1.18rc1/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
/.asdf/installs/golang/1.18rc1/go/src/runtime/debug/stack.go:16 +0x19
github.com/alaingilbert/ttapi.SGo.func1.1()
/Code/go-code/pkg/mod/github.com/alaingilbert/[email protected]/utils.go:24 +0x76
panic({0x123f0a0, 0xc000114960})
/.asdf/installs/golang/1.18rc1/go/src/runtime/panic.go:838 +0x207
github.com/alaingilbert/ttapi.(*Bot).emit.func1.17()
/Code/go-code/pkg/mod/github.com/alaingilbert/[email protected]/ttapi.go:514 +0x4d
github.com/alaingilbert/ttapi.SGo.func1()
/Code/go-code/pkg/mod/github.com/alaingilbert/[email protected]/utils.go:27 +0x3f
created by github.com/alaingilbert/ttapi.SGo
/Code/go-code/pkg/mod/github.com/alaingilbert/[email protected]/utils.go:20 +0x56
I'm using go1.18rc1 darwin/amd64
.
On a side note, is there a reason for not having a struct like EndSongEvt
for OnEndSong
? Why it uses the map H
?
thanks in advance! :-)
I am looking at trying to check the endsong event and I noticed that on startup the first endsong event we get has different data than after we have already been running. I narrowed the issue down to this line: https://github.com/alaingilbert/ttapi/blob/master/ttapi.go#L286 In my initial testing I changed that line to be b.setTmpSong(roomInfoHash["room"].(map[string]interface{}))
to match what is sent for normal song changes here: https://github.com/alaingilbert/ttapi/blob/master/ttapi.go#L219 With that hacky fix I can always get the same json map that I can parse the same way both time. I know there should be some error checking in the fix and not sure how you want to handle that, but if we could get the startup info to match the song change info that would fix the issue I am having parsing the endsong event correctly every time.
With the latest code I am seeing an issue where I hit the error print failed to find message length
a lot. It looks like the commit 5b76c84 is the culprit for why this is happening. I see the error on what looks like data from the room.info
API call which is very large. If I revert the above commit back to the old handling for the websocket I no longer see the issue. I can reproduce the issue pretty easily by PM'ing the bot a super large message (i.e. ~20 lorem ipsums) and see that the websocket seems to split up the large message over multiple websocket messages. Since you removed the check for if we did not receive the full message length we eventually get a websocket message without the length header at the beginning.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.