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:
parent
7863ee8aa2
commit
9a702f5d1a
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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(" ");
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user