MOTD now gets sent as an array of lines
This commit is contained in:
parent
736ef76bc0
commit
1c30da5474
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user