private void IngameCommand_Who(int PlayerId, int CharacterServerId, string Text)
{
string ChannelName = null;
if (Text.Length != 0 && !Text.StartsWith(" "))
return;
if (Text.Length == 0 && HomeChannels.Count != 0)
ChannelName = HomeChannels[0];
else
{
Text = Text.Trim();
ChannelName = (from string C in Client.GetChannels()
where C == Text
select C).FirstOrDefault();
}
if (ChannelName == null)
{
SendMessageToPlayer(PlayerId, CharacterServerId, "Unknown channel.");
return;
}
Channel JoinedChannel = Client.GetChannel(ChannelName);
if (JoinedChannel == null)
{
SendMessageToPlayer(PlayerId, CharacterServerId, "The IRC gateway is not joined to that channel.");
return;
}
SendMessageToPlayer(PlayerId, CharacterServerId, String.Format("{0} user(s) in channel {1}:", JoinedChannel.Users.Values.Count, JoinedChannel.Name));
StringBuilder Line = new StringBuilder();
int UsersInLine = 0;
foreach (ChannelUser User in JoinedChannel.Users.Values)
{
if (UsersInLine != 0)
Line.Append(", ");
if (User.IsOp)
Line.Append("@");
else if (User.IsVoice)
Line.Append("+");
Line.Append(User.Nick);
UsersInLine += 1;
if (UsersInLine == 3)
{
SendMessageToPlayer(PlayerId, CharacterServerId, Line.ToString());
Line.Clear();
UsersInLine = 0;
}
}
if (UsersInLine != 0)
{
SendMessageToPlayer(PlayerId, CharacterServerId, Line.ToString());
Line.Clear();
UsersInLine = 0;
}
IncrementStatistic("IRC_COMMAND_WHO");
}