mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-02-16 15:00:14 -05:00
Implemented /me <action>
This commit is contained in:
parent
ea4e90fb60
commit
2dd9d4a3e8
@ -51,6 +51,7 @@ public class CommandParser
|
||||
|
||||
commands.put("nick", new NickCommand());
|
||||
commands.put("join", new JoinCommand());
|
||||
commands.put("me", new MeCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
* Command: /join
|
||||
* Command: /join <channel> [<key>]
|
||||
*
|
||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||
*/
|
||||
|
72
src/org/yaaic/command/MeCommand.java
Normal file
72
src/org/yaaic/command/MeCommand.java
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Yaaic - Yet Another Android IRC Client
|
||||
|
||||
Copyright 2009 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;
|
||||
|
||||
import org.yaaic.R;
|
||||
import org.yaaic.irc.IRCService;
|
||||
import org.yaaic.model.Broadcast;
|
||||
import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Message;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* Command: /me <action>
|
||||
*
|
||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||
*/
|
||||
public class MeCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* Execute /me
|
||||
*/
|
||||
@Override
|
||||
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
|
||||
{
|
||||
if (params.length > 1) {
|
||||
String action = BaseCommand.mergeParams(params);
|
||||
String nickname = service.getConnection(server.getId()).getNick();
|
||||
|
||||
Message message = new Message(nickname + " " + action);
|
||||
message.setIcon(R.drawable.action);
|
||||
server.getChannel(channel.getName()).addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, channel.getName());
|
||||
service.sendBroadcast(intent);
|
||||
|
||||
service.getConnection(server.getId()).sendAction(channel.getName(), action);
|
||||
} else {
|
||||
throw new CommandException("Text is missing");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage of /me
|
||||
*/
|
||||
@Override
|
||||
public String getUsage()
|
||||
{
|
||||
return "/me <text>";
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import org.yaaic.model.Channel;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
/**
|
||||
* Command: /nick
|
||||
* Command: /nick <nickname>
|
||||
*
|
||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user