Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
V4NSH4J
GitHub Repository: V4NSH4J/discord-mass-DM-GO
Path: blob/main/instance/config.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 instance
8
9
import (
10
"encoding/json"
11
"fmt"
12
"io"
13
"os"
14
"path"
15
"path/filepath"
16
17
"github.com/V4NSH4J/discord-mass-dm-GO/utilities"
18
"gopkg.in/yaml.v3"
19
)
20
21
type Config struct {
22
DirectMessage DirectMessage `yaml:"direct_message_settings"`
23
ProxySettings ProxySettings `yaml:"proxy_settings"`
24
ScraperSettings ScraperSettings `yaml:"scraper_settings"`
25
CaptchaSettings CaptchaSettings `yaml:"captcha_settings"`
26
OtherSettings OtherSettings `yaml:"other_settings"`
27
SuspicionAvoidance SuspicionAvoidance `yaml:"suspicion_avoidance"`
28
DMonReact DMonReact `yaml:"dm_on_react"`
29
}
30
31
type DirectMessage struct {
32
Delay int `yaml:"individual_delay"`
33
LongDelay int `yaml:"rate_limit_delay"`
34
Offset int `yaml:"offset"`
35
Skip bool `yaml:"skip_completed"`
36
Call bool `yaml:"call"`
37
Remove bool `yaml:"remove_dead_tokens"`
38
RemoveM bool `yaml:"remove_completed_members"`
39
Stop bool `yaml:"stop_dead_tokens"`
40
Mutual bool `yaml:"check_mutual"`
41
Friend bool `yaml:"friend_before_DM"`
42
Websocket bool `yaml:"online_tokens"`
43
MaxDMS int `yaml:"max_dms_per_token"`
44
Receive bool `yaml:"receive_messages"`
45
SkipFailed bool `yaml:"skip_failed"`
46
Block bool `yaml:"block_after_dm"`
47
Close bool `yaml:"close_dm_after_message"`
48
MultipleMessages bool `yaml:"multiple_messages"`
49
DelayBetweenMultipleMessages int `yaml:"delay_between_multiple_messages"`
50
}
51
type ProxySettings struct {
52
Proxy string `yaml:"proxy"`
53
ProxyFromFile bool `yaml:"proxy_from_file"`
54
ProxyForCaptcha bool `yaml:"proxy_for_captcha"`
55
GatewayProxy bool `yaml:"use_proxy_for_gateway"`
56
Timeout int `yaml:"timeout"`
57
}
58
59
type ScraperSettings struct {
60
SleepSc int `yaml:"scraper_delay"`
61
ScrapeUsernames bool `yaml:"scrape_usernames"`
62
ScrapeAvatars bool `yaml:"scrape_avatars"`
63
ExtendedChars string `yaml:"query_brute_extra_chars"`
64
}
65
66
type CaptchaSettings struct {
67
ClientKey string `yaml:"captcha_api_key"`
68
CaptchaAPI string `yaml:"captcha_api"`
69
Timeout int `yaml:"max_captcha_wait"`
70
MaxCaptchaDM int `yaml:"max_captcha_retry_dm"`
71
MaxCaptchaInv int `yaml:"max_captcha_retry_invite"`
72
Self string `yaml:"self"`
73
SelfUsername string `yaml:"self_username"`
74
SelfPassword string `yaml:"self_password"`
75
}
76
77
type OtherSettings struct {
78
DisableKL bool `yaml:"disable_keep_alives"`
79
Mode int `yaml:"mode"`
80
ConstantCookies bool `yaml:"constant_cookies"`
81
CensorToken bool `yaml:"censor_token"`
82
Logs bool `yaml:"logs"`
83
GatewayStatus int `yaml:"gateway_status"`
84
DolfiesHeaders bool `yaml:"dolfies_headers"`
85
XSuperProperties string `yaml:"x_super_properties"`
86
Useragent string `yaml:"useragent"`
87
JA3 string `yaml:"ja3"`
88
}
89
90
type SuspicionAvoidance struct {
91
RandomIndividualDelay int `yaml:"random_individual_delay"`
92
RandomRateLimitDelay int `yaml:"random_rate_limit_delay"`
93
RandomDelayOpenChannel int `yaml:"random_delay_before_dm"`
94
Typing bool `yaml:"typing"`
95
TypingVariation int `yaml:"typing_variation"`
96
TypingSpeed int `yaml:"typing_speed"`
97
TypingBase int `yaml:"typing_base"`
98
}
99
100
type DMonReact struct {
101
Observer string `yaml:"observer_token"`
102
ChangeName bool `yaml:"change_name"`
103
ChangeAvatar bool `yaml:"change_avatar"`
104
Invite string `yaml:"invite"`
105
ServerID string `yaml:"server_id"`
106
ChannelID string `yaml:"channel_id"`
107
MessageID string `yaml:"message_id"`
108
SkipCompleted bool `yaml:"skip_completed"`
109
SkipFailed bool `yaml:"skip_failed"`
110
LeaveTokenOnRateLimit bool `yaml:"leave_token_on_rate_limit"`
111
Emoji string `yaml:"emoji"`
112
RotateTokens bool `yaml:"rotate_tokens"`
113
MaxAntiRaidQueue int `yaml:"max_anti_raid_queue"`
114
MaxDMsPerToken int `yaml:"max_dms_per_token"`
115
}
116
117
type AutoReact struct {
118
Observer string `yaml:"observer_token"`
119
Servers []string `yaml:"servers"`
120
Channels []string `yaml:"channels"`
121
Messages []string `yaml:"messages"`
122
Users []string `yaml:"users"`
123
Emojis []string `yaml:"emojis"`
124
ReactWith []string `yaml:"react_with"`
125
ReactAll bool `yaml:"react_all"`
126
Delay int `yaml:"delay_between_reacts"`
127
Subscribe []string `yaml:"subscribe_to_servers"`
128
Randomness int `yaml:"minimum_percent_react"`
129
IndividualDelay int `yaml:"individual_delay"`
130
}
131
132
func GetConfig() (Config, error) {
133
ex, err := os.Executable()
134
if err != nil {
135
utilities.LogErr("Error getting executable path %v", err)
136
return Config{}, err
137
}
138
ex = filepath.ToSlash(ex)
139
var file *os.File
140
file, err = os.Open(path.Join(path.Dir(ex) + "/" + "config.yml"))
141
if err != nil {
142
utilities.LogErr("Error while opening config file %v", err)
143
return Config{}, err
144
} else {
145
defer file.Close()
146
var config Config
147
bytes, _ := io.ReadAll(file)
148
err = yaml.Unmarshal(bytes, &config)
149
if err != nil {
150
fmt.Println(err)
151
return Config{}, err
152
}
153
return config, nil
154
}
155
}
156
157
func GetMessage() ([]Message, error) {
158
var messages []Message
159
ex, err := os.Executable()
160
if err != nil {
161
utilities.LogErr("Error while finding executable %v", err)
162
return []Message{}, err
163
}
164
ex = filepath.ToSlash(ex)
165
file, err := os.Open(path.Join(path.Dir(ex) + "/" + "message.json"))
166
if err != nil {
167
utilities.LogErr("Error while Opening Message %v", err)
168
fmt.Println(err)
169
return []Message{}, err
170
}
171
defer file.Close()
172
bytes, _ := io.ReadAll(file)
173
errr := json.Unmarshal(bytes, &messages)
174
if errr != nil {
175
fmt.Println(errr)
176
177
return []Message{}, errr
178
}
179
180
return messages, nil
181
}
182
183