From 8f378670ed95b47e6abbda7e0e0f7e310dbc0b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 10 Dec 2018 17:12:04 +0100 Subject: [PATCH 1/4] vendor: update girc submodule Includes various fixes. Most importantly the original capitalization of nick names is now retained. --- vendor/github.com/lrstanley/girc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/github.com/lrstanley/girc b/vendor/github.com/lrstanley/girc index 3a1cc73..514d004 160000 --- a/vendor/github.com/lrstanley/girc +++ b/vendor/github.com/lrstanley/girc @@ -1 +1 @@ -Subproject commit 3a1cc735c7c5414fc62be60ab52a11de0895eb90 +Subproject commit 514d004b74d6e6cd42beb2d99557dd4b85d0550e From 68054fefbb835b93591f6ef4da2e1e8ac4dd06e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 10 Dec 2018 17:14:02 +0100 Subject: [PATCH 2/4] addHandlers: Remove DISCONNECTED handler We invoke cleanup() unconditionally in main. This handler is invoked before client.Connect() returns. Thus we invoke cleanup() twice. Before the girc submodule update this wasn't an issue as the handler was never invoked. See: https://github.com/lrstanley/girc/issues/26 --- hii.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/hii.go b/hii.go index 8b023d0..17c4704 100644 --- a/hii.go +++ b/hii.go @@ -600,9 +600,6 @@ func addHandlers(client *girc.Client) { c.Cmd.Join(channels...) } }) - client.Handlers.Add(girc.DISCONNECTED, func(c *girc.Client, e girc.Event) { - cleanup() - }) client.Handlers.Add(girc.PART, handlePart) client.Handlers.Add(girc.KICK, handleKick) From e42ac1da993810d08e6d4a4cd9eb3972ce3c8ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 10 Dec 2018 19:58:07 +0100 Subject: [PATCH 3/4] Compare IDs not names Where IDs are RFC 1459 compliant nicks. --- hii.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hii.go b/hii.go index 17c4704..a3534e4 100644 --- a/hii.go +++ b/hii.go @@ -227,7 +227,7 @@ func appendFile(filename string, data []byte, perm os.FileMode) error { func isMention(client *girc.Client, event *girc.Event) bool { return event.IsFromUser() && - event.Source.Name != client.GetNick() || + event.Source.ID() != client.GetID() || mntRegex.MatchString(event.Trailing) } @@ -252,7 +252,7 @@ func getSourceDirs(client *girc.Client, event *girc.Event) ([]*string, error) { } user := client.LookupUser(event.Source.Name) - if user == nil && client.GetNick() == event.Source.Name { + if user == nil && client.GetID() == event.Source.ID() { return names, nil // User didn't join any channels yet } else if user == nil { return names, fmt.Errorf("user %q doesn't exist", event.Source.Name) @@ -274,7 +274,7 @@ func getEventDirs(client *girc.Client, event *girc.Event) ([]*string, error) { name = event.Params[0] } else if event.IsFromUser() { name = event.Source.Name - if name == client.GetNick() { + if event.Source.ID() == client.GetID() { name = event.Params[0] } } else { @@ -534,7 +534,7 @@ func handlePart(client *girc.Client, event girc.Event) { } name := event.Params[0] - if event.Source.Name == client.GetNick() { + if event.Source.ID() == client.GetID() { err := removeListener(name) if err != nil { log.Printf("Couldn't remove %q after part: %s\n", name, err) @@ -543,7 +543,8 @@ func handlePart(client *girc.Client, event girc.Event) { } func handleKick(client *girc.Client, event girc.Event) { - if len(event.Params) < 2 || event.Params[1] != client.GetNick() { + if len(event.Params) < 2 || + girc.ToRFC1459(event.Params[1]) != client.GetID() { return } name := event.Params[0] From f765c5c86968e59348c54360a751c5787c495c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 10 Dec 2018 21:57:22 +0100 Subject: [PATCH 4/4] serveNicks: Serve nicks in their original format Not in an RFC1459 compliant format. See also: https://github.com/lrstanley/girc/issues/23 --- hii.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hii.go b/hii.go index a3534e4..6a9b2c2 100644 --- a/hii.go +++ b/hii.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "bytes" "crypto/tls" "crypto/x509" "flag" @@ -463,8 +464,11 @@ func serveNicks(client *girc.Client, name string, dir *ircDir) { ch := client.LookupChannel(name) if ch != nil { - users := strings.Join(ch.UserList, "\n") - _, err = conn.Write([]byte(users + "\n")) + var b bytes.Buffer + for _, user := range ch.Users(client) { + b.WriteString(user.Nick + "\n") + } + _, err = conn.Write(b.Bytes()) if err != nil { log.Println(err) }