Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent message sending in lobbies #957

Merged
merged 1 commit into from Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/client.js
Expand Up @@ -335,6 +335,14 @@ Client.prototype.inputLine = function(data) {

// This is either a normal message or a command escaped with a leading '/'
if (text.charAt(0) !== "/" || text.charAt(1) === "/") {
if (target.chan.type === Chan.Type.LOBBY) {
target.chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: "Messages can not be sent to lobbies."
}));
return;
}

text = "say " + text.replace(/^\//, "");
} else {
text = text.substr(1);
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/inputs/action.js
@@ -1,8 +1,20 @@
"use strict";

var Chan = require("../../models/chan");
var Msg = require("../../models/msg");

exports.commands = ["slap", "me"];

exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels and queries.`
}));

return;
}

var irc = network.irc;
var text;

Expand Down
8 changes: 6 additions & 2 deletions src/plugins/inputs/invite.js
@@ -1,6 +1,7 @@
"use strict";

var Chan = require("../../models/chan");
var Msg = require("../../models/msg");

exports.commands = ["invite"];

Expand All @@ -11,7 +12,10 @@ exports.input = function(network, chan, cmd, args) {
irc.raw("INVITE", args[0], args[1]); // Channel provided in the command
} else if (args.length === 1 && chan.type === Chan.Type.CHANNEL) {
irc.raw("INVITE", args[0], chan.name); // Current channel
} else {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels or by specifying a target.`
}));
}

return true;
};
12 changes: 12 additions & 0 deletions src/plugins/inputs/kick.js
@@ -1,8 +1,20 @@
"use strict";

var Chan = require("../../models/chan");
var Msg = require("../../models/msg");

exports.commands = ["kick"];

exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.`
}));

return;
}

if (args.length !== 0) {
var irc = network.irc;
irc.raw("KICK", chan.name, args[0], args.slice(1).join(" "));
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/inputs/topic.js
@@ -1,8 +1,20 @@
"use strict";

var Chan = require("../../models/chan");
var Msg = require("../../models/msg");

exports.commands = ["topic"];

exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.`
}));

return;
}

var irc = network.irc;
irc.raw("TOPIC", chan.name, args.join(" "));

Expand Down