From 1c30da547490ef7e9ecb6c39bce6af8aba0c34e4 Mon Sep 17 00:00:00 2001 From: khlieng Date: Sun, 1 Feb 2015 02:08:38 +0100 Subject: [PATCH] MOTD now gets sent as an array of lines --- client/src/js/irc.js | 2 +- json_types.go | 6 +++--- message_handler.go | 8 +------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/client/src/js/irc.js b/client/src/js/irc.js index 537509bd..e9f1c41a 100644 --- a/client/src/js/irc.js +++ b/client/src/js/irc.js @@ -34,7 +34,7 @@ socket.on('pm', function(data) { }); socket.on('motd', function(data) { - _.each(data.content.split('\n'), function(line) { + _.each(data.content, function(line) { messageActions.add({ server: data.server, to: data.server, diff --git a/json_types.go b/json_types.go index ae281a7c..9867d091 100644 --- a/json_types.go +++ b/json_types.go @@ -72,9 +72,9 @@ type Userlist struct { } type MOTD struct { - Server string `json:"server"` - Title string `json:"title"` - Content string `json:"content"` + Server string `json:"server"` + Title string `json:"title"` + Content []string `json:"content"` } type Error struct { diff --git a/message_handler.go b/message_handler.go index 14db63e8..fb77edf4 100644 --- a/message_handler.go +++ b/message_handler.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "log" "strings" @@ -11,7 +10,6 @@ import ( func handleMessages(irc *IRC, session *Session) { userBuffers := make(map[string][]string) var motd MOTD - var motdContent bytes.Buffer for msg := range irc.Messages { switch msg.Command { @@ -151,15 +149,11 @@ func handleMessages(irc *IRC, session *Session) { motd.Title = msg.Trailing case RPL_MOTD: - motdContent.WriteString(msg.Trailing) - motdContent.WriteRune('\n') + motd.Content = append(motd.Content, msg.Trailing) case RPL_ENDOFMOTD: - motd.Content = motdContent.String() - session.sendJSON("motd", motd) - motdContent.Reset() motd = MOTD{} default: