mirror of
https://github.com/statbate/special-pancake.git
synced 2026-08-11 03:12:42 +00:00
updates
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
568dd266c9
commit
6b2e15c947
4 changed files with 400 additions and 0 deletions
17
go.mod
Normal file
17
go.mod
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
module special-pancake
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/ClickHouse/clickhouse-go v1.5.4
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0
|
||||||
|
github.com/gorilla/websocket v1.5.0
|
||||||
|
github.com/jmoiron/sqlx v1.3.5
|
||||||
|
github.com/json-iterator/go v1.1.12
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
)
|
||||||
38
go.sum
Normal file
38
go.sum
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
|
||||||
|
github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
|
||||||
|
github.com/bkaradzic/go-lz4 v1.0.0 h1:RXc4wYsyz985CkXXeX04y4VnZFGG8Rd43pRaHsOXAKk=
|
||||||
|
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
|
||||||
|
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg=
|
||||||
|
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
|
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
|
||||||
|
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
|
||||||
|
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
|
||||||
|
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
||||||
|
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
26
test2/main.go
Normal file
26
test2/main.go
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func randInt(min int, max int) int {
|
||||||
|
return min + rand.Intn(max-min)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) < 3 {
|
||||||
|
fmt.Println("./test room server")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
room := os.Args[1]
|
||||||
|
server := os.Args[2]
|
||||||
|
|
||||||
|
u := url.URL{Scheme: "wss", Host: server + ".highwebmedia.com", Path: "/ws/555/kmdqiune/websocket"}
|
||||||
|
|
||||||
|
statRoom(room, server, u)
|
||||||
|
}
|
||||||
319
test2/worker.go
Normal file
319
test2/worker.go
Normal file
|
|
@ -0,0 +1,319 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Input struct {
|
||||||
|
Args []string `json:"args"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TipMsg struct {
|
||||||
|
Channel string `json:"channel"`
|
||||||
|
Messages []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Amount int64 `json:"amount"`
|
||||||
|
From string `json:"from_username"`
|
||||||
|
} `json:"messages"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Donate struct {
|
||||||
|
Amount int64 `json:"amount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAuth(room string) (string, string, error) {
|
||||||
|
jar, err := cookiejar.New(nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Jar: jar,
|
||||||
|
}
|
||||||
|
|
||||||
|
var rsp *http.Response
|
||||||
|
|
||||||
|
rsp, err = client.Get("https://chaturbate.com/" + room)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
buf, err := io.ReadAll(rsp.Body)
|
||||||
|
if err != nil {
|
||||||
|
rsp.Body.Close()
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if rsp.StatusCode != 200 {
|
||||||
|
return "", "", fmt.Errorf("%s", buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
var room_uid string
|
||||||
|
// var wschat_host string
|
||||||
|
idx := strings.Index(string(buf), `room_uid`)
|
||||||
|
if idx < 0 {
|
||||||
|
return "", "", fmt.Errorf("failed to find room_uid: %s", buf)
|
||||||
|
}
|
||||||
|
start := idx + len(`room_uid\u0022: \u0022`)
|
||||||
|
for {
|
||||||
|
idx++
|
||||||
|
if string(buf)[idx] != ',' {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
room_uid = string(buf)[start : idx-len(`\u0022`)]
|
||||||
|
fmt.Printf("room_uid: %s\n", room_uid)
|
||||||
|
var csrftoken string
|
||||||
|
var xcookie http.Cookie
|
||||||
|
u, _ := url.Parse("https://chaturbate.com")
|
||||||
|
cookies := jar.Cookies(u)
|
||||||
|
for _, cookie := range cookies {
|
||||||
|
if cookie.Name != "csrftoken" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Printf("cookie with csrftoken %s\n", cookie.Value)
|
||||||
|
csrftoken = cookie.Value
|
||||||
|
xcookie = *cookie
|
||||||
|
break
|
||||||
|
}
|
||||||
|
xcookie.Name = "agreeterms"
|
||||||
|
xcookie.Value = "1"
|
||||||
|
cookies = append(cookies, &xcookie)
|
||||||
|
jar.SetCookies(u, cookies)
|
||||||
|
|
||||||
|
body, writer := io.Pipe()
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodPost, "https://chaturbate.com/push_service/auth/", body)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
mwriter := multipart.NewWriter(writer)
|
||||||
|
req.Header.Add("Content-Type", mwriter.FormDataContentType())
|
||||||
|
req.Header.Add("X-Requested-With", "XMLHttpRequest")
|
||||||
|
req.Header.Add("Accept", "*/*")
|
||||||
|
// req.Header.Add("Accept-Encoding", "gzip, deflate, br")
|
||||||
|
req.Header.Add("Referrer", "https://chaturbate.com/"+room+"/")
|
||||||
|
req.Header.Add("Accept-Language", "ru")
|
||||||
|
req.Header.Add("Origin", "https://chaturbate.com")
|
||||||
|
req.Header.Add("User-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15")
|
||||||
|
req.Header.Add("X-NewRelic-ID", "VQIGWV9aDxACUFNVDgMEUw==")
|
||||||
|
req.Header.Add("tracestate", "1418997@nr=0-1-1418997-24506750-2b71146eaa569098----1674161211828")
|
||||||
|
req.Header.Add("traceparent", "00-01e7ed3b72a4b6787f0fadeb83557180-2b71146eaa569098-01")
|
||||||
|
req.Header.Add("X-CSRFToken", csrftoken)
|
||||||
|
req.Header.Add("newrelic", "eyJ2IjpbMCwxXSwiZCI6eyJ0eSI6IkJyb3dzZXIiLCJhYyI6IjE0MTg5OTciLCJhcCI6IjI0NTA2NzUwIiwiaWQiOiI4MDFiYTg1ZGI0NWQwMTUwIiwidHIiOiIzMWYxNmQ1ZDJlZGRlNWM3NzQyZTM0NWM5NmVkY2MxMCIsInRpIjoxNjc0MzAwNjA5NTY0fX0=")
|
||||||
|
req.Header.Add("X-NewRelic-ID", "VQIGWV9aDxACUFNVDgMEUw==")
|
||||||
|
|
||||||
|
errchan := make(chan error)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer close(errchan)
|
||||||
|
defer writer.Close()
|
||||||
|
defer mwriter.Close()
|
||||||
|
|
||||||
|
wr, err := mwriter.CreateFormField("topics")
|
||||||
|
if err != nil {
|
||||||
|
errchan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err = wr.Write([]byte(strings.ReplaceAll(`{"RoomTipAlertTopic#RoomTipAlertTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomPurchaseTopic#RoomPurchaseTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomFanClubJoinedTopic#RoomFanClubJoinedTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomMessageTopic#RoomMessageTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"GlobalPushServiceBackendChangeTopic#GlobalPushServiceBackendChangeTopic":{},"RoomAnonPresenceTopic#RoomAnonPresenceTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"QualityUpdateTopic#QualityUpdateTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomNoticeTopic#RoomNoticeTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomEnterLeaveTopic#RoomEnterLeaveTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomPasswordProtectedTopic#RoomPasswordProtectedTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomModeratorPromotedTopic#RoomModeratorPromotedTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomModeratorRevokedTopic#RoomModeratorRevokedTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomStatusTopic#RoomStatusTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomTitleChangeTopic#RoomTitleChangeTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomSilenceTopic#RoomSilenceTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomKickTopic#RoomKickTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomUpdateTopic#RoomUpdateTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"},"RoomSettingsTopic#RoomSettingsTopic:ROOM_UID":{"broadcaster_uid":"ROOM_UID"}}`, "ROOM_UID", room_uid))); err != nil {
|
||||||
|
errchan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
wr, err = mwriter.CreateFormField("csrfmiddlewaretoken")
|
||||||
|
if err != nil {
|
||||||
|
errchan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = wr.Write([]byte(csrftoken)); err != nil {
|
||||||
|
errchan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
rsp, err = client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
defer rsp.Body.Close()
|
||||||
|
r := rsp.Body
|
||||||
|
/*
|
||||||
|
r, err := gzip.NewReader(rsp.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer r.Close()
|
||||||
|
*/
|
||||||
|
|
||||||
|
buf, err = io.ReadAll(r)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if rsp.StatusCode != 200 {
|
||||||
|
return "", "", fmt.Errorf("status != 200: %s", buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
type keyNameRsp struct {
|
||||||
|
TokenRequest struct {
|
||||||
|
KeyName string `json:"keyName"`
|
||||||
|
} `json:"token_request"`
|
||||||
|
}
|
||||||
|
keyName := &keyNameRsp{}
|
||||||
|
type tokenRequestRsp struct {
|
||||||
|
TokenRequest json.RawMessage `json:"token_request"`
|
||||||
|
}
|
||||||
|
tokenRequest := &tokenRequestRsp{}
|
||||||
|
if err = json.Unmarshal(buf, keyName); err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(buf, tokenRequest); err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
rsp, err = client.Post("https://realtime.pa.highwebmedia.com/keys/"+keyName.TokenRequest.KeyName+"/requestToken?rnd=9705437583116864", "application/json", bytes.NewReader(tokenRequest.TokenRequest))
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
defer rsp.Body.Close()
|
||||||
|
buf, err = io.ReadAll(rsp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if rsp.StatusCode != 201 {
|
||||||
|
fmt.Printf("buf %s\n", tokenRequest.TokenRequest)
|
||||||
|
return "", "", fmt.Errorf("status != 201: %s", buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
type tokenRsp struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
}
|
||||||
|
tokenResponse := &tokenRsp{}
|
||||||
|
if err = json.Unmarshal(buf, tokenResponse); err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokenResponse.Token, room_uid, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func statRoom(room, server string, _ url.URL) {
|
||||||
|
authToken, room_uid, err := getAuth(room)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// fmt.Printf("auth status: %v rsp: %s room_uid: %s\n", err, authToken, room_uid)
|
||||||
|
|
||||||
|
u, err := url.Parse("wss://realtime.pa.highwebmedia.com/?access_token=" + authToken + "&format=json&heartbeats=true&v=1.2&agent=ably-js%2F1.2.13%20browser&remainPresentFor=0")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
timeout := time.Now().Unix() + 60*60
|
||||||
|
init := false
|
||||||
|
|
||||||
|
initMessages := []string{
|
||||||
|
`{"action":16, "connectionKey":{"accessToken":"` + authToken + `"}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:tip_alert:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:purchase:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:fanclub:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:message:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"global:push_service","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room_anon:presence:` + room_uid + `:0","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:quality_update:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:notice:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:enter_leave:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:password_protected:` + room_uid + `:13","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:mod_promoted:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:mod_revoked:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:status:` + room_uid + `:13","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:title_change:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:silence:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:kick:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:update:` + room_uid + `","params":{}}`,
|
||||||
|
`{"action":10,"flags":327680,"channel":"room:settings:` + room_uid + `","params":{}}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
|
||||||
|
_, message, err := c.ReadMessage()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Now().Unix() > timeout {
|
||||||
|
fmt.Println("Timeout room:", room)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
m := string(message)
|
||||||
|
// fmt.Printf("msg :%s\n", m)
|
||||||
|
|
||||||
|
var v map[string]interface{}
|
||||||
|
if err := json.Unmarshal(message, &v); err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if !init {
|
||||||
|
c.WriteMessage(websocket.TextMessage, []byte(`{"action":17, "auth":{"accessToken":"`+authToken+`"}}`))
|
||||||
|
c.WriteMessage(websocket.TextMessage, []byte(`{"action":16, "connectionKey":"`+v["connectionKey"].(string)+`","connectionSerial": -1}`))
|
||||||
|
for _, im := range initMessages {
|
||||||
|
c.WriteMessage(websocket.TextMessage, []byte(im))
|
||||||
|
}
|
||||||
|
init = true
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
{"action":15,"id":"tCcHlgv0cq:0","connectionSerial":36,"channel":"room:tip_alert:EVX8CQC","channelSerial":"e91SLOyowBKTaO39138171:370","timestamp":1674333061062,"messages":[{"encoding":"json","data":"{\"tid\": \"16743330610:75553\", \"ts\": 1674333061.040021, \"amount\": 1, \"message\": \"\", \"history\": true, \"is_anonymous_tip\": false, \"to_username\": \"chloewildd\", \"from_username\": \"dm___of_cw\", \"gender\": \"m\", \"is_broadcaster\": false, \"in_fanclub\": false, \"is_following\": true, \"is_mod\": false, \"has_tokens\": true, \"tipped_recently\": true, \"tipped_alot_recently\": true, \"tipped_tons_recently\": true, \"method\": \"lazy\", \"pub_ts\": 1674333061.0486424}","name":"room:tip_alert:EVX8CQC"}]}
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch v["action"].(float64) {
|
||||||
|
case 0:
|
||||||
|
continue
|
||||||
|
case 15:
|
||||||
|
/*
|
||||||
|
{"action":15, "channel":"room:tip_alert:EVX8CQC", "channelSerial":"e91SLOyowBKTaO39138171:415", "connectionSerial":5, "id":"0-UOFp1i5K:0", "messages":[]interface {}{map[string]interface {}{"data":"{\"tid\": \"16743339917:85230\", \"ts\": 1674333991.730678, \"amount\": 10, \"message\": \"\", \"history\": true, \"is_anonymous_tip\": false, \"to_username\": \"chloewildd\", \"from_username\": \"majikal666\", \"gender\": \"m\", \"is_broadcaster\": false, \"in_fanclub\": false, \"is_following\": true, \"is_mod\": false, \"has_tokens\": true, \"tipped_recently\": true, \"tipped_alot_recently\": true, \"tipped_tons_recently\": true, \"method\": \"lazy\", \"pub_ts\": 1674333991.7439415}", "encoding":"json", "name":"room:tip_alert:EVX8CQC"}}, "timestamp":1.674333991766e+12}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
donate := &TipMsg{}
|
||||||
|
|
||||||
|
timeout = time.Now().Unix() + 60*60
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(m), &donate); err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Printf("donate %#+v\n", donate)
|
||||||
|
if donate.Channel != "room:tip_alert:"+room_uid {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, msg := range donate.Messages {
|
||||||
|
if len(msg.From) > 3 {
|
||||||
|
fmt.Println(msg.From, " send ", msg.Amount, "tokens")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue