forked from lain-dono/hath
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
183 lines (149 loc) · 4.08 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
package main
import (
"github.com/kutabe/hath/api"
"github.com/kutabe/hath/cache"
"github.com/kutabe/hath/util"
"github.com/Sirupsen/logrus"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
)
var Client *api.API
var CacheHandler *cache.Handler
var log = util.Logger()
func main() {
done := exitHandler()
defer func() {
err := recover()
if err != nil {
//log.Fatal("Failed to initialize InputQueryHandler")
}
}()
log.Infof(copyright, api.CLIENT_VERSION, api.CLIENT_BUILD)
log.Info("Logging in to main server...")
log.Info("Initializing cache handler...")
CacheHandler = cache.NewHandler("./cache", "./tmp", "data.db")
log.Info(CacheHandler)
Client = api.New(api.CLIENT_API_URL)
if login, err := loadClientLoginFromFile("client_login"); err == nil {
log.Infof("Loaded login settings from %s", "client_login")
Client.Login = login
}
//id, key := promptForIDAndKey()
//log.Print(id, key)
//if !Settings.loginCredentialsAreSyntaxValid() {
//Settings.promptForIDAndKey(iqh);
//}
log.Infof("Connecting to the Hentai@Home Server to register client with ID %d...", Client.Id)
s, err := Client.RefreshServerStat()
if err != nil {
log.Fatal("Failed to get initial stat from server. ", err)
}
parseAndUpdateSettings(s)
for {
settings, _ := Client.LoadClientSettingsFromServer()
parseAndUpdateSettings(settings)
break
}
//CacheHandler.Initialize()
//CacheHandler.FlushRecentlyAccessed()
//
//log.Print(s)
//InputQueryHandler iqh = nil;
//try {
//iqh = InputQueryHandlerCLI.getIQHCLI();
//new HentaiAtHomeClient(iqh, args);
//} catch(Exception e) {
//Out.error("Failed to initialize InputQueryHandler");
//}
for i := 0; i < 5; i++ {
//log.Debug("vfds")
//log.Info("vfdsnjkl")
//log.Warn("-")
//log.Error("-")
}
log.Info("WAIT")
<-done
log.Print("done")
rand.Seed(time.Now().UnixNano())
if rand.Float64() > 0.99 {
log.Info(heart)
} else {
log.Info(exitMsgs[rand.Intn(len(exitMsgs))])
}
return
// FATAL
for {
log.WithFields(logrus.Fields{
"animal": "walrus",
"size": "10",
}).Print("To invoke the hive-mind representing chaos.")
log.WithFields(logrus.Fields{
"omg": true,
"number": 122,
}).Warn("Invoking the feeling of chaos.")
log.WithFields(logrus.Fields{
"animal": "walrus",
"size": "10",
}).Print("With out order.")
log.WithFields(logrus.Fields{
"animal": "walrus",
"size": "9",
}).Error("The Nezperdian hive-mind of chaos. Zalgo.")
log.WithFields(logrus.Fields{
"omg": true,
"number": 100,
}).Warn("He who Waits Behind The Wall.")
log.Fatal("ZALGO !")
}
}
func exitHandler() (done chan bool) {
done = make(chan bool, 1)
sigs := make(chan os.Signal, 1)
//signal.Notify(sigs, syscall.Interrupt, syscall.SIGTERM)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
for sig := range sigs {
log.Warnf("captured %v", sig)
//os.Exit(1)
done <- true
}
}()
return
}
const heart = `
.,---.
,/XM#MMMX;,
-%##########M%,
-@######% $###@=
.,--, -H#######$ $###M:
,;$M###MMX; .;##########$;HM###X=
,/@##########H= ;################+
-+#############M/, %##############+
%M###############= /##############:
H################ .M#############;.
@###############M ,@###########M:.
X################, -$=X#######@:
/@##################%- +######$-
.;##################X .X#####+,
.;H################/ -X####+.
,;X##############, .MM/
,:+$H@M#######M#$- .$$=
.,-=;+$@###X: ;/=.
.,/X$; .::,
., ..
`
var exitMsgs = []string{
"I don't hate you",
"Whyyyyyyyy...",
"No hard feelings",
"Your business is appreciated",
"Good-night",
}
const copyright = `Hentai@Home %s:%d starting up
Copyright (c) 2008-2014, E-Hentai.org - all rights reserved.
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to modify and redistribute it under the GPL v3 license.
`