-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (56 loc) · 1.74 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
package main
import (
"encoding/json"
"log"
"os"
"os/signal"
"syscall"
)
var config Configuration
type Configuration struct {
MonitorDelay int `json:"monitorDelay"`
Webhook string `json:"webhook"`
SkinportUsername string `json:"skinportUsername"`
SkinportPassword string `json:"skinportPassword"`
TwoCaptchaKey string `json:"twoCaptchaKey"`
BotToken string `json:"botToken"`
DmarketPublicKey string `json:"dmarketPublicKey"`
DmarketPrivateKey string `json:"dmarketPrivateKey"`
MinimumProfitPercentage float64 `json:"minimumProfitPercentage"`
MinimumPrice float64 `json:"minimumPrice"`
MaximumPrice float64 `json:"maximumPrice"`
InputChannel string `json:"inputChannel"`
}
var (
WarningLogger *log.Logger
InfoLogger *log.Logger
ErrorLogger *log.Logger
)
func init() {
file, err := os.OpenFile("logs.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
log.Fatal(err)
}
InfoLogger = log.New(file, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
WarningLogger = log.New(file, "WARNING: ", log.Ldate|log.Ltime|log.Lshortfile)
ErrorLogger = log.New(file, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
configFile, err := os.Open("config.json")
defer configFile.Close()
if err != nil {
log.Fatal(err)
}
jsonParser := json.NewDecoder(configFile)
jsonParser.Decode(&config)
CreateWebhookClient(config.Webhook)
}
func main() {
UpdateAvailableBalance()
login()
fetchPrices()
go RunDmarket(config.MonitorDelay, "p2p")
go RunDmarket(config.MonitorDelay, "dmarket")
go RunSkinport()
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
}