diff --git a/API.md b/API.md index a303b0ac..cb7d60b2 100644 --- a/API.md +++ b/API.md @@ -17,7 +17,9 @@ All requests are made as JSON encoded array. All chat messages, except the once you send with `chat` or `mcchat`, will be sent to you in the form: -```["msg", name, message]``` +```["msg", name, message, country, channelId]``` +channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come. +country is the [two-letter country code](https://www.nationsonline.org/oneworld/country_code_list.htm) in lowercase ### Subscribe to online user counter ```["sub", "online"]``` @@ -61,8 +63,9 @@ wait Seconds is the cooldown like in `retpixel` above. (got an extra command because minecraftname gets resolved to linked pixelplanet user if possible) ### Send Chat Message -```["chat", name, message]``` +```["chat", name, message, country, channelId]``` +channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come. (messages with the name "info" will be displayed as red notifications in the chat window) ### Link Minecraft Account to pixelplanet Account ```["linkacc", minecraftid, minecraftname, pixelplanetname]``` diff --git a/src/socket/APISocketServer.js b/src/socket/APISocketServer.js index cbc25e79..a5e5e567 100644 --- a/src/socket/APISocketServer.js +++ b/src/socket/APISocketServer.js @@ -90,9 +90,9 @@ class APISocketServer extends WebSocketEvents { sendapi, ws = null, ) { - if (!sendapi || channelId !== 0) return; + if (!sendapi) return; - const sendmsg = JSON.stringify(['msg', name, msg]); + const sendmsg = JSON.stringify(['msg', name, msg, country, channelId]); this.wss.clients.forEach((client) => { if (client !== ws && client.subChat @@ -250,9 +250,9 @@ class APISocketServer extends WebSocketEvents { return; } if (command == 'chat') { - const [name, msg] = packet; - chatProvider.broadcastChatMessage(name, msg, 'xx', 0, false); - this.broadcastChatMessage(name, msg, 'xx', 0, true, ws); + const [name, msg, country, channelId] = packet; + chatProvider.broadcastChatMessage(name, msg, country, channelId, false); + this.broadcastChatMessage(name, msg, country, channelId, true, ws); return; } if (command == 'linkacc') {