1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-29 12:22:21 -05:00

Added command: /mode <channel> <mode>

This commit is contained in:
Sebastian Kaspari 2010-03-18 00:04:50 +01:00
parent 5629f2f308
commit 1b2461f8fe
2 changed files with 67 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import org.yaaic.command.handler.EchoHandler;
import org.yaaic.command.handler.JoinHandler;
import org.yaaic.command.handler.KickHandler;
import org.yaaic.command.handler.MeHandler;
import org.yaaic.command.handler.ModeHandler;
import org.yaaic.command.handler.NamesHandler;
import org.yaaic.command.handler.NickHandler;
import org.yaaic.command.handler.NoticeHandler;
@ -85,6 +86,7 @@ public class CommandParser
commands.put("close", new CloseHandler());
commands.put("notice", new NoticeHandler());
commands.put("dcc", new DCCHandler());
commands.put("mode", new ModeHandler());
// Aliases
commands.put("j", commands.get("join"));

View File

@ -0,0 +1,65 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.command.handler;
import org.yaaic.command.BaseHandler;
import org.yaaic.exception.CommandException;
import org.yaaic.irc.IRCService;
import org.yaaic.model.Conversation;
import org.yaaic.model.Server;
/**
* Command: /mode <channel> <mod>
*
* Set or remove channel modes
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class ModeHandler extends BaseHandler
{
/**
* Execute /mode
*/
@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) {
String modes = BaseHandler.mergeParams(params, 2);
service.getConnection(server.getId()).setMode(params[1], modes);
} else {
throw new CommandException("Invalid number of params");
}
}
/**
* Usage of /mode
*/
@Override
public String getUsage()
{
return "/mode <channel> <mode>";
}
}