mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-02-16 15:00:14 -05:00
All handlers now use conversations instead of channels
This commit is contained in:
parent
47ee4d1d6e
commit
9259ae2afd
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,10 +37,10 @@ public class DeopHandler extends BaseHandler
|
||||
* Execute /voice
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).deOp(channel.getName(), params[1]);
|
||||
service.getConnection(server.getId()).deOp(conversation.getName(), params[1]);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,10 +37,10 @@ public class DevoiceHandler extends BaseHandler
|
||||
* Execute /devoice
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).deVoice(channel.getName(), params[1]);
|
||||
service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Broadcast;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Message;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
@ -41,15 +41,15 @@ public class EchoHandler extends BaseHandler
|
||||
* Execute /echo
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length > 1) {
|
||||
Message message = new Message(BaseHandler.mergeParams(params));
|
||||
channel.addMessage(message);
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||
service.sendBroadcast(intent);
|
||||
} else {
|
||||
throw new CommandException("Text is missing");
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ public class JoinHandler extends BaseHandler
|
||||
* Execute /join
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).joinChannel(params[1]);
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -39,10 +39,10 @@ public class KickHandler extends BaseHandler
|
||||
* Execute /kick
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).kick(channel.getName(), params[1]);
|
||||
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Broadcast;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Message;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
@ -42,7 +42,7 @@ public class MeHandler extends BaseHandler
|
||||
* Execute /me
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length > 1) {
|
||||
String action = BaseHandler.mergeParams(params);
|
||||
@ -50,14 +50,14 @@ public class MeHandler extends BaseHandler
|
||||
|
||||
Message message = new Message(nickname + " " + action);
|
||||
message.setIcon(R.drawable.action);
|
||||
server.getChannel(channel.getName()).addMessage(message);
|
||||
server.getConversation(conversation.getName()).addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||
service.sendBroadcast(intent);
|
||||
|
||||
service.getConnection(server.getId()).sendAction(channel.getName(), action);
|
||||
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
|
||||
} else {
|
||||
throw new CommandException("Text is missing");
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Broadcast;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Message;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
@ -43,10 +43,10 @@ public class NamesHandler extends BaseHandler
|
||||
* Execute /names
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
StringBuffer userList = new StringBuffer("Users " + channel.getName() + ":");
|
||||
for (User user : service.getConnection(server.getId()).getUsers(channel.getName())) {
|
||||
StringBuffer userList = new StringBuffer("Users " + conversation.getName() + ":");
|
||||
for (User user : service.getConnection(server.getId()).getUsers(conversation.getName())) {
|
||||
userList.append(" ");
|
||||
userList.append(user.getPrefix());
|
||||
userList.append(user.getNick());
|
||||
@ -54,11 +54,11 @@ public class NamesHandler extends BaseHandler
|
||||
|
||||
Message message = new Message(userList.toString());
|
||||
message.setColor(Message.COLOR_YELLOW);
|
||||
channel.addMessage(message);
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, conversation.getName());
|
||||
service.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ public class NickHandler extends BaseHandler
|
||||
* Execute /nick
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).changeNick(params[1]);
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,10 +37,10 @@ public class OpHandler extends BaseHandler
|
||||
* Execute /deop
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).op(channel.getName(), params[1]);
|
||||
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ public class QuitHandler extends BaseHandler
|
||||
* Execute /quit
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 1) {
|
||||
service.getConnection(server.getId()).quitServer();
|
||||
|
@ -21,8 +21,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
package org.yaaic.command.handler;
|
||||
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -38,8 +40,14 @@ public class TopicHandler extends BaseHandler
|
||||
* Execute /topic
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service)
|
||||
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");
|
||||
}
|
||||
|
||||
Channel channel = (Channel) conversation;
|
||||
|
||||
if (params.length == 1) {
|
||||
// Show topic
|
||||
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
||||
|
@ -23,7 +23,7 @@ package org.yaaic.command.handler;
|
||||
import org.yaaic.command.BaseHandler;
|
||||
import org.yaaic.command.CommandException;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
@ -37,10 +37,10 @@ public class VoiceHandler extends BaseHandler
|
||||
* Execute /voice
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length == 2) {
|
||||
service.getConnection(server.getId()).voice(channel.getName(), params[1]);
|
||||
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user