コード例 #1
0
        public NovaException(NovaInstance obj)
        {
            var klass = obj.Class;

            var exceptionFound = false;
            var _class         = obj.Class;

            do
            {
                if (_class.Name.Equals("Exception"))
                {
                    exceptionFound = true;
                    break;
                }
                _class = _class.Parent;
            } while (!exceptionFound && _class != null);

            if (exceptionFound)
            {
                ExceptionClass = klass;
                InnerObject    = obj;
            }
            else
            {
                ExceptionClass = Nova.Box(typeof(NovaException));
                InnerObject    = null;
            }
        }
コード例 #2
0
        internal static dynamic DefineClassOpen(object rawValue, List <Expression> contents, object rawScope)
        {
            var scope = (NovaScope)rawScope;

            var value = CompilerServices.CompileExpression((Expression)rawValue, scope);

            if (value == null)
            {
                return(null);
            }

            var @class = value as NovaClass;

            if (@class != null)
            {
                return(DefineCategory(@class, contents, scope));
            }
            var instance = value as NovaInstance;

            if (instance != null)
            {
                return(DefineCategory(instance.Class, contents, scope));
            }
            var newVal = Nova.Box(value);

            return(DefineCategory(((NovaInstance)newVal).Class, contents, scope));
        }
コード例 #3
0
        private static dynamic Compare(object left, object right, object rawScope)
        {
            var scope = (NovaScope)rawScope;

            var NovaName = "<=>";
            var clrName  = InteropBinder.ToClrOperatorName(NovaName);

            if (left is NovaInstance)
            {
                var lo  = (NovaInstance)left;
                var dmo = lo.GetMetaObject(Expression.Constant(left));
                if (InteropBinder.InvokeMember.SearchForFunction(lo.Class, NovaName, lo, L(Arg(right)), true) != null)
                {
                    return(dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                _DMO(DMO(scope), DMO(Arg(right)))));
                }
                if (InteropBinder.InvokeMember.SearchForFunction(lo.Class, clrName, lo, L(Arg(right)), true) != null)
                {
                    return(dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                _DMO(DMO(scope), DMO(Arg(right)))));
                }
            }

            var Value = Nova.Box(left);

            if (Value.Class != null)
            {
                var _dmo = Value.GetMetaObject(Expression.Constant(Value));
                if (InteropBinder.InvokeMember.SearchForFunction(Value.Class, NovaName, Value, L(Arg(right)), true) !=
                    null)
                {
                    return(_dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                 _DMO(DMO(scope), DMO(Arg(right)))));
                }
                if (InteropBinder.InvokeMember.SearchForFunction(Value.Class, clrName, Value, L(Arg(right)), true) !=
                    null)
                {
                    return(_dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                 _DMO(DMO(scope), DMO(Arg(right)))));
                }
            }

            dynamic _left  = left;
            dynamic _right = right;

            if (_left < _right)
            {
                return(-1);
            }

            if (_left > _right)
            {
                return(1);
            }

            return(0);
        }
コード例 #4
0
        internal static dynamic Resolve(object rawName, object rawScope)
        {
            if (rawName.GetType() == typeof(InstanceReference))
            {
                var iref   = (InstanceReference)rawName;
                var lval   = CompilerServices.CompileExpression(iref.LValue, (NovaScope)rawScope);
                var gmArgs = new List <Expression>();
                gmArgs.Add(Expression.Constant(lval, typeof(object)));
                return(Dynamic(typeof(object), new InteropBinder.GetMember(iref.Key, (NovaScope)rawScope), gmArgs));
            }
            var name  = (string)rawName;
            var scope = (NovaScope)rawScope;

            if (name.StartsWith("$") && name != "$:")
            {
                scope = scope.GlobalScope;
                name  = name.Substring(1);
            }
            if (name.StartsWith("@") && scope["<nova_context_invokemember>"] != null)
            {
                if (name.StartsWith("@@"))
                {
                    var _val = Resolve("self", scope);
                    if (!(_val is NovaInstance))
                    {
                        // native object?
                        _val = Nova.Box((object)_val, scope);
                    }
                    var @class = ((NovaInstance)_val).Class;
                    return
                        (CompilerServices.CompileExpression(
                             NovaExpression.Variable(NovaExpression.InstanceRef(Expression.Constant(@class),
                                                                                Expression.Constant(name.Substring(2)))), scope));
                }
                return
                    (CompilerServices.CompileExpression(
                         NovaExpression.Variable(
                             NovaExpression.InstanceRef(NovaExpression.Variable(Expression.Constant("self")),
                                                        Expression.Constant(name.Substring(1)))), scope));
            }

            var val = scope[name];

            // The cast is needed here because if we get a non-nullable type (such as System.Int32) the check here will throw an exception.
            // By casting to System.Object we can avoid the exception since it is a boxed value that can be null.
            if ((object)val == null)
            {
                Type type;
                if ((type = NovaTypeResolver.Resolve(name)) != null)
                {
                    var @class = NovaClass.BoxClass(type);
                    scope.GlobalScope[@class.Name] = @class;
                    val = @class;
                }
            }
            return(val);
        }
コード例 #5
0
 private void OnDestroy()
 {
     if (gameObject.name.Contains("Missile"))
     {
         GameObject explosionInstance = Instantiate(Manager.instance.explosionPrefab, transform.position, transform.rotation);
         Nova       explosionScript   = explosionInstance.GetComponent <Nova>();
         explosionScript.SetTime(1.0f);
         explosionScript.SetGrowth(15.0f);
     }
 }
コード例 #6
0
 protected DialogResult ShowCustomMessageBox(string msg, string title,
     MessageBoxButtons buttons, Nova.Windows.Forms.MessageBoxIconType icon)
 {
     if (!this.InvokeRequired)
     {
         return CustomMessageBox.ShowCustomMessageBox(this, msg, title, buttons, icon);
     }
     else
     {
         ShowCustomMessageBoxDele cs = new ShowCustomMessageBoxDele(ShowCustomMessageBox);
         return (DialogResult)this.Invoke(cs, new object[] { msg, title, buttons, icon });
     }
 }
