diff --git a/chat/channel_test.go b/chat/channel_test.go index 07e0c8b..de06bce 100644 --- a/chat/channel_test.go +++ b/chat/channel_test.go @@ -50,4 +50,12 @@ func TestChannelJoin(t *testing.T) { if !reflect.DeepEqual(actual, expected) { t.Errorf("Got: `%s`; Expected: `%s`", actual, expected) } + + ch.Send(ParseInput("/me says hello.", u)) + u.ConsumeOne(s) + expected = []byte("** foo says hello." + Newline) + s.Read(&actual) + if !reflect.DeepEqual(actual, expected) { + t.Errorf("Got: `%s`; Expected: `%s`", actual, expected) + } } diff --git a/chat/command.go b/chat/command.go index 0fe6a79..23df6e2 100644 --- a/chat/command.go +++ b/chat/command.go @@ -40,6 +40,8 @@ func init() { me := strings.TrimLeft(msg.body, "/me") if me == "" { me = " is at a loss for words." + } else { + me = me[1:] } channel.Send(NewEmoteMsg(me, msg.From())) diff --git a/chat/message.go b/chat/message.go index 1779cfc..92be95b 100644 --- a/chat/message.go +++ b/chat/message.go @@ -96,13 +96,22 @@ func (m *PublicMsg) String() string { return m.Render(nil) } -// EmoteMsg is a /me message sent to the channel. +// EmoteMsg is a /me message sent to the channel. It specifically does not +// extend PublicMsg because it doesn't implement MessageFrom to allow the +// sender to see the emote. type EmoteMsg struct { - PublicMsg + Msg + from *User } func NewEmoteMsg(body string, from *User) *EmoteMsg { - return &EmoteMsg{*NewPublicMsg(body, from)} + return &EmoteMsg{ + Msg: Msg{ + body: body, + timestamp: time.Now(), + }, + from: from, + } } func (m *EmoteMsg) Render(t *Theme) string {