mirror of https://github.com/fluffle/goirc
Fixed logic bug, but it's a bit ugly :-/
This commit is contained in:
parent
4c0f62666d
commit
d74fd18d3d
|
@ -125,7 +125,12 @@ func (conn *Conn) h_PART(line *Line) {
|
||||||
ch := conn.GetChannel(line.Args[0])
|
ch := conn.GetChannel(line.Args[0])
|
||||||
n := conn.GetNick(line.Nick)
|
n := conn.GetNick(line.Nick)
|
||||||
if ch != nil && n != nil {
|
if ch != nil && n != nil {
|
||||||
ch.DelNick(n)
|
if _, ok := ch.Nicks[n]; ok {
|
||||||
|
ch.DelNick(n)
|
||||||
|
} else {
|
||||||
|
conn.error("irc.PART(): nick %s is not on channel %s",
|
||||||
|
line.Nick, line.Args[0])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
conn.error("irc.PART(): buh? PART of channel %s by nick %s",
|
conn.error("irc.PART(): buh? PART of channel %s by nick %s",
|
||||||
line.Args[0], line.Nick)
|
line.Args[0], line.Nick)
|
||||||
|
|
|
@ -227,14 +227,9 @@ func TestPART(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test error states.
|
// Test error states.
|
||||||
// TODO(fluffle): BUG?
|
// Part a known user from a known channel they are not on.
|
||||||
// user1 is still a known Nick (on #test2), but receiving another PART
|
|
||||||
// for user1 from #test1 (or, in fact, a PART on any known Channel, whether
|
|
||||||
// they are on it or not) won't cause an error because h_PART doesn't
|
|
||||||
// check whether the Nick is on the Channel before calling DelNick().
|
|
||||||
// The Nick and Channel structs should expose more of the state info.
|
|
||||||
c.h_PART(parseLine(":user1!ident1@host1.com PART #test1 :Bye!"))
|
c.h_PART(parseLine(":user1!ident1@host1.com PART #test1 :Bye!"))
|
||||||
c.ExpectNoErrors()
|
c.ExpectError()
|
||||||
|
|
||||||
// Part an unknown user from a known channel.
|
// Part an unknown user from a known channel.
|
||||||
c.h_PART(parseLine(":user2!ident2@host2.com PART #test1 :Bye!"))
|
c.h_PART(parseLine(":user2!ident2@host2.com PART #test1 :Bye!"))
|
||||||
|
|
Loading…
Reference in New Issue