MOTD now gets sent as an array of lines

This commit is contained in:
khlieng 2015-02-01 02:08:38 +01:00
parent 736ef76bc0
commit 1c30da5474
3 changed files with 5 additions and 11 deletions

View File

@ -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,

View File

@ -74,7 +74,7 @@ type Userlist struct {
type MOTD struct {
Server string `json:"server"`
Title string `json:"title"`
Content string `json:"content"`
Content []string `json:"content"`
}
type Error struct {

View File

@ -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: