mirror of https://github.com/fluffle/goirc
Support other chantypes in (*Line).Public. Fixes #65.
This commit is contained in:
parent
8101dbaedd
commit
fdb1c8229d
|
@ -62,13 +62,14 @@ func (line *Line) Target() string {
|
||||||
// a message to a channel the client has joined instead of directly
|
// a message to a channel the client has joined instead of directly
|
||||||
// to the client.
|
// to the client.
|
||||||
//
|
//
|
||||||
// NOTE: This makes the (poor) assumption that all channels start with #.
|
// NOTE: This is very permissive, allowing all 4 RFC channel types even if
|
||||||
|
// your server doesn't technically support them.
|
||||||
func (line *Line) Public() bool {
|
func (line *Line) Public() bool {
|
||||||
switch line.Cmd {
|
switch line.Cmd {
|
||||||
case PRIVMSG, NOTICE, ACTION:
|
case PRIVMSG, NOTICE, ACTION:
|
||||||
if strings.HasPrefix(line.Args[0], "#") {
|
switch line.Args[0][0] {
|
||||||
return true
|
case '#', '&', '+', '!': return true
|
||||||
}
|
}
|
||||||
case CTCP, CTCPREPLY:
|
case CTCP, CTCPREPLY:
|
||||||
// CTCP prepends the CTCP verb to line.Args, thus for the message
|
// CTCP prepends the CTCP verb to line.Args, thus for the message
|
||||||
// :nick!user@host PRIVMSG #foo :\001BAR baz\001
|
// :nick!user@host PRIVMSG #foo :\001BAR baz\001
|
||||||
|
@ -76,9 +77,9 @@ func (line *Line) Public() bool {
|
||||||
// TODO(fluffle): Arguably this is broken, and we should have
|
// TODO(fluffle): Arguably this is broken, and we should have
|
||||||
// line.Args containing: []string{"#foo", "BAR", "baz"}
|
// line.Args containing: []string{"#foo", "BAR", "baz"}
|
||||||
// ... OR change conn.Ctcp()'s argument order to be consistent.
|
// ... OR change conn.Ctcp()'s argument order to be consistent.
|
||||||
if strings.HasPrefix(line.Args[1], "#") {
|
switch line.Args[1][0] {
|
||||||
return true
|
case '#', '&', '+', '!': return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ func TestLineTarget(t *testing.T) {
|
||||||
{&Line{Cmd: CTCP, Args: []string{"PING", "Me", "1"}, Nick: "Them"}, "Them"},
|
{&Line{Cmd: CTCP, Args: []string{"PING", "Me", "1"}, Nick: "Them"}, "Them"},
|
||||||
{&Line{Cmd: CTCPREPLY, Args: []string{"PONG", "Me", "2"}, Nick: "Them"}, "Them"},
|
{&Line{Cmd: CTCPREPLY, Args: []string{"PONG", "Me", "2"}, Nick: "Them"}, "Them"},
|
||||||
{&Line{Cmd: PRIVMSG, Args: []string{"#foo", "la"}, Nick: "Them"}, "#foo"},
|
{&Line{Cmd: PRIVMSG, Args: []string{"#foo", "la"}, Nick: "Them"}, "#foo"},
|
||||||
{&Line{Cmd: NOTICE, Args: []string{"#foo", "la"}, Nick: "Them"}, "#foo"},
|
{&Line{Cmd: NOTICE, Args: []string{"&foo", "la"}, Nick: "Them"}, "&foo"},
|
||||||
{&Line{Cmd: ACTION, Args: []string{"#foo", "la"}, Nick: "Them"}, "#foo"},
|
{&Line{Cmd: ACTION, Args: []string{"!foo", "la"}, Nick: "Them"}, "!foo"},
|
||||||
{&Line{Cmd: CTCP, Args: []string{"PING", "#foo", "1"}, Nick: "Them"}, "#foo"},
|
{&Line{Cmd: CTCP, Args: []string{"PING", "#foo", "1"}, Nick: "Them"}, "#foo"},
|
||||||
{&Line{Cmd: CTCPREPLY, Args: []string{"PONG", "#foo", "2"}, Nick: "Them"}, "#foo"},
|
{&Line{Cmd: CTCPREPLY, Args: []string{"PONG", "#foo", "2"}, Nick: "Them"}, "#foo"},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue