Inheritance: ChannelSurrogate, IDisposable
 public ReceivedChannelModeEventArgs(ServerBase server, ChannelBase channel, UserBase user, string argument)
 {
     Server = server;
     Channel = channel;
     User = user;
     Argument = argument;
 }
Example #2
0
 public override List<HostMask> GetList(ChannelBase channel)
 {
     return channel.Exceptions;
 }
Example #3
0
 public abstract void Commit(ChannelBase channel);
Example #4
0
 public override List<HostMask> GetList(ChannelBase channel)
 {
     return channel.InviteExcepts;
 }
Example #5
0
 public abstract string PrefixNickname(ChannelBase channel);
Example #6
0
 public abstract bool AddToChannel(ChannelBase channel);
Example #7
0
 public abstract bool IsQuieted(ChannelBase channel);
Example #8
0
        private void OnJoin(ChannelBase channel, UserBase user)
        {
            channel.BroadcastInclusive(CMD, user, channel.Name);
            user.Names(channel);

            if (channel.Properties.ContainsKey("Topic"))
            { // Note: Shouldn't send RPL_NOTOPIC under any circumstances at this point.
                user.SendNumeric(Numerics.RPL_TOPIC, channel.Name, ":" + (string)channel.Properties["Topic"]);
            }

            if (channel.Users.Count < 2)
            {
                return;
            }

            string prefix = channel.GetPrefix(user);
            if (!string.IsNullOrEmpty(prefix))
            {
                StringBuilder modes = new StringBuilder(prefix.Length + 1).Append('+');
                StringBuilder args = new StringBuilder(prefix.Length * (user.Mask.Nickname.Length + 1));
                foreach (char c in prefix)
                {
                    char m;
                    switch (c)
                    {
                    case '$':
                        m = 'X';
                        break;

                    case '~':
                        m = 'O';
                        break;

                    case '&':
                        m = 'a';
                        break;

                    case '@':
                        m = 'o';
                        break;

                    case '%':
                        m = 'h';
                        break;

                    case '+':
                        m = 'v';
                        break;

                    case '!':
                        m = 'x';
                        break;

                    default:
                        continue;
                    }

                    modes.Append(m);
                    args.Append(' ').Append(user.Mask.Nickname);
                }

                channel.BroadcastInclusive("MODE", null, channel.Name, modes.ToString() + args.ToString());
            }
        }
Example #9
0
 public abstract bool IsVoice(ChannelBase channel);
Example #10
0
 public abstract bool IsBanned(ChannelBase channel);
Example #11
0
 public abstract bool IsHalfOperator(ChannelBase channel);
Example #12
0
 public abstract bool IsProtect(ChannelBase channel);
Example #13
0
 public abstract void Names(ChannelBase channel);
Example #14
0
        public override void Commit(ChannelBase channel)
        {
            if (!channel.IsRegistered && !channel.IsSystem)
            {
                return;
            }

            Cache.Channels[channel.Id] = new ChannelSurrogate(channel);
        }
Example #15
0
 public abstract bool IsExcepted(ChannelBase channel);
Example #16
0
        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);
            }
        }
Example #17
0
 public abstract bool CanSendToChannel(ChannelBase channel, bool skipInChannelCheck, string action);
Example #18
0
 public ChannelBase(ChannelBase clone)
     : base(clone)
 {
     Server = clone.Server;
     Users = clone.Users;
 }
Example #19
0
 public abstract string PrefixHostMask(ChannelBase channel);