|
@@ -72,6 +72,19 @@ type IRCConfig struct {
|
|
|
Registered bool
|
|
|
ISupport map[string]string // 005
|
|
|
wg sync.WaitGroup
|
|
|
+ Mutex sync.Mutex
|
|
|
+}
|
|
|
+
|
|
|
+func (Config *IRCConfig) GetNick() string {
|
|
|
+ Config.Mutex.Lock()
|
|
|
+ defer Config.Mutex.Unlock()
|
|
|
+ return Config.MyNick
|
|
|
+}
|
|
|
+
|
|
|
+func (Config *IRCConfig) SetNick(nick string) {
|
|
|
+ Config.Mutex.Lock()
|
|
|
+ defer Config.Mutex.Unlock()
|
|
|
+ Config.MyNick = nick
|
|
|
}
|
|
|
|
|
|
// Writer *bufio.Writer
|
|
@@ -217,9 +230,12 @@ func (Config *IRCConfig) WriterRoutine() {
|
|
|
if !gotSignal {
|
|
|
gotSignal = true
|
|
|
log.Println("SIGNAL")
|
|
|
- if Config.OnExit != nil {
|
|
|
- Config.OnExit()
|
|
|
- }
|
|
|
+ /*
|
|
|
+ // This should be handled now by Close().
|
|
|
+ if Config.OnExit != nil {
|
|
|
+ Config.OnExit()
|
|
|
+ }
|
|
|
+ */
|
|
|
Config.PriorityWrite("QUIT :Received SIGINT")
|
|
|
}
|
|
|
// return
|
|
@@ -254,9 +270,12 @@ func (Config *IRCConfig) WriterRoutine() {
|
|
|
if !gotSignal {
|
|
|
gotSignal = true
|
|
|
log.Println("SIGNAL")
|
|
|
- if Config.OnExit != nil {
|
|
|
- Config.OnExit()
|
|
|
- }
|
|
|
+ /*
|
|
|
+ // This should now be handled by Close().
|
|
|
+ if Config.OnExit != nil {
|
|
|
+ Config.OnExit()
|
|
|
+ }
|
|
|
+ */
|
|
|
Config.PriorityWrite("QUIT :Received SIGINT")
|
|
|
}
|
|
|
// return
|
|
@@ -301,6 +320,9 @@ func (Config *IRCConfig) WriterRoutine() {
|
|
|
func (Config *IRCConfig) Close() {
|
|
|
Config.Socket.Close()
|
|
|
Config.PriorityWrite("")
|
|
|
+ if Config.OnExit != nil {
|
|
|
+ Config.OnExit()
|
|
|
+ }
|
|
|
Config.wg.Wait()
|
|
|
}
|
|
|
|
|
@@ -580,7 +602,7 @@ func (Config *IRCConfig) ReaderRoutine() {
|
|
|
// :meow NICK :meow-bot
|
|
|
|
|
|
if msg.From == Config.MyNick {
|
|
|
- Config.MyNick = msg.To
|
|
|
+ Config.SetNick(msg.To)
|
|
|
log.Println("Nick is now:", Config.MyNick)
|
|
|
}
|
|
|
}
|