private void Forward(ReceivedCommandEventArgs e, ChannelBase from)
{
if (from.Properties.ContainsKey("Forward"))
{
ChannelBase channel = e.Server.GetChannel((string)from.Properties["Forward"]);
if (channel == null)
{
return;
}
else
{
e.User.SendNumeric(Numerics.RPL_SUMMONING, CMD, from.Name, ":Forwarding to", channel.Name, "due to restricted access.");
if (channel.HasFlag("RegisteredOnly") && e.User.Level < Authorizations.Registered)
{
e.User.SendNumeric(Numerics.ERR_NOLOGIN, CMD, channel.Name, ":Only registered users can join that channel.");
return;
}
if (channel.Properties.ContainsKey("Key"))
{
e.User.SendNumeric(Numerics.ERR_KEYSET, CMD, channel.Name, ":Key not specified for channel.");
return;
}
if (channel.HasFlag("InviteOnly"))
{
if (!e.User.HasSessionFlag("Invite:" + channel.Name)
&& !e.User.IsVoice(channel))
{
bool inviteExcept = false;
for (int m = 0; m < channel.InviteExcepts.Count; m++)
{
if (e.User.Mask.Matches(channel.InviteExcepts[m]))
{
inviteExcept = true;
break;
}
}
if (!inviteExcept)
{
e.User.SendNumeric(Numerics.ERR_INVITEONLYCHAN, CMD, channel.Name, ":That channel is marked invite-only.");
return;
}
}
}
if (!e.User.IsVoice(channel))
{
bool except = false;
for (int m = 0; m < channel.Exceptions.Count; m++)
{
if (e.User.Mask.Matches(channel.Exceptions[m]))
{
except = true;
break;
}
}
if (!except)
{
bool banned = false;
for (int m = 0; m < channel.Bans.Count; m++)
{
if (e.User.Mask.Matches(channel.Bans[m]))
{
banned = true;
break;
}
}
if (banned)
{
e.User.SendNumeric(Numerics.ERR_BANNEDFROMCHAN, CMD, channel.Name, ":You are banned from that channel.");
return;
}
}
}
}
if (!e.User.AddToChannel(channel))
{
e.User.SendNumeric(Numerics.ERR_UNKNOWNERROR, CMD, channel.Name, ":Unknown error occurred while joining channel.");
}
OnJoin(channel, e.User);
}
}