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) { socket.on('motd', function(data) {
_.each(data.content.split('\n'), function(line) { _.each(data.content, function(line) {
messageActions.add({ messageActions.add({
server: data.server, server: data.server,
to: data.server, to: data.server,

View File

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

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"bytes"
"log" "log"
"strings" "strings"
@ -11,7 +10,6 @@ import (
func handleMessages(irc *IRC, session *Session) { func handleMessages(irc *IRC, session *Session) {
userBuffers := make(map[string][]string) userBuffers := make(map[string][]string)
var motd MOTD var motd MOTD
var motdContent bytes.Buffer
for msg := range irc.Messages { for msg := range irc.Messages {
switch msg.Command { switch msg.Command {
@ -151,15 +149,11 @@ func handleMessages(irc *IRC, session *Session) {
motd.Title = msg.Trailing motd.Title = msg.Trailing
case RPL_MOTD: case RPL_MOTD:
motdContent.WriteString(msg.Trailing) motd.Content = append(motd.Content, msg.Trailing)
motdContent.WriteRune('\n')
case RPL_ENDOFMOTD: case RPL_ENDOFMOTD:
motd.Content = motdContent.String()
session.sendJSON("motd", motd) session.sendJSON("motd", motd)
motdContent.Reset()
motd = MOTD{} motd = MOTD{}
default: default: