Exemplo n.º 1
0
 /// <summary>
 /// Creates a new CommandArgs object, containing information about a command invocation.
 /// </summary>
 /// <param name="command">The name of the requested command.</param>
 /// <param name="args">An array of arguments to be passed to the command.</param>
 /// <param name="sender">The <see cref="IrcUser"/> who sent the command.</param>
 /// <param name="channel">The channel the command was sent in.</param>
 /// <param name="fullArgument">All arguments that were passed to the command, as a single string.</param>
 public CommandArgs(string command, string[] args, IrcUser sender, string channel, string fullArgument)
 {
     Command = command;
     Args = args;
     Sender = sender;
     Channel = channel;
     FullArgument = fullArgument;
     //ReplyCallback = replyCallback;
 }
Exemplo n.º 2
0
        public static bool Validate(IrcUser user)
        {
            Logger.Log(null, "Validating user");
            Match match = (input, reference) => (reference.Equals("*") || input.Equals(reference));

            // TODO: allow validation of multiple operators
            var op = ConfigManager.Config.Operators.First();

            var nick = op.Nick;
            var ident = op.Ident;
            var host = op.Host;
            var uid = op.Uid;
            int[] uids;
            try
            {
                uids = user.Client.StatsDatabase.GetUids(user);
            }
            catch (Exception e)
            {
                Logger.Log(null, $"Failed to get UID for {user.Nick} ({user.Ident}, {user.Hostmask}); An exception occurred while trying to query the database: {e.GetType()}: \"{e.Message}\"", LogLevel.Warning);
                uids = new[] { -1 };
            }

            if (uids.Length > 1)
            {
                Logger.Log(null, $"Failed to validate {user.Nick} ({user.Ident}, {user.Hostmask}); GetUids() returned more than one user ID.", LogLevel.Warning);
                return false;
            }
            if (uids.Length == 0)
            {
                Logger.Log(null, $"Failed to validate {user.Nick} ({user.Ident}, {user.Hostmask}); GetUids() returned no user IDs.", LogLevel.Warning);
                return false;
            }
            var nickM = match(user.Nick, nick);
            var identM = match(user.Ident, ident);
            var hostM = match(user.Hostmask, host);
            var uidM = match(uids[0].ToString(), uid);

            return nickM && identM && hostM && uidM;
        }
Exemplo n.º 3
0
 public IrcMessage(IrcClientWrapper clientWrapper, IrcUser sender, string channel, string message, bool action = false)
     : base(sender, channel, message, action)
 {
     Client = clientWrapper;
 }