Example #1
0
        /// <summary>
        /// Checks if a message is considered sent from a chat admin
        /// </summary>
        /// <param name="e">The <see cref="IrcMessageData"/></param>
        /// <returns><see langword="true"/> if <paramref name="e"/> was sent by a chat admin, <see langword="false"/> otherwise</returns>
        private bool CheckAdmin(IrcMessageData e)
        {
            if (IRCConfig.AdminsAreSpecial)
            {
                if (e.Channel == null)
                {
                    return(false);
                }
                var user = (NonRfcChannelUser)irc.GetChannelUser(e.Channel, e.Nick);
                if (user != null)
                {
                    switch (IRCConfig.AuthLevel)
                    {
                    case IRCMode.Voice:
                        if (user.IsVoice)
                        {
                            return(true);
                        }
                        goto case IRCMode.Halfop;

                    case IRCMode.Halfop:
                        if (user.IsHalfop)
                        {
                            return(true);
                        }
                        goto case IRCMode.Op;

                    case IRCMode.Op:
                        if (user.IsOp)
                        {
                            return(true);
                        }
                        goto case IRCMode.Owner;

                    case IRCMode.Owner:
                        if (user.IsOwner)
                        {
                            return(true);
                        }
                        break;
                    }
                }
            }
            else
            {
                var lowerNick = e.Nick.ToLower();
                foreach (var I in IRCConfig.AdminList)
                {
                    if (lowerNick == I.ToLower())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }