mirror of
https://github.com/statbate/shiny-potato.git
synced 2026-08-11 03:12:42 +00:00
cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
2ef3e1fc8d
commit
4cb32b2344
2 changed files with 7 additions and 23 deletions
14
test/main.go
14
test/main.go
|
|
@ -22,12 +22,12 @@ func main() {
|
||||||
server := os.Args[2]
|
server := os.Args[2]
|
||||||
proxy := os.Args[3]
|
proxy := os.Args[3]
|
||||||
|
|
||||||
u, token, id := getToken(room)
|
u, id := getToken(room)
|
||||||
|
|
||||||
startRoom(room, server, proxy, u, token, id)
|
startRoom(room, server, proxy, u, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getToken(room string) (*url.URL, string, string) {
|
func getToken(room string) (*url.URL, string) {
|
||||||
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "https://ru.stripchat.com/"+room, nil)
|
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "https://ru.stripchat.com/"+room, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -61,17 +61,11 @@ func getToken(room string) (*url.URL, string, string) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
re = regexp.MustCompile(`"token":"*(.*?)\s*"`)
|
|
||||||
m = re.FindSubmatch(buf)
|
|
||||||
if len(m) != 2 {
|
|
||||||
panic("not match")
|
|
||||||
}
|
|
||||||
|
|
||||||
re = regexp.MustCompile(`img.strpst.com/thumbs/*(.*?)\s*"`)
|
re = regexp.MustCompile(`img.strpst.com/thumbs/*(.*?)\s*"`)
|
||||||
id := re.FindSubmatch(buf)
|
id := re.FindSubmatch(buf)
|
||||||
if len(id) != 2 {
|
if len(id) != 2 {
|
||||||
panic("not match")
|
panic("not match")
|
||||||
}
|
}
|
||||||
xid := string(id[1])
|
xid := string(id[1])
|
||||||
return u, string(m[1]), xid[strings.Index(xid, "/")+1:]
|
return u, xid[strings.Index(xid, "/")+1:]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ type ServerResponse struct {
|
||||||
} `json:"params,omitempty"`
|
} `json:"params,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func startRoom(room, server, proxy string, u *url.URL, token string, 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"
|
// 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.Printf("token %s id %s\n", token, id)
|
|
||||||
fmt.Println("Start", room, "server", server, "proxy", proxy)
|
fmt.Println("Start", room, "server", server, "proxy", proxy)
|
||||||
|
|
||||||
Dialer := *websocket.DefaultDialer
|
Dialer := *websocket.DefaultDialer
|
||||||
|
|
@ -88,12 +88,6 @@ func startRoom(room, server, proxy string, u *url.URL, token string, id string)
|
||||||
|
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
ws, _, err := Dialer.Dial("wss://websocket.stripchat.com/connection/websocket", nil)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer ws.Close()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
_, message, err := c.ReadMessage()
|
_, message, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -120,17 +114,13 @@ func startRoom(room, server, proxy string, u *url.URL, token string, id string)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err = ws.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf(`{"params":{"token":"%s","name":"js"},"id":1}`, token))); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(m.SubscriptionKey, "newChatMessage") {
|
if !strings.Contains(m.SubscriptionKey, "newChatMessage") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("proper msg")
|
|
||||||
|
|
||||||
if m.Params.Message.Type == "lovense" {
|
if m.Params.Message.Type == "lovense" {
|
||||||
fmt.Println("donate")
|
fmt.Println("donate")
|
||||||
fmt.Println(m.Params.Message.Details.LovenseDetails.Detail.Name, " send ", m.Params.Message.Details.LovenseDetails.Detail.Amount, "tokens")
|
fmt.Println(m.Params.Message.Details.LovenseDetails.Detail.Name, " send ", m.Params.Message.Details.LovenseDetails.Detail.Amount, "tokens")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue