Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
V4NSH4J
GitHub Repository: V4NSH4J/discord-mass-DM-GO
Path: blob/main/discord/token_onliner.go
310 views
1
// Copyright (C) 2021 github.com/V4NSH4J
2
//
3
// This source code has been released under the GNU Affero General Public
4
// License v3.0. A copy of this license is available at
5
// https://www.gnu.org/licenses/agpl-3.0.en.html
6
7
package discord
8
9
import (
10
"bufio"
11
"os"
12
"sync"
13
14
"github.com/V4NSH4J/discord-mass-dm-GO/instance"
15
"github.com/V4NSH4J/discord-mass-dm-GO/utilities"
16
)
17
18
func LaunchTokenOnliner() {
19
_, instances, err := instance.GetEverything()
20
if err != nil {
21
utilities.LogErr("Error while getting neccessary information %v", err)
22
utilities.ExitSafely()
23
}
24
var wg sync.WaitGroup
25
wg.Add(len(instances))
26
for i := 0; i < len(instances); i++ {
27
go func(i int) {
28
err := instances[i].StartWS()
29
if err != nil {
30
utilities.LogErr("Token %v Error while starting websocket %v", instances[i].CensorToken(), err)
31
} else {
32
utilities.LogSuccess("Websocket opened %v", instances[i].CensorToken())
33
}
34
wg.Done()
35
}(i)
36
}
37
wg.Wait()
38
utilities.LogInfo("All Token online. Press ENTER to disconnect and continue the program")
39
bufio.NewReader(os.Stdin).ReadBytes('\n')
40
wg.Add(len(instances))
41
for i := 0; i < len(instances); i++ {
42
go func(i int) {
43
instances[i].Ws.Close()
44
wg.Done()
45
}(i)
46
}
47
wg.Wait()
48
utilities.LogInfo("All Token offline")
49
}
50
51