Skip to content

Commit

Permalink
Remove Message.FromChannel in favor of Client.FromChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
belak committed Dec 13, 2017
1 parent f463eea commit c4c8efb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
19 changes: 0 additions & 19 deletions parser.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 c4c8efb

Please sign in to comment.