2020-09-02 10:57:12 +01:00
|
|
|
const osu = require("osu-packet"),
|
2022-01-04 03:39:53 +00:00
|
|
|
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) {
|
2022-01-04 03:39:53 +00:00
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
|
|
|
const userSentTo = getUserByUsername(CurrentPacket.target);
|
2021-09-03 21:12:25 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
if (userSentTo == null) return;
|
2020-09-02 10:57:12 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
osuPacketWriter.SendMessage({
|
|
|
|
sendingClient: CurrentUser.username,
|
|
|
|
message: CurrentPacket.message,
|
|
|
|
target: CurrentUser.username,
|
|
|
|
senderId: CurrentUser.id
|
|
|
|
});
|
2020-09-02 10:57:12 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Write chat message to stream asociated with chat channel
|
|
|
|
return userSentTo.addActionToQueue(osuPacketWriter.toBuffer);
|
2020-09-02 10:57:12 +01:00
|
|
|
}
|