-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
328 lines (281 loc) · 8.82 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
)
var HostApi = "https://dev.execross.pw"
var APIKEY = "your_apikey_here"
type ResponseData struct {
Status int `json:"status"`
Message string `json:"message"`
}
func sendRequest(endpoint string, requestData map[string]interface{}) (*ResponseData, error) {
jsonData, err := json.Marshal(requestData)
if err != nil {
return nil, err
}
resp, err := http.Post(endpoint, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
}
defer resp.Body.Close()
var response ResponseData
err = json.NewDecoder(resp.Body).Decode(&response)
if err != nil {
return nil, err
}
return &response, nil
}
func sendMultiImageWithUrl(token, to string, urls []string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendMultiImageWithUrl"
requestData := map[string]interface{}{
"apikey": APIKEY,
"token": token,
"to": to,
"url": urls,
}
return sendRequest(endpoint, requestData)
}
func sendImageWithUrl(token, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendImageWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendReplyImageWithUrl(token, ids, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendReplyImageWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"ids": ids,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendAudioWithUrl(token, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendReplyImageWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendReplyImageWithUrl(token, ids, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendReplyAudioWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"ids": ids,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendVideoWithUrl(token, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendReplyImageWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendReplyVideoWithUrl(token, ids, to, url string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendReplyAudioWithUrl"
requestData := map[string]string{
"apikey": APIKEY,
"token": token,
"ids": ids,
"to": to,
"url": url,
}
return sendRequest(endpoint, requestData)
}
func sendFlex(token, to string, meta map[string]interface{}) (*ResponseData, error) {
endpoint := HostApi + "/api/go/sendFlex"
flexJSON, err := json.Marshal(meta)
if err != nil {
return nil, err
}
requestData := map[string]interface{}{
"apikey": APIKEY,
"token": token,
"to": to,
"flex": string(flexJSON),
}
return sendRequest(endpoint, requestData)
}
func sendLikePost(token, mid, contentId, string) (*ResponseData, error) {
endpoint := HostApi + "/api/go/likePost"
requestData := map[string]string{
"apikey": "Your_Apikey_Here",
"token": token,
"mid": to,
"contentId": contentId,
}
return sendRequest(endpoint, requestData)
}
func main() {
baseAPIURL := "https://dev.execross.pw/api/js/"
queryParams := url.Values{}
queryParams.Set("gid", "your_gid_value")
queryParams.Set("appName", "your_app_name")
queryParams.Set("authToken", "your_auth_token")
speedEndpoint := baseAPIURL + "speed?" + queryParams.Encode()
makeGETRequest(speedEndpoint, "Speed Request")
invites := []string{"invite1", "invite2", "invite3"} // this mid you want cancelled or like something like that :p
members := []string{"member1", "member2", "member3"} // this mid you want kick from the group
invitesParam := strings.Join(invites, ",")
membersParam := strings.Join(members, ",")
// Making a GET request to /api/js/loopkick
loopKickEndpoint := baseAPIURL + "loopkick?" + queryParams.Encode() + "&invites=" + invitesParam + "&members=" + membersParam
makeGETRequest(loopKickEndpoint, "Loop Kick Request")
// Making a GET request to /api/js/multi
multiEndpoint = baseAPIURL + "multi?" + queryParams.Encode() + "&invites=" + invitesParam + "&members=" + membersParam
makeGETRequest(multiEndpoint, "Multi Request")
// Making a GET request to /api/js/cancel
cancelEndpoint := baseAPIURL + "cancel?" + queryParams.Encode() + "&invites=" + invitesParam
makeGETRequest(cancelEndpoint, "Cancel Request")
// sending Media requests
Token := "Your_auth_token"
to := "groupid_or_user_id"
url := "https://cdn.motor1.com/images/mgl/6ZAvXk/s1/lamborghini-invencible.jpg"
urlAudio := "https://dev.execross.pw/assets/audio-url-test.mp3"
urlVideo := "https://dev.execross.pw/assets/video-url-test.mp4"
ids1 := "472433797585961272"
MultiImg := []string{"https://upload.wikimedia.org/wikipedia/commons/1/19/Lamborghini_Aventador.jpg", "https://www.miaomiaopa.com/wp-content/uploads/2023/03/3f10ba5ca81d82cacef50fdcd6550b23.jpg", "https://www.miaomiaopa.com/wp-content/uploads/2023/03/374d1ded15ad5305d13a84118cbab938.jpg", "https://img-9gag-fun.9cache.com/photo/arG92Ld_460s.jpg"}
// Send Like Post
contentId := "Post_Target"
responseLike, err := sendLikePost(token, mid, contentId)
if err != nil {
fmt.Println("Error send like post:", err)
return
}
fmt.Println(responseLike)
// Send Image
responseImg1, errImg1 := sendImageWithUrl(Token, to, url)
if errImg1 != nil {
fmt.Println("Error sending image with URL:", errImg1)
return
}
fmt.Println(responseImg1)
// Send Multi Image
resImg, errMultiImg := sendMultiImageWithUrl(Token, to, MultiImg)
if errMultiImg != nil {
fmt.Println("Error sending image with URL:", errMultiImg)
return
}
fmt.Println(resImg)
// Send Reply Image
responseImg2, errImg2 := sendReplyImageWithUrl(Token, ids1, to, url)
if errImg2 != nil {
fmt.Println("Error sending reply image with URL:", errImg2)
return
}
fmt.Println(responseImg2)
// Send Audio
responseAud1, errAud1 := sendAudioWithUrl(Token, to, urlAudio)
if errAud1 != nil {
fmt.Println("Error sending audio with URL:", errAud1)
return
}
fmt.Println(responseAud1)
// Send Reply Audio
responseAud2, errAud2 := sendReplyAudioWithUrl(Token, ids1, to, urlAudio)
if errAud2 != nil {
fmt.Println("Error sending reply audio with URL:", errAud2)
return
}
fmt.Println(responseAud2)
// Send Video
responseVid1, errVid1 := sendVideoWithUrl(Token, to, urlVideo)
if errVid1 != nil {
fmt.Println("Error sending video with URL:", errVid1)
return
}
fmt.Println(responseVid1)
// Send Reply Video
responseVid2, errVid2 := sendReplyVideoWithUrl(Token, ids1, to, urlVideo)
if errVid2 != nil {
fmt.Println("Error sending reply video with URL:", errVid2)
return
}
fmt.Println(responseVid2)
// Send Flex Example (Image)
background := "https://cdn.motor1.com/images/mgl/6ZAvXk/s1/lamborghini-invencible.jpg"
meta := map[string]interface{}{
"type": "image",
"originalContentUrl": url,
"previewImageUrl": url,
}
dataFlex := map[string]interface{}{
"type": "flex",
"altText": "Developer Execross",
"contents": meta,
}
responseFlex, errFlex := sendFlex(Token, to, dataFlex)
if errFlex != nil {
fmt.Println("Error sending Flex (Image):", errFlex)
return
}
fmt.Println(responseFlex)
// Send Flex Example (Video)
meta = map[string]interface{}{
"type": "video",
"originalContentUrl": urlVideo,
"previewImageUrl": url,
}
dataFlex = map[string]interface{}{
"type": "flex",
"altText": "Developer Execross",
"contents": meta,
}
responseFlex, errFlex = sendFlex(Token, to, dataFlex)
if errFlex != nil {
fmt.Println("Error sending Flex (Video):", errFlex)
return
}
fmt.Println(responseFlex)
// Send Flex Example (Audio)
meta = map[string]interface{}{
"type": "audio",
"originalContentUrl": urlAudio,
"duration": 60000,
}
dataFlex = map[string]interface{}{
"type": "flex",
"altText": "Developer Execross",
"contents": meta,
}
responseFlex, errFlex = sendFlex(Token, to, dataFlex)
if errFlex != nil {
fmt.Println("Error sending Flex (Audio):", errFlex)
return
}
fmt.Println(responseFlex)
}
func makeGETRequest(apiURL, requestName string) {
resp, err := http.Get(apiURL)
if err != nil {
fmt.Printf("%s: Error - %v\n", requestName, err)
return
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Printf("%s: Request Successful\n", requestName)
} else {
fmt.Printf("%s: Request failed with status code: %d\n", requestName, resp.StatusCode)
}
}