forked from Kqzz/MCsniperGO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
109 lines (89 loc) · 3.04 KB
/
config.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
package main
import (
"errors"
"io/ioutil"
"os"
"github.com/pelletier/go-toml/v2"
)
type ConfigStruct struct {
Sniper struct {
TimingSystemPreference string `toml:"timing_system_preference"`
CycleTimingSystems bool `toml:"cycle_timing_systems"`
AutoClaimNamemc bool `toml:"auto_claim_namemc"`
SnipeRequests int `toml:"snipe_requests"`
PrenameRequests int `toml:"prename_requests"`
Spread float64 `toml:"spread"`
} `toml:"sniper"`
Accounts struct {
StartAuth int `toml:"start_auth"`
AuthDelay int `toml:"auth_delay"`
} `toml:"accounts"`
Skin struct {
ChangeSkinOnSnipe bool `toml:"change_skin_on_snipe"`
SkinChangeType string `toml:"skin_change_type"`
Skin string `toml:"skin"`
} `toml:"skin"`
Announce struct {
McsnipergoAnnounceCode string `toml:"mcsnipergo_announce_code"`
WebhookURL string `toml:"webhook_url"`
WebhookFormat string `toml:"webhook_format"`
PrivateWebhookURL string `toml:"private_webhook_url"`
PrivateWebhookFormat string `toml:"private_webhook_format"`
PrivateWebhookIncludeAcc bool `toml:"private_webhook_include_acc"`
} `toml:"announce"`
}
const (
defaultConfigString = `[sniper]
timing_system_preference = "star.shopping"
cycle_timing_systems = true # Go through each timing system until droptime is successfully grabbed
auto_claim_namemc = false # broken
snipe_requests = 2 # requests to be sent per acc for normal sniping
prename_requests = 6 # requests to be sent per acc for prename sniping
spread = 0.0 # delay between requests in milliseconds (float)
[accounts]
start_auth = 15 # start authenticating accounts x minutes before drop
auth_delay = 1 # seconds between auth
[skin]
# DOESNT WORK
change_skin_on_snipe = false
skin_change_type = "url"
skin = "" # this value depends on the skin_change_type value
[announce]
# discord webhook-related things
# WORKING NOW
webhook_url = "" # public webhook url to announce snipes in your own server, leave empty to not announce
# Might work but api is probably down
mcsnipergo_announce_code = "" # leave blank to not announce snipe
# DOESNT WORK
private_webhook_url = "" # webhook url where PRIVATE information will be sent, DO NOT MAKE THIS IN A PUBLIC DISCORD CHANNEL.
private_webhook_format = "sniped {name} with {searches} searches and {offset} offset!"
private_webhook_include_acc = false # include acc details in webhook`
)
func defaultConfig() error {
cfgBytes := []byte(defaultConfigString)
file, err := os.Create("config.toml")
if err != nil {
return err
}
defer file.Close()
_, err = file.Write(cfgBytes)
if err != nil {
return err
}
return nil
}
func getConfig() (ConfigStruct, error) {
if !fileExists("config.toml") {
return ConfigStruct{}, errors.New("config file does not exist")
}
confBytes, err := ioutil.ReadFile("config.toml")
if err != nil {
return ConfigStruct{}, err
}
var cfg ConfigStruct
err = toml.Unmarshal(confBytes, &cfg)
if err != nil {
return ConfigStruct{}, err
}
return cfg, nil
}