Implement IRC QUIT

parent 3298c025
......@@ -16,7 +16,6 @@ const ignoredSplits = [
"372", // MOTD
"375", // MOTD Begin
"376", // MOTD End
"QUIT", // User disconnects
];
/**
......
......@@ -11,6 +11,7 @@ const ModeCommand = require("../IrcCommands/ModeCommand");
const WhoisChannelsCommand = require("../IrcCommands/whois/WhoisChannelsCommand.js");
const WhoisEndCommand = require("../IrcCommands/whois/WhoisEndCommand.js");
const WhoisUserCommand = require("../IrcCommands/whois/WhoisUserCommand.js");
const QuitCommand = require("../IrcCommands/QuitCommand.js");
/**
* Contains all the active IRC incoming commands
......@@ -44,6 +45,8 @@ const IrcCommands = {
/** @type {ModeCommand} */
"MODE": new ModeCommand(),
/** @type {MessageCommand} */
"PRIVMSG": new MessageCommand()
"PRIVMSG": new MessageCommand(),
/** @type {QuitCommand} */
"QUIT": new QuitCommand()
};
module.exports = Object.freeze(IrcCommands);
\ No newline at end of file
const IrcCommand = require("../IrcCommand");
/**
* Received when someone disconnects from Bancho (with no other client opened)
* @extends IrcCommand
* @private
*/
class QuitCommand extends IrcCommand {
constructor() {
super();
}
handleCommand(client, command, splits) {
const username = splits[0].substr(1, splits[0].indexOf("!") - 1);
const user = client.getUser(username);
/**
* Fired when a user has disconnected from Bancho (with no other client opened)
* @event BanchoClient#QUIT
* @type {BanchoUser}
*/
client.emit("QUIT", user);
for(const channel of client.channels.values())
if(channel.channelMembers[user.ircUsername] != null)
delete channel.channelMembers[user.ircUsername];
}
}
module.exports = QuitCommand;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment