2020-11-03 02:08:57 +00:00
|
|
|
const osu = require("osu-packet"),
|
2022-01-04 03:39:53 +00:00
|
|
|
botCommandHandler = require("../BotCommandHandler.js"),
|
|
|
|
consoleHelper = require("../../consoleHelper.js");
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2021-01-26 12:26:46 +00:00
|
|
|
module.exports = function(CurrentUser, CurrentPacket) {
|
2022-01-04 03:39:53 +00:00
|
|
|
let isSendingChannelLocked = false;
|
|
|
|
for (let i = 0; i < global.channels.length; i++) {
|
|
|
|
if (!CurrentPacket.target.includes("#")) break;
|
|
|
|
if (global.channels[i].channelName == CurrentPacket.target) {
|
|
|
|
isSendingChannelLocked = global.channels[i].locked;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:08:57 +00:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
if (isSendingChannelLocked) {
|
|
|
|
if (CurrentPacket.message.includes("!")) {
|
|
|
|
botCommandHandler(CurrentUser, CurrentPacket.message, CurrentPacket.target);
|
|
|
|
} else {
|
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
|
|
|
osuPacketWriter.SendMessage({
|
|
|
|
sendingClient: global.users["bot"].username,
|
|
|
|
message: "The channel you are currently trying to send to is locked, please check back later!",
|
|
|
|
target: CurrentPacket.target,
|
|
|
|
senderId: global.users["bot"].id
|
|
|
|
});
|
|
|
|
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-11-03 02:08:57 +00:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
consoleHelper.printChat(`${CurrentUser.username} in ${CurrentPacket.target} sent: ${CurrentPacket.message}`);
|
2021-09-03 21:12:42 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
|
|
|
osuPacketWriter.SendMessage({
|
|
|
|
sendingClient: CurrentUser.username,
|
|
|
|
message: CurrentPacket.message,
|
|
|
|
target: CurrentPacket.target,
|
|
|
|
senderId: CurrentUser.id
|
|
|
|
});
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
if (CurrentPacket.target == "#multiplayer") {
|
|
|
|
global.StreamsHandler.sendToStream(CurrentUser.currentMatch.matchChatStreamName, osuPacketWriter.toBuffer, CurrentUser.uuid);
|
|
|
|
botCommandHandler(CurrentUser, CurrentPacket.message, CurrentUser.currentMatch.matchChatStreamName, true);
|
|
|
|
return;
|
|
|
|
}
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Check the stream that we're sending to even exists
|
|
|
|
if (!global.StreamsHandler.doesStreamExist(CurrentPacket.target)) return;
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Write chat message to stream asociated with chat channel
|
|
|
|
global.StreamsHandler.sendToStream(CurrentPacket.target, osuPacketWriter.toBuffer, CurrentUser.uuid);
|
|
|
|
if (CurrentPacket.target == "#osu")
|
|
|
|
global.addChatMessage(`${CurrentUser.username}: ${CurrentPacket.message}`);
|
|
|
|
|
|
|
|
botCommandHandler(CurrentUser, CurrentPacket.message, CurrentPacket.target);
|
|
|
|
return;
|
2020-08-27 13:09:35 +01:00
|
|
|
}
|