protected XmppBotCommand GetCommand(string commandText)
        {
            XmppBotCommand cmd = null;

            this.Commands.TryGetValue(commandText, out cmd);

            return(cmd);
        }
        public virtual string EvaluateEx(ParsedLine line)
        {
            if (!line.IsCommand)
            {
                return(null); // this is not a command
            }
            XmppBotCommand command = GetCommand(line.Command);

            return(command == null ? null : command.Method(line));
        }
        public virtual string Help(ParsedLine line)
        {
            if (this.Commands.Count <= 0)
            {
                return("");
            }

            if (line.Args.Length == 0)
            {
                return(String.Format("{0} commands: {1}", this.Name, String.Join(",", this.Commands.Keys.ToArray())));
            }

            XmppBotCommand command = GetCommand(line.Args.FirstOrDefault());

            return(command == null ? "" : command.HelpInfo);
        }
Beispiel #4
0
        public override string EvaluateEx(ParsedLine line)
        {
            if (!line.IsCommand)
            {
                return(null); // this is not a command
            }
            XmppBotCommand command = GetCommand(line.Command);

            // this is a command for this plugin, so we are going to queue it up
            if (command != null)
            {
                _commandQueue.Add(new QueuedCommand(line, command));
                return(string.Format("Queued up: {0}", line.Command));
            }

            return(null); // nothing to do
        }
Beispiel #5
0
        public override string EvaluateEx(ParsedLine line)
        {
            // check to see if this is a confirmation
            if (commandQueue.Count > 0)
            {
                if (line.Raw.ToUpperInvariant() == "YES" ||
                    line.Raw.ToUpperInvariant() == "Y")
                {
                    string     res = ExecuteConfirm(line);
                    ParsedLine cmdLine;
                    commandQueue.TryRemove(line.User.Id, out cmdLine);

                    if (!string.IsNullOrEmpty(res))
                    {
                        return(res);
                    }
                }
                else if (
                    line.Raw.ToUpperInvariant() == "NO" ||
                    line.Raw.ToUpperInvariant() == "N")
                {
                    ClearCommandHistory(line.User.Id);
                }
            }


            // now check for a command
            if (!line.IsCommand)
            {
                return(null); // this is not a command
            }
            XmppBotCommand command = GetCommand(line.Command);

            if (command != null)
            {
                // queue this command if it is one
                AreYouSure(line);
            }

            return(null);
        }
 public QueuedCommand(ParsedLine line, XmppBotCommand command)
 {
     this.Line = line;
     this.Command = command;
 }
 public QueuedCommand(ParsedLine line, XmppBotCommand command)
 {
     this.Line    = line;
     this.Command = command;
 }