// // openmapi.org - IRC <--> Jabber bridge - UsersCommand.cs // // (C) 2009 by Johannes Roith // // Author: Johannes Roith // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program 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 Affero General Public License for more details. // namespace Jonfo.Jabber.IRC { using System; using System.Text; using jabber; /// /// Prints a list of all connected users. /// public sealed class UsersCommand : Command { public UsersCommand (IRCJabberBridge bridge) : base (bridge) { } public override string Description { get { return "Print a list of connected users."; } } public override string CommandStr { get { return "users"; } } public override void Run (JID from, string args) { StringBuilder response = new StringBuilder (); /* string[] channels = bridge.IRCClient.GetChannels (); foreach (var ch in channels) Console.WriteLine (ch); Channel channel = bridge.IRCClient.GetChannel (bridge.IRCChannel); if (channel == null) bridge.JabberClient.Message (from, "error -- invalid target channel '" + bridge.IRCChannel + "' !"); else { foreach (ChannelUser user in channel.Users.Values) { string nick = user.Nick; if (user.IsOp) nick = "@"+ nick; else if (user.IsVoice) nick = "+"+ nick; response.Append (nick + "\n"); } } */ foreach (JID jid in bridge.GetAvailableJabberBuddies ()) response.Append ("jabber: " + jid.ToString () + "; "); bridge.JabberClient.Message (from, response.ToString ()); } } }