diff --git a/src/org/yaaic/command/CommandParser.java b/src/org/yaaic/command/CommandParser.java
index 2f46934..5273b25 100644
--- a/src/org/yaaic/command/CommandParser.java
+++ b/src/org/yaaic/command/CommandParser.java
@@ -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());
}
/**
diff --git a/src/org/yaaic/command/NamesCommand.java b/src/org/yaaic/command/NamesCommand.java
new file mode 100644
index 0000000..d247e2b
--- /dev/null
+++ b/src/org/yaaic/command/NamesCommand.java
@@ -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 .
+*/
+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
+ */
+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";
+ }
+}