Skip to content

Commit

Permalink
Stop rewriting CTCP PRIVMSG messages
Browse files Browse the repository at this point in the history
  • Loading branch information
belak committed Dec 12, 2017
1 parent cbbf18f commit ca4d52d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
10 changes: 0 additions & 10 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ var clientFilters = map[string]func(*Client, *Message){
}
}
},
"PRIVMSG": func(c *Client, m *Message) {
// Clean up CTCP stuff so everyone doesn't have to parse it
// manually.
lastArg := m.Trailing()
lastIdx := len(lastArg) - 1
if lastIdx > 0 && lastArg[0] == '\x01' && lastArg[lastIdx] == '\x01' {
m.Command = "CTCP"
m.Params[len(m.Params)-1] = lastArg[1:lastIdx]
}
},
"NICK": func(c *Client, m *Message) {
if m.Prefix.Name == c.currentNick && len(m.Params) > 0 {
c.currentNick = m.Params[0]
Expand Down
33 changes: 0 additions & 33 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,39 +157,6 @@ func TestClientHandler(t *testing.T) {
Params: []string{"hello_world"},
},
}, handler.Messages())

// Ensure CTCP messages are parsed
runClientTest(t, config, io.EOF, []TestAction{
ExpectLine("PASS :test_pass\r\n"),
ExpectLine("NICK :test_nick\r\n"),
ExpectLine("USER test_user 0.0.0.0 0.0.0.0 :test_name\r\n"),
SendLine(":world PRIVMSG :\x01VERSION\x01\r\n"),
})
assert.EqualValues(t, []*Message{
{
Tags: Tags{},
Prefix: &Prefix{Name: "world"},
Command: "CTCP",
Params: []string{"VERSION"},
},
}, handler.Messages())

// CTCP Regression test for PR#47
// Proper CTCP should start AND end in \x01
runClientTest(t, config, io.EOF, []TestAction{
ExpectLine("PASS :test_pass\r\n"),
ExpectLine("NICK :test_nick\r\n"),
ExpectLine("USER test_user 0.0.0.0 0.0.0.0 :test_name\r\n"),
SendLine(":world PRIVMSG :\x01VERSION\r\n"),
})
assert.EqualValues(t, []*Message{
{
Tags: Tags{},
Prefix: &Prefix{Name: "world"},
Command: "PRIVMSG",
Params: []string{"\x01VERSION"},
},
}, handler.Messages())
}

func TestFromChannel(t *testing.T) {
Expand Down

0 comments on commit ca4d52d

Please sign in to comment.