コード例 #7
0
        internal static dynamic ObjectMethodChange(object rawSelf, object rawName, bool isRemove, object rawScope)
        {
            var scope = (NovaScope)rawScope;
            var name  = (string)rawName;

            var self = CompilerServices.CompileExpression((Expression)rawSelf, scope);

            var @class = self as NovaClass;

            if (@class != null)
            {
                if (isRemove)
                {
                    @class.RemovedMethods.Add(name);
                }
                else
                {
                    @class.UndefinedMethods.Add(name);
                }
            }
            else
            {
                var instance = self as NovaInstance;
                if (instance != null)
                {
                    if (isRemove)
                    {
                        instance.RemovedMethods.Add(name);
                    }
                    else
                    {
                        instance.UndefinedMethods.Add(name);
                    }
                }
                else
                {
                    var newVal = Nova.Box(self);
                    if (isRemove)
                    {
                        ((NovaInstance)newVal).RemovedMethods.Add(name);
                    }
                    else
                    {
                        ((NovaInstance)newVal).UndefinedMethods.Add(name);
                    }
                }
            }


            return(null);
        }
コード例 #8
0
 public void MergeWithScope(ScriptScope scope)
 {
     scope.GetVariableNames().ToList().ForEach(name => {
         if (!Variables.ContainsKey(name))
         {
             var val = scope.GetVariable(name);
             // Runtime classes we should wrap to get desired effect
             if (val is NovaArray || val is NovaDictionary || val is NovaString || val is NovaNumber)
             {
                 val = Nova.Box(val);
             }
             Variables[name] = val;
         }
     });
 }
コード例 #9
0
        static void Main(string[] args)
        {
            ContaBancaria Nova;

            Console.Write("Entre com o número da conta : ");
            int NC = int.Parse(Console.ReadLine());

            Console.Write("Entre o titular da conta : ");
            string TC = Console.ReadLine();

            Console.Write("Haverá deposito inicial (s/n)? ");
            char DI = char.Parse(Console.ReadLine());

            while (DI != 'n' && DI != 'N' && DI != 's' && DI != 'S')
            {
                Console.WriteLine("Digite Sim[s/S] ou Não[n/N]! : ");
                DI = char.Parse(Console.ReadLine());
            }
            if (DI == 's' || DI == 'S')
            {
                Console.WriteLine("Entre um valor para deposito inicial : ");
                double depositoInicial = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Nova = new ContaBancaria(NC, TC, depositoInicial);
            }
            else
            {
                Nova = new ContaBancaria(NC, TC);
            }

            Console.WriteLine("\nDados da conta : " + Nova + "\n");

            Console.Write("\nEntre com um valor para deposito : ");
            double deposito = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Nova.Deposito(deposito);

            Console.WriteLine("\nDados da conta atualizados : " + Nova);

            Console.Write("\nEntre com um valor para saque : ");
            double saque = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Nova.Saque(saque);

            Console.WriteLine("\nDados da conta atualizados : " + Nova);
        }
コード例 #10
0
        public void MergeWithScope(Scope scope)
        {
            List <KeyValuePair <string, dynamic> > items = scope.Storage.GetItems();

            foreach (var item in items)
            {
                if (!Variables.ContainsKey(item.Key))
                {
                    var val = item.Value;
                    // Runtime classes we should wrap to get desired effect
                    if (val is NovaArray || val is NovaDictionary || val is NovaString || val is NovaNumber)
                    {
                        val = Nova.Box(val);
                    }
                    Variables[item.Key] = val;
                }
            }
        }
コード例 #11
0
ファイル: Kernel.cs プロジェクト: nihilisticpandemonium/Nova
        public Kernel()
        {
            NovaNativeFunction nfunc;

            GetType().GetMethods(BindingFlags.Static | BindingFlags.NonPublic).ToList()
            .ForEach(method => {
                nfunc = new NovaNativeFunction(GetType(), method);
                Nova.Globals.SetVariable(nfunc.Name, nfunc);
            });
            // Register wrapper for functions which need it, like eval
            var stream = typeof(Kernel).Assembly.GetManifestResourceStream("Nova.Scripts.core.nova");
            var buffer = new byte[stream.Length];

            stream.Read(buffer, 0, (int)stream.Length);
            var source = Encoding.UTF8.GetString(buffer);

            Nova.Execute(source);
        }
コード例 #12
0
ファイル: Class1.cs プロジェクト: atdt/wikimedia-bot
        public void JSON()
        {
            try
            {
                string URL = "https://labsconsole.wikimedia.org/wiki/Special:Ask/-5B-5BResource-20Type::instance-5D-5D/-3FInstance-20Name/-3FInstance-20Type/-3FProject/-3FImage-20Id/-3FFQDN/-3FLaunch-20Time/-3FPuppet-20Class/-3FModification-20date/-3FInstance-20Host/-3FNumber-20of-20CPUs/-3FRAM-20Size/-3FAmount-20of-20Storage/limit%3D500/format%3Djson";
                string temp = System.IO.Path.GetTempFileName();
                if (Download(URL, temp))
                {
                    List<Instance> deleted = new List<Instance>();
                    lock (Instances)
                    {
                        deleted.AddRange(Instances);
                    }
                    System.IO.StreamReader a = System.IO.File.OpenText(temp);
                    JsonTextReader b = new JsonTextReader(a);
                    string name = "{unknown}";
                    string host = "{unknown}";
                    string ip = "{unknown}";
                    string project = "{unknown}";
                    string resource = "{unknown}";
                    string image = "{unknown}";
                    string Ram = "{unknown}";
                    string NumberOfCpu = "{unknown}";
                    string ModifyTime = "{unknown}";
                    string Storage = "{unknown}";
                    string FullUrl = "{unknown}";
                    string fqdn = "{unknown}";
                    string LaunchTime = "{unknown}";
                    string type = "{unknown}";
                    while (b.Read())
                    {
                        if (b.TokenType == JsonToken.PropertyName)
                        {
                            if (b.Value == null)
                            {
                                core.Log("DEBUG: null at value");
                                continue;
                            }
                            string value = b.Value.ToString();
                            if (value.StartsWith("Nova Resource:"))
                            {
                                value = value.Substring("Nova Resource:".Length);
                                if (resource != "{unknown}")
                                {
                                    Instance instance = getInstance(resource);
                                    if (instance != null)
                                    {
                                        if (deleted.Contains(instance))
                                        {
                                            deleted.Remove(instance);
                                        }
                                        deleteInstance(instance);
                                    }
                                    try
                                    {
                                        IPAddress[] addresslist = Dns.GetHostAddresses(resource);

                                        if (addresslist.Length > 0)
                                        {
                                            ip = addresslist[0].ToString();
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        core.Log("Debug: can't resolve" + resource);
                                    }
                                    instance = new Instance(resource, name, host, ip, type, true);
                                    instance.fqdn = fqdn;
                                    instance.FullUrl = FullUrl;
                                    instance.ImageID = image;
                                    instance.LaunchTime = LaunchTime;
                                    instance.ModifyTime = ModifyTime;
                                    instance.NumberOfCpu = NumberOfCpu;
                                    instance.Project = project;
                                    instance.Ram = Ram;
                                    instance.Storage = Storage;
                                    lock (Instances)
                                    {
                                        Instances.Add(instance);
                                    }
                                    name = "{unknown}";
                                    host = "{unknown}";
                                    ip = "{unknown}";
                                    project = "{unknown}";
                                    resource = "{unknown}";
                                    image = "{unknown}";
                                    Ram = "{unknown}";
                                    NumberOfCpu = "{unknown}";
                                    ModifyTime = "{unknown}";
                                    Storage = "{unknown}";
                                    FullUrl = "{unknown}";
                                    fqdn = "{unknown}";
                                    LaunchTime = "{unknown}";
                                    type = "{unknown}";
                                }
                                resource = value;
                            }
                            switch (b.Value.ToString())
                            {
                                case "Instance Name":
                                    name = getValue(ref b);
                                    break;
                                case "Instance Type":
                                    type = getValue(ref b);
                                    break;
                                case "Project":
                                    project = getValue(ref b);
                                    break;
                                case "Image Id":
                                    image = getValue(ref b);
                                    break;
                                case "FQDN":
                                    fqdn = getValue(ref b);
                                    break;
                                case "Launch Time":
                                    continue;
                                case "Puppet Class":
                                    break;
                                case "Modification date":
                                    ModifyTime = getValue(ref b);
                                    break;
                                case "Instance Host":
                                    host = getValue(ref b);
                                    break;
                                case "Number of CPUs":
                                    NumberOfCpu = getValue(ref b);
                                    break;
                                case "RAM Size":
                                    Ram = getValue(ref b);
                                    break;
                                case "Amount of Storage":
                                    Storage = getValue(ref b);
                                    break;
                                case "fullurl":
                                    FullUrl = getValue(ref b);
                                    break;
                            }
                        }
                    }
                    System.IO.File.Delete(temp);
                    foreach (Instance x in deleted)
                    {
                        deleteInstance(x);
                    }
                }
                else
                {
                    core.Log("Failed to download db file", true);
                }
                URL = "https://labsconsole.wikimedia.org/wiki/Special:Ask/-5B-5BResource-20Type::project-5D-5D/-3F/-3FMember/-3FDescription/mainlabel%3D-2D/searchlabel%3Dprojects/offset%3D0/limit%3D500/format%3Djson";
                temp = System.IO.Path.GetTempFileName();
                if (Download(URL, temp))
                {
                    System.IO.StreamReader a = System.IO.File.OpenText(temp);
                    JsonTextReader b = new JsonTextReader(a);
                    string name = "{unknown}";
                    List<Nova> projectlist2 = new List<Nova>();
                    List<string> members = new List<string>();
                    string description = "{unknown}";
                    while (b.Read())
                    {
                        if (b.Value == null)
                        {
                            continue;
                        }
                        //Console.WriteLine(b.Value.ToString());
                        string value = b.Value.ToString();
                        if (value.StartsWith("Nova Resource:"))
                        {
                            value = value.Substring("Nova Resource:".Length);
                            if (name != "{unknown}")
                            {
                                Nova project = null;
                                foreach (Nova x in projectlist2)
                                {
                                    if (x.Name == value)
                                    {
                                        project = x;
                                        break;
                                    }
                                }
                                if (project == null)
                                {
                                    project = new Nova(name);
                                }
                                project.users.AddRange(members);
                                if (!(description == "" && project.Description == ""))
                                {
                                    project.Description = description;
                                }
                                else if (project.Description == "")
                                {
                                    project.Description = "there is no description for this item";
                                }
                                description = "";
                                if (!projectlist2.Contains(project))
                                {
                                    projectlist2.Add(project);
                                }
                                members.Clear();
                            }
                            name = value;
                        }
                        if (value.StartsWith("User:"******"Description")
                        {
                            description = getValue(ref b, true);
                        }
                    }
                    System.IO.File.Delete(temp);
                    lock (ProjectList)
                    {
                        ProjectList.Clear();
                        ProjectList.AddRange(projectlist2);
                    }
                    lock (Instances)
                    {
                        foreach (Instance i in Instances)
                        {
                            Nova nova = getProject(i.Project);
                            if (nova != null)
                            {
                                i.project = nova;
                                lock (nova.instances)
                                {
                                    if (!nova.instances.Contains(i))
                                    {
                                        nova.instances.Add(i);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    core.Log("Failed to download db file", true);
                }
                OK = true;
                LastUpdate = DateTime.Now;
            }
            catch (Exception t)
            {
                core.Log(t.Data + t.StackTrace);
                core.handleException(t);
            }
        }
コード例 #13
0
 public static ScriptRuntime GetRuntime()
 {
     return(Nova.CreateRuntime(Nova.CreateNovaSetup(), Ruby.CreateRubySetup()));
 }
コード例 #14
0
        private static dynamic Match(object rawLeft, object rawRight, NovaExpressionType novaBinaryNodeType, object rawScope)
        {
            var scope = (NovaScope)rawScope;

            var left  = CompilerServices.CompileExpression((Expression)rawLeft, scope);
            var right = CompilerServices.CompileExpression((Expression)rawRight, scope);

            var NovaName = "=~";
            var clrName  = InteropBinder.ToClrOperatorName(NovaName);

            if (left is NovaInstance)
            {
                var lo = (NovaInstance)left;
                DynamicMetaObject dmo = lo.GetMetaObject(Expression.Constant(left));
                if (InteropBinder.InvokeMember.SearchForFunction(lo.Class, NovaName, lo, L(Arg(right)), true) != null)
                {
                    if (novaBinaryNodeType == NovaExpressionType.NotMatch)
                    {
                        return(!dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                     _DMO(DMO(scope), DMO(Arg(right)))));
                    }
                    return(dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                _DMO(DMO(scope), DMO(Arg(right)))));
                }
                if (InteropBinder.InvokeMember.SearchForFunction(lo.Class, clrName, lo, L(Arg(right)), true) != null)
                {
                    if (novaBinaryNodeType == NovaExpressionType.NotMatch)
                    {
                        return(!dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                     _DMO(DMO(scope), DMO(Arg(right)))));
                    }
                    return(dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                _DMO(DMO(scope), DMO(Arg(right)))));
                }
            }

            var Value = Nova.Box(left);

            if (Value.Class != null)
            {
                var _dmo = Value.GetMetaObject(Expression.Constant(Value));
                if (InteropBinder.InvokeMember.SearchForFunction(Value.Class, NovaName, Value, L(Arg(right)), true) !=
                    null)
                {
                    if (novaBinaryNodeType == NovaExpressionType.NotMatch)
                    {
                        return(!_dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                      _DMO(DMO(scope), DMO(Arg(right)))));
                    }
                    return(_dmo.BindInvokeMember(new InteropBinder.InvokeMember(NovaName, new CallInfo(1), scope),
                                                 _DMO(DMO(scope), DMO(Arg(right)))));
                }
                if (InteropBinder.InvokeMember.SearchForFunction(Value.Class, clrName, Value, L(Arg(right)), true) !=
                    null)
                {
                    if (novaBinaryNodeType == NovaExpressionType.NotMatch)
                    {
                        return(!_dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                      _DMO(DMO(scope), DMO(Arg(right)))));
                    }
                    return(_dmo.BindInvokeMember(new InteropBinder.InvokeMember(clrName, new CallInfo(1), scope),
                                                 _DMO(DMO(scope), DMO(Arg(right)))));
                }
            }

            if (!(left is Regex || right is Regex))
            {
                return(null);
            }

            var left1 = left as Regex;
            var regex = left1 ?? (Regex)right;

            var str = (left is Regex) ? (string)right : (string)left;

            if (!regex.Match(str).Success)
            {
                return(novaBinaryNodeType == NovaExpressionType.NotMatch);
            }
            var groups = regex.Match(str).Groups;

            foreach (var groupName in regex.GetGroupNames())
            {
                scope[groupName] = groups[groupName].Value;
            }


            return(novaBinaryNodeType == NovaExpressionType.Match);
        }
コード例 #15
0
ファイル: Kernel.cs プロジェクト: nihilisticpandemonium/Nova
 private static dynamic Box(object val)
 {
     return(Nova.Box(val));
 }
コード例 #16
0
    public override bool Decide(StateMachine controller)
    {
        if (controller.skillController.Casting)
        {
            return(true);
        }

        var skills   = controller.skillController.skills;
        var distance = controller.target.transform.position - controller.transform.position;

        List <int> availableSkillsId = new List <int>();

        Blink blink = null;
        Nova  nova  = null;

        for (int i = 0; i < skills.Count; i++)
        {
            if (controller.skillController.cooldowns[i] <= 0)
            {
                if (distance.magnitude <= skills[i].minRangeToTarget || skills[i].minRangeToTarget == 0)
                {
                    availableSkillsId.Add(i);
                }

                if (skills[i].exactSkillType == ExactSkillType.Nova)
                {
                    nova = (Nova)skills[i];
                    availableSkillsId.Remove(i);
                }

                if (skills[i].exactSkillType == ExactSkillType.Blink)
                {
                    blink = (Blink)skills[i];
                    availableSkillsId.Remove(i);
                }
            }
        }

        if (nova != null)
        {
            if (distance.magnitude <= nova.radius)
            {
                controller.skill = nova;
                return(true);
            }
        }

        if (blink != null)
        {
            float blinkRange = (controller.transform.position.normalized + controller.transform.forward.normalized * blink.rangeMultiplier).magnitude;
            Debug.Log(blinkRange);

            if (distance.magnitude >= blinkRange)
            {
                controller.skill = blink;
                return(true);
            }
        }


        if (availableSkillsId.Count > 0)
        {
            int randomIndex = availableSkillsId[Random.Range(0, availableSkillsId.Count)];
            controller.skill = skills[randomIndex];

            return(true);
        }



        return(false);
    }
コード例 #17
0
 private static NovaClass GetBoxClass(object obj)
 {
     return(Nova.Box(obj.GetType()));
 }
コード例 #18
0
        internal static dynamic DefineClass(object rawName, object rawParent, List <Expression> contents, object rawScope)
        {
            lock (_classDefineLock) {
                if (Resolve(rawName, rawScope) != null)
                {
                    return(DefineCategory(Resolve(rawName, rawScope), contents, rawScope));
                }
                var scope       = (NovaScope)rawScope;
                var defineScope = _inClassDefine ? scope : scope.GlobalScope;
                _inClassDefine = true;
                NovaClass parent;
                if (rawParent == null)
                {
                    if (scope.GlobalScope["Object"] == null)
                    {
                        scope.GlobalScope["Object"] = Nova.Box(typeof(object));
                    }
                    parent = scope.GlobalScope["Object"];
                }
                else
                {
                    var dParent = Resolve(rawParent as string, scope);
                    if (dParent == null)
                    {
                        _inClassDefine = false;
                        return(null);
                    }
                    if (dParent is Type)
                    {
                        parent = Nova.Box(dParent);
                    }
                    else
                    {
                        parent = dParent as NovaClass;
                    }
                    if (parent == null)
                    {
                        _inClassDefine = false;
                        return(null);
                    }
                }

                var name = (string)rawName;
                _className = name;

                var @class = new NovaClass {
                    Name = _className, Parent = parent
                };
                var xScope = new NovaScope(scope);
                xScope["self"]     = @class;
                xScope[_className] = @class;
                _currentClassScope = xScope;

                contents.ForEach(content => {
                    if (content is IncludeExpression)
                    {
                        // We only include modules here so make sure this include references a module
                        var names = ((IncludeExpression)content).Names;

                        dynamic module = null;

                        var index = 0;
                        names.ForEach(mname => {
                            if ((module is NovaModule))
                            {
                                module = module.Context[mname];
                            }
                            else if (index == 0)
                            {
                                module = scope[mname];
                            }
                            index = index + 1;
                        });

                        if (module != null)
                        {
                            if (module is NovaModule)
                            {
                                ((NovaModule)module).Contents.ForEach(mcon => {
                                    if (mcon is NovaFunction)
                                    {
                                        if ((mcon as NovaFunction).IsSingleton ||
                                            (mcon as NovaFunction).Name == "new")
                                        {
                                            NovaClass.AddMethod(@class.ClassMethods, mcon as NovaFunction);
                                        }
                                        else
                                        {
                                            NovaClass.AddMethod(@class.InstanceMethods, mcon as NovaFunction);
                                        }
                                        if (@class.RemovedMethods.Contains((mcon as NovaFunction).Name))
                                        {
                                            @class.RemovedMethods.Remove((mcon as NovaFunction).Name);
                                        }
                                        if (@class.UndefinedMethods.Contains((mcon as NovaFunction).Name))
                                        {
                                            @class.UndefinedMethods.Remove((mcon as NovaFunction).Name);
                                        }
                                    }
                                });

                                xScope.MergeWithScope(module.Context);
                            }
                            else if (module is NovaClass)
                            {
                                xScope[((NovaClass)module).Name] = module;
                            }
                        }
                    }
                });

                contents.ForEach(content => {
                    if (!(content is IncludeExpression))
                    {
                        var result = CompilerServices.CompileExpression(content, xScope);
                        if (result is NovaFunction)
                        {
                            if ((result as NovaFunction).IsSingleton || (result as NovaFunction).Name == "new")
                            {
                                NovaClass.AddMethod(@class.ClassMethods, result as NovaFunction);
                            }
                            else
                            {
                                NovaClass.AddMethod(@class.InstanceMethods, result as NovaFunction);
                            }
                            if (@class.RemovedMethods.Contains((result as NovaFunction).Name))
                            {
                                @class.RemovedMethods.Remove((result as NovaFunction).Name);
                            }
                            if (@class.UndefinedMethods.Contains((result as NovaFunction).Name))
                            {
                                @class.UndefinedMethods.Remove((result as NovaFunction).Name);
                            }
                        }
                    }
                });

                if ([email protected]("new"))
                {
                    NovaClass.AddMethod(@class.ClassMethods, new NovaFunction("new", new List <FunctionArgument>(),
                                                                              NovaExpression.NovaBlock(
                                                                                  NovaExpression.Return(new List <FunctionArgument> {
                        new FunctionArgument(null, NovaExpression.Variable(Expression.Constant("self")))
                    }),
                                                                                  Expression.Label(NovaParser.ReturnTarget, Expression.Constant(null, typeof(object)))),
                                                                              new NovaScope()));
                }
                @class.Context           = xScope;
                defineScope[@class.Name] = @class;
                _inClassDefine           = false;
                return(@class);
            }
        }
コード例 #19
0
ファイル: Class1.cs プロジェクト: MatmaRex/wikimedia-bot
        public void JSON()
        {
            try
            {
                string URL  = "https://labsconsole.wikimedia.org/wiki/Special:Ask/-5B-5BResource-20Type::instance-5D-5D/-3FInstance-20Name/-3FInstance-20Type/-3FProject/-3FImage-20Id/-3FFQDN/-3FLaunch-20Time/-3FPuppet-20Class/-3FModification-20date/-3FInstance-20Host/-3FNumber-20of-20CPUs/-3FRAM-20Size/-3FAmount-20of-20Storage/limit%3D500/format%3Djson";
                string temp = System.IO.Path.GetTempFileName();
                if (Download(URL, temp))
                {
                    List <Instance> deleted = new List <Instance>();
                    lock (Instances)
                    {
                        deleted.AddRange(Instances);
                    }
                    System.IO.StreamReader a = System.IO.File.OpenText(temp);
                    JsonTextReader         b = new JsonTextReader(a);
                    string name        = "{unknown}";
                    string host        = "{unknown}";
                    string ip          = "{unknown}";
                    string project     = "{unknown}";
                    string resource    = "{unknown}";
                    string image       = "{unknown}";
                    string Ram         = "{unknown}";
                    string NumberOfCpu = "{unknown}";
                    string ModifyTime  = "{unknown}";
                    string Storage     = "{unknown}";
                    string FullUrl     = "{unknown}";
                    string fqdn        = "{unknown}";
                    string LaunchTime  = "{unknown}";
                    string type        = "{unknown}";
                    while (b.Read())
                    {
                        if (b.TokenType == JsonToken.PropertyName)
                        {
                            if (b.Value == null)
                            {
                                core.DebugLog("null at value");
                                continue;
                            }
                            string value = b.Value.ToString();
                            if (value.StartsWith("Nova Resource:"))
                            {
                                value = value.Substring("Nova Resource:".Length);
                                if (resource != "{unknown}")
                                {
                                    Instance instance = getInstance(resource);
                                    if (instance != null)
                                    {
                                        if (deleted.Contains(instance))
                                        {
                                            deleted.Remove(instance);
                                        }
                                        deleteInstance(instance);
                                    }
                                    try
                                    {
                                        IPAddress[] addresslist = Dns.GetHostAddresses(resource);

                                        if (addresslist.Length > 0)
                                        {
                                            ip = addresslist[0].ToString();
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        core.DebugLog("can't resolve" + resource);
                                    }
                                    instance             = new Instance(resource, name, host, ip, type, true);
                                    instance.fqdn        = fqdn;
                                    instance.FullUrl     = FullUrl;
                                    instance.ImageID     = image;
                                    instance.LaunchTime  = LaunchTime;
                                    instance.ModifyTime  = ModifyTime;
                                    instance.NumberOfCpu = NumberOfCpu;
                                    instance.Project     = project;
                                    instance.Ram         = Ram;
                                    instance.Storage     = Storage;
                                    lock (Instances)
                                    {
                                        Instances.Add(instance);
                                    }
                                    name        = "{unknown}";
                                    host        = "{unknown}";
                                    ip          = "{unknown}";
                                    project     = "{unknown}";
                                    resource    = "{unknown}";
                                    image       = "{unknown}";
                                    Ram         = "{unknown}";
                                    NumberOfCpu = "{unknown}";
                                    ModifyTime  = "{unknown}";
                                    Storage     = "{unknown}";
                                    FullUrl     = "{unknown}";
                                    fqdn        = "{unknown}";
                                    LaunchTime  = "{unknown}";
                                    type        = "{unknown}";
                                }
                                resource = value;
                            }
                            switch (b.Value.ToString())
                            {
                            case "Instance Name":
                                name = getValue(ref b);
                                break;

                            case "Instance Type":
                                type = getValue(ref b);
                                break;

                            case "Project":
                                project = getValue(ref b);
                                break;

                            case "Image Id":
                                image = getValue(ref b);
                                break;

                            case "FQDN":
                                fqdn = getValue(ref b);
                                break;

                            case "Launch Time":
                                continue;

                            case "Puppet Class":
                                break;

                            case "Modification date":
                                ModifyTime = getValue(ref b);
                                break;

                            case "Instance Host":
                                host = getValue(ref b);
                                break;

                            case "Number of CPUs":
                                NumberOfCpu = getValue(ref b);
                                break;

                            case "RAM Size":
                                Ram = getValue(ref b);
                                break;

                            case "Amount of Storage":
                                Storage = getValue(ref b);
                                break;

                            case "fullurl":
                                FullUrl = getValue(ref b);
                                break;
                            }
                        }
                    }
                    System.IO.File.Delete(temp);
                    foreach (Instance x in deleted)
                    {
                        deleteInstance(x);
                    }
                }
                else
                {
                    core.Log("Labs: Failed to download db file", true);
                }
                URL  = "https://labsconsole.wikimedia.org/wiki/Special:Ask/-5B-5BResource-20Type::project-5D-5D/-3F/-3FMember/-3FDescription/mainlabel%3D-2D/searchlabel%3Dprojects/offset%3D0/limit%3D500/format%3Djson";
                temp = System.IO.Path.GetTempFileName();
                if (Download(URL, temp))
                {
                    System.IO.StreamReader a   = System.IO.File.OpenText(temp);
                    JsonTextReader         b   = new JsonTextReader(a);
                    string        name         = "{unknown}";
                    List <Nova>   projectlist2 = new List <Nova>();
                    List <string> members      = new List <string>();
                    string        description  = "{unknown}";
                    while (b.Read())
                    {
                        if (b.Value == null)
                        {
                            continue;
                        }
                        //Console.WriteLine(b.Value.ToString());
                        string value = b.Value.ToString();
                        if (value.StartsWith("Nova Resource:"))
                        {
                            value = value.Substring("Nova Resource:".Length);
                            if (name != "{unknown}")
                            {
                                Nova project = null;
                                foreach (Nova x in projectlist2)
                                {
                                    if (x.Name == value)
                                    {
                                        project = x;
                                        break;
                                    }
                                }
                                if (project == null)
                                {
                                    project = new Nova(name);
                                }
                                project.users.AddRange(members);
                                if (!(description == "" && project.Description == ""))
                                {
                                    project.Description = description;
                                }
                                else if (project.Description == "")
                                {
                                    project.Description = "there is no description for this item";
                                }
                                description = "";
                                if (!projectlist2.Contains(project))
                                {
                                    projectlist2.Add(project);
                                }
                                members.Clear();
                            }
                            name = value;
                        }
                        if (value.StartsWith("User:"******"Description")
                        {
                            description = getValue(ref b, true);
                        }
                    }
                    System.IO.File.Delete(temp);
                    lock (ProjectList)
                    {
                        ProjectList.Clear();
                        ProjectList.AddRange(projectlist2);
                    }
                    lock (Instances)
                    {
                        foreach (Instance i in Instances)
                        {
                            Nova nova = getProject(i.Project);
                            if (nova != null)
                            {
                                i.project = nova;
                                lock (nova.instances)
                                {
                                    if (!nova.instances.Contains(i))
                                    {
                                        nova.instances.Add(i);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    core.Log("Failed to download db file", true);
                }
                OK         = true;
                LastUpdate = DateTime.Now;
            }
            catch (Exception t)
            {
                core.Log(t.Data + t.StackTrace);
                core.handleException(t, "Labs");
            }
        }
コード例 #20
0
ファイル: Class1.cs プロジェクト: MatmaRex/wikimedia-bot
        public override void Hook_PRIV(config.channel channel, User invoker, string message)
        {
            if (message.StartsWith("@labs-off"))
            {
                if (channel.Users.IsApproved(invoker, "admin"))
                {
                    if (!GetConfig(channel, "LABS.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage("Labs utilities are already disabled", channel.Name);
                        return;
                    }
                    SetConfig(channel, "LABS.Enabled", false);
                    channel.SaveConfig();
                    core.irc._SlowQueue.DeliverMessage("Labs utilities were disabled", channel.Name);
                    return;
                }
                else
                {
                    if (!channel.suppress_warnings)
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                    }
                }
                return;
            }


            if (message.StartsWith("@labs-on"))
            {
                if (channel.Users.IsApproved(invoker, "admin"))
                {
                    if (GetConfig(channel, "LABS.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage("Labs utilities are already enabled", channel.Name);
                        return;
                    }
                    SetConfig(channel, "LABS.Enabled", true);
                    channel.SaveConfig();
                    core.irc._SlowQueue.DeliverMessage("Labs utilities were enabled", channel.Name);
                    return;
                }
                else
                {
                    if (!channel.suppress_warnings)
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                    }
                }
                return;
            }

            if (message.StartsWith("@labs-user "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string user   = message.Substring(11);
                    string result = getProjects(user);
                    int    list   = getNumbers(user);
                    if (result != "")
                    {
                        core.irc._SlowQueue.DeliverMessage(user + " is member of " + list.ToString() + " projects: " + result, channel.Name);
                        return;
                    }
                    core.irc._SlowQueue.DeliverMessage("That user is not a member of any project", channel.Name);
                    return;
                }
            }

            if (message.StartsWith("@labs-info "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string host    = message.Substring("@labs-info ".Length);
                    string results = "";
                    if (!OK)
                    {
                        core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of instances", channel.Name);
                        return;
                    }
                    Instance instance = getInstance(host);
                    if (instance == null)
                    {
                        instance = resolve(host);
                        if (instance != null)
                        {
                            results = "[Name " + host + " doesn't exist but resolves to " + instance.OriginalName + "] ";
                        }
                    }
                    if (instance != null)
                    {
                        results += instance.OriginalName + " is Nova Instance with name: " + instance.Name + ", host: " + instance.Host + ", IP: " + instance.IP
                                   + " of type: " + instance.Type + ", with number of CPUs: " + instance.NumberOfCpu + ", RAM of this size: " + instance.Ram
                                   + "M, member of project: " + instance.Project + ", size of storage: " + instance.Storage + " and with image ID: " + instance.ImageID;

                        core.irc._SlowQueue.DeliverMessage(results, channel.Name);
                        return;
                    }
                    core.irc._SlowQueue.DeliverMessage("I don't know this instance, sorry, try browsing the list by hand, but I can guarantee there is no such instance matching this name, host or Nova ID unless it was created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                }
            }

            if (message.StartsWith("@labs-resolve "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string host = message.Substring("@labs-resolve ".Length);
                    if (!OK)
                    {
                        core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of instances", channel.Name);
                        return;
                    }
                    Instance instance = resolve(host);
                    if (instance != null)
                    {
                        string d = "The " + host + " resolves to instance " + instance.OriginalName + " with a fancy name " + instance.Name + " and IP " + instance.IP;
                        core.irc._SlowQueue.DeliverMessage(d, channel.Name);
                        return;
                    }
                    string names = "";
                    lock (Instances)
                    {
                        foreach (Instance instance2 in Instances)
                        {
                            if (instance2.Name.Contains(host) || instance2.OriginalName.Contains(host))
                            {
                                names += instance2.OriginalName + " (" + instance2.Name + "), ";
                                if (names.Length > 210)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (names != "")
                    {
                        core.irc._SlowQueue.DeliverMessage("I don't know this instance - aren't you are looking for: " + names, channel.Name);
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage("I don't know this instance, sorry, try browsing the list by hand, but I can guarantee there is no such instance matching this name, host or Nova ID unless it was created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                    }
                }
            }

            if (message.StartsWith("@labs-project-users "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string host = message.Substring("@labs-project-users ".Length);
                    if (!OK)
                    {
                        core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", channel.Name);
                        return;
                    }
                    Nova project = getProject(host);
                    if (project != null)
                    {
                        string instances = "";
                        int    trimmed   = 0;
                        lock (project.instances)
                        {
                            foreach (string x in project.users)
                            {
                                if (instances.Length > 180)
                                {
                                    break;
                                }
                                trimmed++;
                                instances = instances + x + ", ";
                            }
                            if (trimmed == project.users.Count)
                            {
                                core.irc._SlowQueue.DeliverMessage("Following users are in this project (showing all " + project.users.Count.ToString() + " members): " + instances, channel.Name);
                                return;
                            }
                            core.irc._SlowQueue.DeliverMessage("Following users are in this project (displaying " + trimmed.ToString() + " of " + project.users.Count.ToString() + " total): " + instances, channel.Name);
                            return;
                        }
                    }
                    string names = getProjectsList(host);
                    if (names != "")
                    {
                        core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                        return;
                    }
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                }
            }

            if (message.StartsWith("@labs-project-instances "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string host = message.Substring("@labs-project-instances ".Length);
                    if (!OK)
                    {
                        core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", channel.Name);
                        return;
                    }
                    Nova project = getProject(host);
                    if (project != null)
                    {
                        string instances = "";
                        lock (project.instances)
                        {
                            foreach (Instance x in project.instances)
                            {
                                instances = instances + x.Name + ", ";
                            }
                            core.irc._SlowQueue.DeliverMessage("Following instances are in this project: " + instances, channel.Name);
                            return;
                        }
                    }
                    string names = getProjectsList(host);
                    if (names != "")
                    {
                        core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                        return;
                    }
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                }
            }

            if (message.StartsWith("@labs-project-info "))
            {
                if (GetConfig(channel, "LABS.Enabled", false))
                {
                    string host = message.Substring("@labs-project-info ".Length);
                    if (!OK)
                    {
                        core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", channel.Name);
                        return;
                    }
                    Nova project = getProject(host);
                    if (project != null)
                    {
                        string d = "The project " + project.Name + " has " + project.instances.Count.ToString() + " instances and " + project.users.Count.ToString() + " members, description: " + project.Description;
                        core.irc._SlowQueue.DeliverMessage(d, channel.Name);
                        return;
                    }
                    string names = getProjectsList(host);
                    if (names != "")
                    {
                        core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                        return;
                    }
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", channel.Name);
                }
            }
        }
コード例 #21
0
ファイル: Class1.cs プロジェクト: MatmaRex/wikimedia-bot
        public override bool Hook_OnPrivateFromUser(string message, User user)
        {
            if (message.StartsWith("@labs-user "))
            {
                string user2  = message.Substring(11);
                string result = getProjects(user2);
                int    list   = getNumbers(user2);
                if (result != "")
                {
                    core.irc._SlowQueue.DeliverMessage(user2 + " is member of " + list.ToString() + " projects: " + result, user);
                    return(true);
                }
                core.irc._SlowQueue.DeliverMessage("That user is not a member of any project", user);
                return(true);
            }

            if (message.StartsWith("@labs-info "))
            {
                string host    = message.Substring("@labs-info ".Length);
                string results = "";
                if (!OK)
                {
                    core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of instances", user);
                    return(true);
                }
                Instance instance = getInstance(host);
                if (instance == null)
                {
                    instance = resolve(host);
                    if (instance != null)
                    {
                        results = "[Name " + host + " doesn't exist but resolves to " + instance.OriginalName + "] ";
                    }
                }
                if (instance != null)
                {
                    results += instance.OriginalName + " is Nova Instance with name: " + instance.Name + ", host: " + instance.Host + ", IP: " + instance.IP
                               + " of type: " + instance.Type + ", with number of CPUs: " + instance.NumberOfCpu + ", RAM of this size: " + instance.Ram
                               + "M, member of project: " + instance.Project + ", size of storage: " + instance.Storage + " and with image ID: " + instance.ImageID;

                    core.irc._SlowQueue.DeliverMessage(results, user.Nick);
                    return(true);
                }
                core.irc._SlowQueue.DeliverMessage("I don't know this instance, sorry, try browsing the list by hand, but I can guarantee there is no such instance matching this name, host or Nova ID unless it was created less than " + time().Seconds.ToString() + " seconds ago", user);
                return(true);
            }

            if (message.StartsWith("@labs-resolve "))
            {
                string host = message.Substring("@labs-resolve ".Length);
                if (!OK)
                {
                    core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of instances", user);
                    return(true);
                }
                Instance instance = resolve(host);
                if (instance != null)
                {
                    string d = "The " + host + " resolves to instance " + instance.OriginalName + " with a fancy name " + instance.Name + " and IP " + instance.IP;
                    core.irc._SlowQueue.DeliverMessage(d, user);
                    return(true);
                }
                string names = "";
                lock (Instances)
                {
                    foreach (Instance instance2 in Instances)
                    {
                        if (instance2.Name.Contains(host) || instance2.OriginalName.Contains(host))
                        {
                            names += instance2.OriginalName + " (" + instance2.Name + "), ";
                            if (names.Length > 210)
                            {
                                break;
                            }
                        }
                    }
                }
                if (names != "")
                {
                    core.irc._SlowQueue.DeliverMessage("I don't know this instance - aren't you are looking for: " + names, user);
                    return(true);
                }
                else
                {
                    core.irc._SlowQueue.DeliverMessage("I don't know this instance, sorry, try browsing the list by hand, but I can guarantee there is no such instance matching this name, host or Nova ID unless it was created less than " + time().Seconds.ToString() + " seconds ago", user);
                    return(true);
                }
            }

            if (message.StartsWith("@labs-project-users "))
            {
                string host = message.Substring("@labs-project-users ".Length);
                if (!OK)
                {
                    core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", user);
                    return(true);
                }
                Nova project = getProject(host);
                if (project != null)
                {
                    string instances = "";
                    int    trimmed   = 0;
                    lock (project.instances)
                    {
                        foreach (string x in project.users)
                        {
                            if (instances.Length > 180)
                            {
                                break;
                            }
                            trimmed++;
                            instances = instances + x + ", ";
                        }
                        if (trimmed == project.users.Count)
                        {
                            core.irc._SlowQueue.DeliverMessage("Following users are in this project (showing all " + project.users.Count.ToString() + " members): " + instances, user);
                            return(true);
                        }
                        core.irc._SlowQueue.DeliverMessage("Following users are in this project (displaying " + trimmed.ToString() + " of " + project.users.Count.ToString() + " total): " + instances, user);
                        return(true);
                    }
                }
                string names = getProjectsList(host);
                if (names != "")
                {
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                    return(true);
                }
                core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                return(true);
            }

            if (message.StartsWith("@labs-project-instances "))
            {
                string host = message.Substring("@labs-project-instances ".Length);
                if (!OK)
                {
                    core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", user);
                    return(true);
                }
                Nova project = getProject(host);
                if (project != null)
                {
                    string instances = "";
                    lock (project.instances)
                    {
                        foreach (Instance x in project.instances)
                        {
                            instances = instances + x.Name + ", ";
                        }
                        core.irc._SlowQueue.DeliverMessage("Following instances are in this project: " + instances, user);
                        return(true);
                    }
                }
                string names = getProjectsList(host);
                if (names != "")
                {
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                    return(true);
                }
                core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                return(true);
            }

            if (message.StartsWith("@labs-project-info "))
            {
                string host = message.Substring("@labs-project-info ".Length);
                if (!OK)
                {
                    core.irc._SlowQueue.DeliverMessage("Please wait, I still didn't retrieve the labs datafile containing the list of projects", user);
                    return(true);
                }
                Nova project = getProject(host);
                if (project != null)
                {
                    string d = "The project " + project.Name + " has " + project.instances.Count.ToString() + " instances and " + project.users.Count.ToString() + " members, description: " + project.Description;
                    core.irc._SlowQueue.DeliverMessage(d, user);
                    return(true);
                }
                string names = getProjectsList(host);
                if (names != "")
                {
                    core.irc._SlowQueue.DeliverMessage("I don't know this project, did you mean: " + names + "? I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                    return(true);
                }
                core.irc._SlowQueue.DeliverMessage("I don't know this project, sorry, try browsing the list by hand, but I can guarantee there is no such project matching this name unless it has been created less than " + time().Seconds.ToString() + " seconds ago", user);
                return(true);
            }
            return(base.Hook_OnPrivateFromUser(message, user));
        }