fixed client.HasQuit and made internal disconnects not setting that flag.

This commit is contained in:
2020-10-18 11:28:05 +02:00
parent f7d53f4c63
commit 6df9233cbc
3 changed files with 34 additions and 18 deletions
+15
View File
@@ -9,7 +9,9 @@ import (
"github.com/gissleh/irc/handlers"
"log"
"os"
"os/signal"
"strings"
"syscall"
"github.com/gissleh/irc"
)
@@ -95,6 +97,10 @@ func main() {
target = client.Target(event.Arg(1), event.Arg(2))
}
if event.Name() == "client.disconnect" {
os.Exit(0)
}
j, err := json.MarshalIndent(event, "", " ")
if err != nil {
return
@@ -103,6 +109,15 @@ func main() {
fmt.Println(string(j))
})
go func() {
exitSignal := make(chan os.Signal)
signal.Notify(exitSignal, os.Interrupt, os.Kill, syscall.SIGTERM)
<-exitSignal
client.Quit("Goodnight.")
}()
reader := bufio.NewReader(os.Stdin)
for {
line, err := reader.ReadString('\n')