mirror of
https://github.com/statbate/shiny-potato.git
synced 2026-08-11 03:12:42 +00:00
Update worker.go
This commit is contained in:
parent
370e3bce07
commit
e9ff078dc2
1 changed files with 36 additions and 50 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -13,8 +12,6 @@ import (
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
var messages [][]byte
|
|
||||||
|
|
||||||
type Amount struct {
|
type Amount struct {
|
||||||
value int
|
value int
|
||||||
}
|
}
|
||||||
|
|
@ -36,27 +33,6 @@ func (a *Amount) UnmarshalJSON(b []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194970-sub-lotteryChanged","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/lotteryChanged"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194970-sub-userBanned:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/userBanned:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194970-sub-goalChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/goalChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194970-sub-modelStatusChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/modelStatusChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-broadcastSettingsChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/broadcastSettingsChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-tipMenuUpdated:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/tipMenuUpdated:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-topicChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/topicChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-userUpdated:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/userUpdated:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-interactiveToyStatusChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/interactiveToyStatusChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-groupShow:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/groupShow:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-deleteChatMessages:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/deleteChatMessages:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-tipLeaderboardSettingsUpdated:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/tipLeaderboardSettingsUpdated:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194971-sub-modelAppUpdated:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/modelAppUpdated:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194972-sub-newKing:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/newKing:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194972-sub-privateMessageSettingsChanged:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/privateMessageSettingsChanged:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194972-sub-newChatMessage:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/newChatMessage:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194972-sub-fanClubUpdated:XID","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/fanClubUpdated:XID"}`))
|
|
||||||
messages = append(messages, []byte(`{"id":"1660248194972-sub-viewServerChanged:hls-07","method":"PUT","url":"/front/clients/CLIENT_ID/subscriptions/viewServerChanged:hls-07"}`))
|
|
||||||
}
|
|
||||||
|
|
||||||
type ServerResponse struct {
|
type ServerResponse struct {
|
||||||
SubscriptionKey string `json:"subscriptionKey,omitempty"`
|
SubscriptionKey string `json:"subscriptionKey,omitempty"`
|
||||||
|
|
||||||
|
|
@ -88,8 +64,7 @@ type ServerResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func startRoom(room, server, proxy string, u *url.URL, id string) {
|
func startRoom(room, server, proxy string, u *url.URL, id string) {
|
||||||
// curl -vvv -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "X-Requested-With: XMLHttpRequest" -d "method=getRoomData" -d "args[]=Icehotangel" "https://rt.bongocams.com/tools/amf.php?res=771840&t=1654437233142"
|
|
||||||
|
|
||||||
fmt.Println("Start", room, "server", server, "proxy", proxy)
|
fmt.Println("Start", room, "server", server, "proxy", proxy)
|
||||||
|
|
||||||
Dialer := *websocket.DefaultDialer
|
Dialer := *websocket.DefaultDialer
|
||||||
|
|
@ -116,15 +91,15 @@ func startRoom(room, server, proxy string, u *url.URL, id string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
_, message, err := c.ReadMessage()
|
_, message, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("return " + err.Error())
|
fmt.Println(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(message))
|
//fmt.Println(string(message))
|
||||||
|
|
||||||
m := &ServerResponse{}
|
m := &ServerResponse{}
|
||||||
|
|
||||||
|
|
@ -134,38 +109,49 @@ func startRoom(room, server, proxy string, u *url.URL, id string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.SubscriptionKey == "connected" {
|
if m.SubscriptionKey == "connected" {
|
||||||
fmt.Println("subscribe to messages")
|
messages := [][]byte{}
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194970-sub-lotteryChanged","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/lotteryChanged"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194970-sub-userBanned:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/userBanned:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194970-sub-goalChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/goalChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194970-sub-modelStatusChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/modelStatusChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-broadcastSettingsChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/broadcastSettingsChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-tipMenuUpdated:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/tipMenuUpdated:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-topicChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/topicChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-userUpdated:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/userUpdated:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-interactiveToyStatusChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/interactiveToyStatusChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-groupShow:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/groupShow:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-deleteChatMessages:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/deleteChatMessages:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-tipLeaderboardSettingsUpdated:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/tipLeaderboardSettingsUpdated:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194971-sub-modelAppUpdated:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/modelAppUpdated:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194972-sub-newKing:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/newKing:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194972-sub-privateMessageSettingsChanged:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/privateMessageSettingsChanged:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194972-sub-newChatMessage:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/newChatMessage:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194972-sub-fanClubUpdated:`+id+`","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/fanClubUpdated:`+id+`"}`))
|
||||||
|
messages = append(messages, []byte(`{"id":"1660248194972-sub-viewServerChanged:hls-07","method":"PUT","url":"/front/clients/`+m.Params.ClientId+`/subscriptions/viewServerChanged:hls-07"}`))
|
||||||
for _, msg := range messages {
|
for _, msg := range messages {
|
||||||
b := bytes.ReplaceAll(msg, []byte(`CLIENT_ID`), []byte(m.Params.ClientId))
|
if err = c.WriteMessage(websocket.TextMessage, msg); err != nil {
|
||||||
b = bytes.ReplaceAll(b, []byte(`XID`), []byte(id))
|
fmt.Println(err.Error())
|
||||||
if err = c.WriteMessage(websocket.TextMessage, b); err != nil {
|
|
||||||
// fmt.Println("return " + err.Error())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
messages = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(m.SubscriptionKey, "userUpdated") {
|
if strings.Contains(m.SubscriptionKey, "userUpdated") && m.Params.User.Status == "off" {
|
||||||
if m.Params.User.Status == "off" {
|
fmt.Println("user exiting")
|
||||||
fmt.Println("user exiting")
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
} else if strings.Contains(m.SubscriptionKey, "modelStatusChanged") {
|
if strings.Contains(m.SubscriptionKey, "modelStatusChanged") && m.Params.Model.Status == "off" {
|
||||||
if m.Params.Model.Status == "off" {
|
fmt.Println("user exiting")
|
||||||
fmt.Println("user exiting")
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(m.SubscriptionKey, "newChatMessage") {
|
if !strings.Contains(m.SubscriptionKey, "newChatMessage") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Params.Message.Type == "lovense" {
|
if m.Params.Message.Type == "tip" {
|
||||||
// fmt.Println("donate")
|
|
||||||
fmt.Println(m.Params.Message.Details.LovenseDetails.Detail.Name, " send ", m.Params.Message.Details.LovenseDetails.Detail.Amount.Value(), "tokens")
|
|
||||||
} else if m.Params.Message.Type == "tip" {
|
|
||||||
// fmt.Println("donate")
|
|
||||||
fmt.Println(m.Params.Message.Userdata.Username, " send ", m.Params.Message.Details.Amount.Value(), "tokens")
|
fmt.Println(m.Params.Message.Userdata.Username, " send ", m.Params.Message.Details.Amount.Value(), "tokens")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue