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

Implemented command: /names

This commit is contained in:
Sebastian Kaspari 2010-03-09 22:25:54 +01:00
parent 2dd9d4a3e8
commit 7ee8984f9a
2 changed files with 72 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public class CommandParser
commands.put("nick", new NickCommand());
commands.put("join", new JoinCommand());
commands.put("me", new MeCommand());
commands.put("names", new NamesCommand());
}
/**

View File

@ -0,0 +1,71 @@
/*
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.jibble.pircbot.User;
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: /names
* Lists all users currently in the selected channel
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class NamesCommand extends BaseCommand
{
/**
* Execute /names
*/
@Override
public void execute(String[] params, Server server, Channel channel, IRCService service) throws CommandException
{
StringBuffer userList = new StringBuffer("Users " + channel.getName() + ":");
for (User user : service.getConnection(server.getId()).getUsers(channel.getName())) {
userList.append(" ");
userList.append(user.getPrefix());
userList.append(user.getNick());
}
Message message = new Message(userList.toString());
message.setColor(Message.COLOR_YELLOW);
channel.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);
}
/**
* Usage of /names
*/
@Override
public String getUsage()
{
return "/names";
}
}