public Objects.JSUser GetUser(IUser client) { if (client == null) { return(null); } Objects.JSUser result = null; if (!client.Link.IsLinked) { result = this.local_users.Find(x => x.Name == client.Name); } else { this.leaves.ForEach(x => { if (x.Ident == client.Link.Ident) { result = x.users.Find(z => z.Name == client.Name); if (result != null) { return; } } }); } return(result); }
public bool CanScribble(IUser client) { if (this.CanScript) { JSScript[] scripts = ScriptManager.Scripts.ToArray(); foreach (JSScript s in scripts) { try { Objects.JSUser u = new Objects.JSUser(s.JS.Object.InstancePrototype, client, s.ScriptName); bool result = s.JS.CallGlobalFunction <bool>("onScribbleCheck", u); if (!result) { return(false); } } catch (Jurassic.JavaScriptException e) { ErrorDispatcher.SendError(s.ScriptName, e.Message, e.LineNumber); } catch { } } } return(true); }
public bool CanScribble(IUser client, bool isPM = false) { if (this.CanScript) { JSScript[] scripts = ScriptManager.Scripts.ToArray(); foreach (JSScript s in scripts) { try { // Adding the isPM shouldnt break any existing scripts due to how javascript works Objects.JSUser u = new Objects.JSUser(s.JS.Object.InstancePrototype, client, s.ScriptName); bool result = s.JS.CallGlobalFunction <bool>("onScribbleCheck", u, isPM); if (!result) { return(false); } } catch (Jurassic.JavaScriptException e) { ErrorDispatcher.SendError(s.ScriptName, e.Message, e.LineNumber); } catch { } } } return(true); }
public Objects.JSUser GetIgnoredUser(String name) { Objects.JSUser result = this.local_users.Find(x => x.Name == name); if (result == null) { this.leaves.ForEach(x => { result = x.users.Find(z => z.Name == name); if (result != null) { return; } }); } return(result); }
public void Joined(IUser client) { if (this.CanScript) { ScriptManager.Scripts.ForEach(x => { if (!client.Link.IsLinked) { x.local_users.RemoveAll(z => z.Name == client.Name); x.local_users.Add(new Objects.JSUser(x.JS.Object.InstancePrototype, client, x.ScriptName)); } else { x.leaves.ForEach(z => { if (z.Ident == client.Link.Ident) { z.users.RemoveAll(y => y.Name == client.Name); z.users.Add(new Objects.JSUser(x.JS.Object.InstancePrototype, client, x.ScriptName)); } }); } }); JSScript[] scripts = ScriptManager.Scripts.ToArray(); foreach (JSScript s in scripts) { Objects.JSUser u = s.GetUser(client); if (u != null) { try { s.JS.CallGlobalFunction("onJoin", u); } catch (Jurassic.JavaScriptException e) { ErrorDispatcher.SendError(s.ScriptName, e.Message, e.LineNumber); } }
public JSUser FindUser(object a) { JSUser result = null; if (!(a is Undefined)) { String str = a.ToString(); if (str.Length > 0) { result = this.users.Find(x => x.Name == str); if (result == null) { result = this.users.Find(x => x.Name.StartsWith(str)); } } } return(result); }
public JSIgnoreCollection(ObjectInstance prototype, String[] ignores, String scriptName) : base(prototype.Engine, ((ClrFunction)prototype.Engine.Global["IgnoreCollection"]).InstancePrototype) { this.PopulateFunctions(); this.count = 0; JSScript script = ScriptManager.Scripts.Find(x => x.ScriptName == scriptName); if (script != null) { foreach (String str in ignores) { if (!String.IsNullOrEmpty(str)) { JSUser u = script.GetIgnoredUser(str); if (u == null) { script.leaves.ForEach(x => { u = x.FindUser(str); if (u != null) { return; } }); } if (u != null) { this.SetPropertyValue((uint)this.count++, u, throwOnError: true); } } } } }