public void onMessage( String channel, String sender, String login, String hostname, String message) { JSFunction onMessage = (JSFunction) _things.get("onMessage"); if (onMessage == null) return; JSObjectBase o = new JSObjectBase(); o.set("channel", channel); o.set("sender", sender); o.set("login", login); o.set("hostname", hostname); o.set("message", message); onMessage.call(onMessage.getScope(), o); }
static { _functions.set("toFixed", toFixed); _functions.set( "to_f", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { return ((Number) s.getThis()).doubleValue(); } }); _functions.set( "round", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { return (int) (((Number) s.getThis()).doubleValue() + .5); } }); _functions.set( "times", new JSFunctionCalls1() { public Object call(Scope s, Object func, Object foo[]) { final int t = ((Number) s.getThis()).intValue(); final JSFunction f = (JSFunction) func; return _loop(s, f, 0, t); } }); _functions.set( "upto", new JSFunctionCalls2() { public Object call(Scope s, Object num, Object func, Object foo[]) { final int start = ((Number) s.getThis()).intValue(); final int end = ((Number) num).intValue() + 1; final JSFunction f = (JSFunction) func; return _loop(s, f, start, end); } }); _functions.set( "chr", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { return (char) (((Number) s.getThis()).intValue()); } }); _functions.set( "zero_q_", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { return ((Number) s.getThis()).doubleValue() == 0; } }); _functions.set( "valueOf", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { Object o = s.getThis(); if (o instanceof JSObjectBase && ((JSObjectBase) o).getConstructor() instanceof Cons) return ((Cons) ((JSObjectBase) o).getConstructor())._parse(null, null); if (o instanceof Number) return o; if (!(o instanceof JSNumber)) throw new JSException("TypeError: valueOf must be called on a Number"); return ((JSNumber) o)._val; } }); _functions.set( "toString", new JSFunctionCalls0() { public Object call(Scope s, Object foo[]) { return new JSString(s.getThis().toString()); } }); _functions.set("kilobytes", new Conversion(1024)); _functions.set("megabytes", new Conversion(1024 * 1024)); _functions.set("seconds", new Conversion(1000)); _functions.set("minutes", new Conversion(1000 * 60)); _functions.set("hours", new Conversion(1000 * 60 * 60)); _functions.set("days", new Conversion(1000 * 60 * 60 * 24)); _functions.set("weeks", new Conversion(1000 * 60 * 60 * 24 * 7)); _functions.set("years", new Conversion(1000 * 60 * 60 * 24 * 365.25)); }