From f463eea686aebd9f90bdcb26e6870b8294d3d47e Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Tue, 12 Dec 2017 16:57:39 -0800 Subject: [PATCH 1/2] Small README update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd5a436..9e55f69 100644 --- a/README.md +++ b/README.md @@ -95,5 +95,5 @@ 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. From c4c8efb5fd7ba7acd66063198c9c779e6bfc6841 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Tue, 12 Dec 2017 16:59:10 -0800 Subject: [PATCH 2/2] Remove Message.FromChannel in favor of Client.FromChannel --- README.md | 4 +++- parser.go | 19 ------------------- parser_test.go | 13 ------------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 9e55f69..3cebbb9 100644 --- a/README.md +++ b/README.md @@ -96,4 +96,6 @@ Initial release ### v2 - CTCP messages will no longer be rewritten. The decision was made that this -library should pass through all messages without mangling them. + 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()