Skip to content

Commit 01e72ff

Browse files
authored
Merge pull request #61 from go-irc/remove-msg-from-chan
Remove Message.FromChannel in favor of Client.FromChannel
2 parents ae0b4e8 + c4c8efb commit 01e72ff

File tree

3 files changed

+4
-34
lines changed

3 files changed

+4
-34
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@ Initial release
9595

9696
### v2
9797

98-
CTCP messages will no longer be rewritten. The decision was made that this
99-
library should not rewrite messages.
98+
- CTCP messages will no longer be rewritten. The decision was made that this
99+
library should pass through all messages without mangling them.
100+
- Remove Message.FromChannel as this is not always accurate, while
101+
Client.FromChannel should always be accurate.

parser.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -325,25 +325,6 @@ func (m *Message) Trailing() string {
325325
return m.Params[len(m.Params)-1]
326326
}
327327

328-
// FromChannel is mostly for PRIVMSG messages (and similar derived
329-
// messages) It will check if the message came from a channel or a
330-
// person. This is not always accurate, because some servers allow for
331-
// other characters at the start of a channel.
332-
//
333-
// TODO: Remove in favor of *Client.FromChannel(*Message)
334-
func (m *Message) FromChannel() bool {
335-
if len(m.Params) < 1 || len(m.Params[0]) < 1 {
336-
return false
337-
}
338-
339-
switch m.Params[0][0] {
340-
case '#', '&':
341-
return true
342-
default:
343-
return false
344-
}
345-
}
346-
347328
// Copy will create a new copy of an message
348329
func (m *Message) Copy() *Message {
349330
// Create a new message

parser_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ func TestMessageTrailing(t *testing.T) {
6868
assert.Equal(t, "", m.Trailing())
6969
}
7070

71-
func TestMessageFromChan(t *testing.T) {
72-
t.Parallel()
73-
74-
m := MustParseMessage("PRIVMSG #test-msg :hello world")
75-
assert.True(t, m.FromChannel(), "Wrong FromChannel value")
76-
77-
m = MustParseMessage("PRIVMSG bot :hello world")
78-
assert.False(t, m.FromChannel(), "Wrong FromChannel value")
79-
80-
m = MustParseMessage("PING")
81-
assert.False(t, m.FromChannel(), "Wrong FromChannel value")
82-
}
83-
8471
func TestMessageCopy(t *testing.T) {
8572
t.Parallel()
8673

0 commit comments

Comments
 (0)