forked from pothtonswer/discordmuffin
Merge branch 'develop' into 1
This commit is contained in:
commit
2f51bf4d58
6 changed files with 19 additions and 17 deletions
2
event.go
2
event.go
|
@ -224,7 +224,7 @@ func (s *Session) onInterface(i interface{}) {
|
||||||
case *VoiceStateUpdate:
|
case *VoiceStateUpdate:
|
||||||
go s.onVoiceStateUpdate(t)
|
go s.onVoiceStateUpdate(t)
|
||||||
}
|
}
|
||||||
err := s.State.onInterface(s, i)
|
err := s.State.OnInterface(s, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(LogDebug, "error dispatching internal event, %s", err)
|
s.log(LogDebug, "error dispatching internal event, %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1867,14 +1867,9 @@ func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string) (s
|
||||||
|
|
||||||
// WebhookDelete deletes a webhook for a given ID
|
// WebhookDelete deletes a webhook for a given ID
|
||||||
// webhookID: The ID of a webhook.
|
// webhookID: The ID of a webhook.
|
||||||
func (s *Session) WebhookDelete(webhookID string) (st *Webhook, err error) {
|
func (s *Session) WebhookDelete(webhookID string) (err error) {
|
||||||
|
|
||||||
body, err := s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks)
|
_, err = s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = unmarshal(body, &st)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
2
state.go
2
state.go
|
@ -783,7 +783,7 @@ func (s *State) onReady(se *Session, r *Ready) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// onInterface handles all events related to states.
|
// onInterface handles all events related to states.
|
||||||
func (s *State) onInterface(se *Session, i interface{}) (err error) {
|
func (s *State) OnInterface(se *Session, i interface{}) (err error) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return ErrNilState
|
return ErrNilState
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ type Presence struct {
|
||||||
type Game struct {
|
type Game struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals json to Game struct
|
// UnmarshalJSON unmarshals json to Game struct
|
||||||
|
|
10
voice.go
10
voice.go
|
@ -15,7 +15,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -660,8 +659,6 @@ func (v *VoiceConnection) opusSender(udpConn *net.UDPConn, close <-chan struct{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.LockOSThread()
|
|
||||||
|
|
||||||
// VoiceConnection is now ready to receive audio packets
|
// VoiceConnection is now ready to receive audio packets
|
||||||
// TODO: this needs reviewed as I think there must be a better way.
|
// TODO: this needs reviewed as I think there must be a better way.
|
||||||
v.Lock()
|
v.Lock()
|
||||||
|
@ -800,7 +797,7 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, skip anything except audio.
|
// For now, skip anything except audio.
|
||||||
if rlen < 12 || recvbuf[0] != 0x80 {
|
if rlen < 12 || (recvbuf[0] != 0x80 && recvbuf[0] != 0x90) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,6 +811,11 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
|
||||||
copy(nonce[:], recvbuf[0:12])
|
copy(nonce[:], recvbuf[0:12])
|
||||||
p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey)
|
p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey)
|
||||||
|
|
||||||
|
if len(p.Opus) > 8 && recvbuf[0] == 0x90 {
|
||||||
|
// Extension bit is set, first 8 bytes is the extended header
|
||||||
|
p.Opus = p.Opus[8:]
|
||||||
|
}
|
||||||
|
|
||||||
if c != nil {
|
if c != nil {
|
||||||
select {
|
select {
|
||||||
case c <- &p:
|
case c <- &p:
|
||||||
|
|
11
wsapi.go
11
wsapi.go
|
@ -250,8 +250,10 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateStatusData struct {
|
type updateStatusData struct {
|
||||||
IdleSince *int `json:"idle_since"`
|
IdleSince *int `json:"since"`
|
||||||
Game *Game `json:"game"`
|
Game *Game `json:"game"`
|
||||||
|
AFK bool `json:"afk"`
|
||||||
|
Status string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateStatusOp struct {
|
type updateStatusOp struct {
|
||||||
|
@ -274,7 +276,10 @@ func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err
|
||||||
return ErrWSNotFound
|
return ErrWSNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
var usd updateStatusData
|
usd := updateStatusData{
|
||||||
|
Status: "online",
|
||||||
|
}
|
||||||
|
|
||||||
if idle > 0 {
|
if idle > 0 {
|
||||||
usd.IdleSince = &idle
|
usd.IdleSince = &idle
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue