Esempio n. 1
0
        protected KeyValuePair <bool, string> CallCommand(string command, string arg, UUID caller, string split_args_on)
        {
            command = command.ToLowerInvariant();
            CoreCommand cmd = (CoreCommand)GetCommand(command);

            if (cmd != null)
            {
                cmd.Setup(bot, caller);
                string[] args = new string[] { };
                if (helpers.notempty(arg) == true)
                {
                    args = arg.Split(new[] { split_args_on }, StringSplitOptions.RemoveEmptyEntries);
                }
                if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true))
                {
                    if (cmd.Min_Required_args <= args.Length)
                    {
                        pending_avatar_lookup pending = new pending_avatar_lookup(this, cmd, args);
                        if (pending.needs_lookup() == true)
                        {
                            commands_pending_avatar_lookups.Add(next_lookup_id, pending);
                            commands_pending_avatar_lookups_ages.Add(next_lookup_id, helpers.UnixTimeNow());
                            next_lookup_id++;
                            if (next_lookup_id == 13000)
                            {
                                next_lookup_id = 0;
                            }
                            return(new KeyValuePair <bool, string>(true, "Lookup underway"));
                        }
                        else
                        {
                            return(pending.Callnow());
                        }
                    }
                    else
                    {
                        return(new KeyValuePair <bool, string>(false, "Required args count not sent! expected: " + cmd.Min_Required_args.ToString() + " but got " + args.Length.ToString() + ""));
                    }
                }
                else
                {
                    bool result = cmd.CallFunction(args);
                    return(new KeyValuePair <bool, string>(result, cmd.GetInfoBlob));
                }
            }
            else
            {
                if (suppress_warnings.Contains(command) == false)
                {
                    suppress_warnings.Add(command);
                    return(new KeyValuePair <bool, string>(false, "unknown"));
                }
            }
            return(new KeyValuePair <bool, string>(false, "--"));
        }
Esempio n. 2
0
        public bool Call(string command, string arg)
        {
            command = command.ToLowerInvariant();
            CoreCommand cmd = (CoreCommand)GetCommand(command);

            if (cmd != null)
            {
                cmd.Setup(bot);
                if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true))
                {
                    string[] args = arg.Split(new string[] { "~#~" }, StringSplitOptions.None);
                    if (cmd.MinArgs <= args.Length)
                    {
                        pending_avatar_lookup pending = new pending_avatar_lookup(this, cmd, args);
                        if (pending.needs_lookup() == true)
                        {
                            commands_pending_avatar_lookups.Add(next_lookup_id, pending);
                            commands_pending_avatar_lookups_ages.Add(next_lookup_id, helpers.UnixTimeNow());
                            next_lookup_id++;
                            if (next_lookup_id == 13000)
                            {
                                next_lookup_id = 0;
                            }
                            return(true);
                        }
                        else
                        {
                            return(pending.Callnow());
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(cmd.CallFunction(arg.Split(new string[] { "~#~" }, StringSplitOptions.None)));
                }
            }
            else
            {
                if (suppress_warnings.Contains(command) == false)
                {
                    suppress_warnings.Add(command);
                    ConsoleLog.Debug("[CMD/Failed] " + command + " : I have no f*****g idea what you are talking about");
                }
                return(false);
            }
        }