Skip to content

Commit

Permalink
Merge branch 'girc-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmeum committed Dec 10, 2018
2 parents 07fc5bd + f765c5c commit 8c2beef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions hii.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bufio"
"bytes"
"crypto/tls"
"crypto/x509"
"flag"
Expand Down Expand Up @@ -227,7 +228,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)
}

Expand All @@ -252,7 +253,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)
Expand All @@ -274,7 +275,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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -534,7 +538,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)
Expand All @@ -543,7 +547,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]
Expand Down Expand Up @@ -600,9 +605,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)
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/lrstanley/girc
Submodule girc updated 14 files
+24 −30 builtin.go
+3 −3 cap.go
+1 −1 cap_tags.go
+7 −1 client.go
+1 −1 client_test.go
+6 −0 commands.go
+4 −2 conn.go
+18 −12 constants.go
+9 −9 ctcp.go
+9 −2 event.go
+1 −1 format.go
+2 −0 format_test.go
+1 −0 go.mod
+6 −4 state.go

0 comments on commit 8c2beef

Please sign in to comment.