Skip to content

Commit

Permalink
Merge pull request #61 from go-irc/remove-msg-from-chan
Browse files Browse the repository at this point in the history
Remove Message.FromChannel in favor of Client.FromChannel
  • Loading branch information
belak committed Dec 13, 2017
2 parents ae0b4e8 + c4c8efb commit 01e72ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -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.
19 changes: 0 additions & 19 deletions parser.go
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions parser_test.go
Expand Up @@ -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()

Expand Down

0 comments on commit 01e72ff

Please sign in to comment.