Binato/server/Packets/SendPrivateMessage.js

19 lines
642 B
JavaScript
Raw Normal View History

2020-09-02 10:57:12 +01:00
const osu = require("osu-packet"),
getUserByUsername = require("../util/getUserByUsername.js");
2021-01-26 12:26:46 +00:00
module.exports = function(CurrentUser, CurrentPacket) {
2020-09-02 10:57:12 +01:00
const osuPacketWriter = new osu.Bancho.Writer;
2021-09-24 01:39:46 +01:00
const userSentTo = getUserByUsername(CurrentPacket.target);
if (userSentTo == null) return;
2020-09-02 10:57:12 +01:00
osuPacketWriter.SendMessage({
sendingClient: CurrentUser.username,
2021-09-24 01:39:46 +01:00
message: CurrentPacket.message,
2020-09-02 11:28:50 +01:00
target: CurrentUser.username,
2020-09-02 10:57:12 +01:00
senderId: CurrentUser.id
});
// Write chat message to stream asociated with chat channel
return userSentTo.addActionToQueue(osuPacketWriter.toBuffer);
}