Compare commits
No commits in common. "32e62376809f2ee4de8a2585d55b143737d2c0a9" and "96f36577c34824b90f8aff76b2c190f3ea3aae0c" have entirely different histories.
32e6237680
...
96f36577c3
13
main.go
13
main.go
@ -16,7 +16,6 @@ import (
|
|||||||
type config struct {
|
type config struct {
|
||||||
Horn map[string]string `yaml:"horn"`
|
Horn map[string]string `yaml:"horn"`
|
||||||
Times []string `yaml:"times"`
|
Times []string `yaml:"times"`
|
||||||
Days []string `yaml:"days"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *config) getConf() *config {
|
func (config *config) getConf() *config {
|
||||||
@ -32,7 +31,7 @@ func (config *config) getConf() *config {
|
|||||||
logger.Error("Unmarshal", logger.Args(":", err))
|
logger.Error("Unmarshal", logger.Args(":", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Config loaded", logger.Args("Times", config.Times, "Days", config.Days, "API URL", config.Horn["url"]))
|
logger.Info("Config loaded", logger.Args("Times", config.Times, "API URL", config.Horn["url"]))
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ func main() {
|
|||||||
|
|
||||||
pterm.DefaultCenter.Println(s)
|
pterm.DefaultCenter.Println(s)
|
||||||
pterm.DefaultCenter.Println("By Cody (" + pterm.LightBlue("https://oki.cx/tree") + ")")
|
pterm.DefaultCenter.Println("By Cody (" + pterm.LightBlue("https://oki.cx/tree") + ")")
|
||||||
pterm.DefaultCenter.Println("v1.2")
|
pterm.DefaultCenter.Println("v1.1")
|
||||||
|
|
||||||
pterm.Print("\n")
|
pterm.Print("\n")
|
||||||
|
|
||||||
@ -61,10 +60,7 @@ func main() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
ctime := time.Now().Format("15:04:05")
|
ctime := time.Now().Format("15:04:05")
|
||||||
cday := time.Now().Weekday()
|
|
||||||
|
|
||||||
for _, day := range config.Days {
|
|
||||||
if day == cday.String() {
|
|
||||||
for _, time := range config.Times {
|
for _, time := range config.Times {
|
||||||
if time == ctime {
|
if time == ctime {
|
||||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
@ -85,10 +81,7 @@ func main() {
|
|||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
logger.Error(fmt.Sprintf("HTTP request failed: %s", resp.Status))
|
logger.Error(fmt.Sprintf("HTTP request failed: %s", resp.Status))
|
||||||
} else {
|
} else {
|
||||||
logger.Info(fmt.Sprintf("Sending HTTP request to %s", config.Horn["url"]),
|
logger.Info(fmt.Sprintf("Sending HTTP request to %s", config.Horn["url"]), logger.Args("Reason", "Config File", "Time", ctime, "Status Code", resp.Status))
|
||||||
logger.Args("Reason", "Config File", "Time", ctime, "Status Code", resp.Status))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user