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,12 +62,13 @@ func (line *Line) Target() string {
|
|||
// a message to a channel the client has joined instead of directly
|
||||
// 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 {
|
||||
switch line.Cmd {
|
||||
case PRIVMSG, NOTICE, ACTION:
|
||||
if strings.HasPrefix(line.Args[0], "#") {
|
||||
return true
|
||||
switch line.Args[0][0] {
|
||||
case '#', '&', '+', '!': return true
|
||||
}
|
||||
case CTCP, CTCPREPLY:
|
||||
// CTCP prepends the CTCP verb to line.Args, thus for the message
|
||||
|
@ -76,8 +77,8 @@ func (line *Line) Public() bool {
|
|||
// TODO(fluffle): Arguably this is broken, and we should have
|
||||
// line.Args containing: []string{"#foo", "BAR", "baz"}
|
||||
// ... OR change conn.Ctcp()'s argument order to be consistent.
|
||||
if strings.HasPrefix(line.Args[1], "#") {
|
||||
return true
|
||||
switch line.Args[1][0] {
|
||||
case '#', '&', '+', '!': return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -69,8 +69,8 @@ func TestLineTarget(t *testing.T) {
|
|||
{&Line{Cmd: CTCP, Args: []string{"PING", "Me", "1"}, 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: NOTICE, Args: []string{"#foo", "la"}, Nick: "Them"}, "#foo"},
|
||||
{&Line{Cmd: ACTION, 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: CTCP, Args: []string{"PING", "#foo", "1"}, Nick: "Them"}, "#foo"},
|
||||
{&Line{Cmd: CTCPREPLY, Args: []string{"PONG", "#foo", "2"}, Nick: "Them"}, "#foo"},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue