]> Cypherpunks.ru repositories - goircd.git/blobdiff - daemon.go
Raise copyright years
[goircd.git] / daemon.go
index 3afda4fb0a3d8b69897e8e160cf09e4c77af6ab4..b5c3e56f3e97ad6f933436f55b6ad89eb68f3e3c 100644 (file)
--- a/daemon.go
+++ b/daemon.go
@@ -1,6 +1,6 @@
 /*
 goircd -- minimalistic simple Internet Relay Chat (IRC) server
-Copyright (C) 2014-2015 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -162,6 +162,7 @@ func ClientRegister(client *Client, cmd string, cols []string) {
                nickname := cols[1]
                // Compatibility with some clients prepending colons to nickname
                nickname = strings.TrimPrefix(nickname, ":")
+               nickname = strings.ToLower(nickname)
                for existingClient := range clients {
                        if *existingClient.nickname == nickname {
                                client.ReplyParts("433", "*", nickname, "Nickname is already in use")
@@ -308,6 +309,14 @@ func Processor(events chan ClientEvent, finished chan struct{}) {
                                        }
                                }
                        }
+                       for rn, r := range rooms {
+                               if *statedir == "" && len(r.members) == 0 {
+                                       log.Println(rn, "emptied room")
+                                       delete(rooms, rn)
+                                       close(roomSinks[r])
+                                       delete(roomSinks, r)
+                               }
+                       }
                case EventTerm:
                        for _, sink := range roomSinks {
                                sink <- ClientEvent{eventType: EventTerm}
@@ -337,6 +346,9 @@ func Processor(events chan ClientEvent, finished chan struct{}) {
                                ClientRegister(client, cmd, cols)
                                continue
                        }
+                       if client != nil {
+                               client.recvTimestamp = now
+                       }
                        switch cmd {
                        case "AWAY":
                                if len(cols) == 1 {
@@ -477,6 +489,22 @@ func Processor(events chan ClientEvent, finished chan struct{}) {
                                cols := strings.Split(cols[1], " ")
                                nicknames := strings.Split(cols[len(cols)-1], ",")
                                SendWhois(client, nicknames)
+                       case "ISON":
+                               if len(cols) == 1 || len(cols[1]) < 1 {
+                                       client.ReplyNotEnoughParameters("ISON")
+                                       continue
+                               }
+                               nicksKnown := make(map[string]struct{})
+                               for c := range clients {
+                                       nicksKnown[*c.nickname] = struct{}{}
+                               }
+                               var nicksExists []string
+                               for _, nickname := range strings.Split(cols[1], " ") {
+                                       if _, exists := nicksKnown[nickname]; exists {
+                                               nicksExists = append(nicksExists, nickname)
+                                       }
+                               }
+                               client.ReplyNicknamed("303", strings.Join(nicksExists, " "))
                        case "VERSION":
                                var debug string
                                if *verbose {
@@ -489,8 +517,5 @@ func Processor(events chan ClientEvent, finished chan struct{}) {
                                client.ReplyNicknamed("421", cmd, "Unknown command")
                        }
                }
-               if client != nil {
-                       client.recvTimestamp = now
-               }
        }
 }