Binato/server/Packets/SendPrivateMessage.js

19 lines
594 B
JavaScript
Raw Permalink Normal View History

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