1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-25 18:32:15 -05:00

Check conversation type on handler execution where needed

This commit is contained in:
Sebastian Kaspari 2010-03-10 21:14:20 +01:00
parent 7863ee8aa2
commit 9a702f5d1a
7 changed files with 28 additions and 0 deletions

View File

@ -39,6 +39,10 @@ public class DeopHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
if (params.length == 2) {
service.getConnection(server.getId()).deOp(conversation.getName(), params[1]);
} else {

View File

@ -39,6 +39,10 @@ public class DevoiceHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
if (params.length == 2) {
service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]);
} else {

View File

@ -41,6 +41,10 @@ public class KickHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
if (params.length == 2) {
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
} else {

View File

@ -44,6 +44,10 @@ public class MeHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() == Conversation.TYPE_SERVER) {
throw new CommandException("Only usable from within a channel or a query");
}
if (params.length > 1) {
String action = BaseHandler.mergeParams(params);
String nickname = service.getConnection(server.getId()).getNick();

View File

@ -45,6 +45,10 @@ public class NamesHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
StringBuffer userList = new StringBuffer("Users " + conversation.getName() + ":");
for (User user : service.getConnection(server.getId()).getUsers(conversation.getName())) {
userList.append(" ");

View File

@ -39,6 +39,10 @@ public class OpHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
if (params.length == 2) {
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
} else {

View File

@ -39,6 +39,10 @@ public class VoiceHandler extends BaseHandler
@Override
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
}
if (params.length == 2) {
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
} else {