X-Git-Url: http://www.git.cypherpunks.ru/?p=goircd.git;a=blobdiff_plain;f=daemon.go;h=1af9712616a383ad1a3b869bf3143e85756dd037;hp=80a3229b4f7ec9735617d5b9835c5a76f7c4c80f;hb=7770e09e68f8dd0991ecd5a32383a89ac3e50857;hpb=e657ffd2ab2cd5fae8c1d19e39b2268fa758153e diff --git a/daemon.go b/daemon.go index 80a3229..1af9712 100644 --- a/daemon.go +++ b/daemon.go @@ -67,7 +67,7 @@ func SendMotd(client *Client) { return } client.ReplyNicknamed("375", "- "+*hostname+" Message of the day -") - for _, s := range strings.Split(strings.Trim(string(motdText), "\n"), "\n") { + for _, s := range strings.Split(strings.TrimSuffix(string(motdText), "\n"), "\n") { client.ReplyNicknamed("372", "- "+s) } client.ReplyNicknamed("376", "End of /MOTD command") @@ -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") @@ -258,7 +259,7 @@ func HandlerJoin(client *Client, cmd string) { } for roomExisting, roomSink = range roomSinks { if room == *roomExisting.name { - if (roomExisting.key != nil) && (*roomExisting.key != key) { + if (*roomExisting.key != "") && (*roomExisting.key != key) { goto Denied } roomSink <- ClientEvent{client, EventNew, ""} @@ -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} @@ -477,6 +486,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 {