Skip to content

Commit

Permalink
Merge pull request #59 from go-irc/remove-privmsg-rewriting
Browse files Browse the repository at this point in the history
Stop rewriting CTCP PRIVMSG messages
  • Loading branch information
belak committed Dec 13, 2017
2 parents a56998f + 5993377 commit ae0b4e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 44 deletions.
13 changes: 12 additions & 1 deletion README.md
Expand Up @@ -29,7 +29,7 @@ considered stable enough, a new release will be tagged.

As a result of this, there are multiple import locations.

* `gopkg.in/irc.v1` should be used to develop against the commits
* `gopkg.in/irc.v2` should be used to develop against the commits
tagged as stable
* `github.com/go-irc/irc` should be used to develop against the master branch

Expand Down Expand Up @@ -86,3 +86,14 @@ func main() {
}
}
```

## Major Version Changes

### v1

Initial release

### v2

CTCP messages will no longer be rewritten. The decision was made that this
library should not rewrite messages.
10 changes: 0 additions & 10 deletions client.go
Expand Up @@ -47,16 +47,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
Expand Up @@ -179,39 +179,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 ae0b4e8

Please sign in to comment.