Moved user interactions to separate goroutine
This commit is contained in:
parent
4d2dbe71e9
commit
340e193ab6
@ -145,7 +145,7 @@ func StringOscillator(s string, amplitude int) chan string {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClickRepeteadly(s *SavedGroups) {
|
func ClickRepeteadly(s *SavedGroups, c chan os.Signal) {
|
||||||
for index, g := range s.Groups {
|
for index, g := range s.Groups {
|
||||||
fmt.Printf("- Press %v to select %v\n", index+1, g.Name)
|
fmt.Printf("- Press %v to select %v\n", index+1, g.Name)
|
||||||
}
|
}
|
||||||
@ -188,6 +188,7 @@ func ClickRepeteadly(s *SavedGroups) {
|
|||||||
}
|
}
|
||||||
if t >= 10 {
|
if t >= 10 {
|
||||||
fmt.Println("You stayed away too long, exiting...")
|
fmt.Println("You stayed away too long, exiting...")
|
||||||
|
c <- os.Interrupt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,15 +204,19 @@ func cleanUp(c chan os.Signal) chan int {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func interactWithUser(s *SavedGroups, yamlFile string, c chan os.Signal) {
|
||||||
|
addSavedGroup(s)
|
||||||
|
storeSavedGroups(s, yamlFile)
|
||||||
|
ClickRepeteadly(s, c)
|
||||||
|
}
|
||||||
|
|
||||||
func RunAutoClicker() {
|
func RunAutoClicker() {
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
quit := cleanUp(c)
|
quit := cleanUp(c)
|
||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
yamlFile := "SavedGroups.yaml"
|
yamlFile := "SavedGroups.yaml"
|
||||||
s := getSavedGroups(yamlFile)
|
s := getSavedGroups(yamlFile)
|
||||||
addSavedGroup(s)
|
go interactWithUser(s, yamlFile, c)
|
||||||
storeSavedGroups(s, yamlFile)
|
|
||||||
go ClickRepeteadly(s)
|
|
||||||
if <-quit == 1 {
|
if <-quit == 1 {
|
||||||
fmt.Println("Exiting...")
|
fmt.Println("Exiting...")
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user