diff --git a/README.md b/README.md index bd5a436..3cebbb9 100644 --- a/README.md +++ b/README.md @@ -95,5 +95,7 @@ Initial release ### v2 -CTCP messages will no longer be rewritten. The decision was made that this -library should not rewrite messages. +- CTCP messages will no longer be rewritten. The decision was made that this + library should pass through all messages without mangling them. +- Remove Message.FromChannel as this is not always accurate, while + Client.FromChannel should always be accurate. diff --git a/parser.go b/parser.go index 8ec439d..819de4d 100644 --- a/parser.go +++ b/parser.go @@ -325,25 +325,6 @@ func (m *Message) Trailing() string { return m.Params[len(m.Params)-1] } -// FromChannel is mostly for PRIVMSG messages (and similar derived -// messages) It will check if the message came from a channel or a -// person. This is not always accurate, because some servers allow for -// other characters at the start of a channel. -// -// TODO: Remove in favor of *Client.FromChannel(*Message) -func (m *Message) FromChannel() bool { - if len(m.Params) < 1 || len(m.Params[0]) < 1 { - return false - } - - switch m.Params[0][0] { - case '#', '&': - return true - default: - return false - } -} - // Copy will create a new copy of an message func (m *Message) Copy() *Message { // Create a new message diff --git a/parser_test.go b/parser_test.go index 54c0251..e25ae71 100644 --- a/parser_test.go +++ b/parser_test.go @@ -68,19 +68,6 @@ func TestMessageTrailing(t *testing.T) { assert.Equal(t, "", m.Trailing()) } -func TestMessageFromChan(t *testing.T) { - t.Parallel() - - m := MustParseMessage("PRIVMSG #test-msg :hello world") - assert.True(t, m.FromChannel(), "Wrong FromChannel value") - - m = MustParseMessage("PRIVMSG bot :hello world") - assert.False(t, m.FromChannel(), "Wrong FromChannel value") - - m = MustParseMessage("PING") - assert.False(t, m.FromChannel(), "Wrong FromChannel value") -} - func TestMessageCopy(t *testing.T) { t.Parallel()