Skip to content
Commit 76808c88 authored by Andrew Price's avatar Andrew Price
Browse files

New mwjs API

- Better namespacing.
- Useful message objects.
- New generic event mechanism instead of just message received events.
- mw.onevent array of function refs instead of weird bind() calls:
  > mw.onevent.push(myhandler);
- Discoverable:
  > mw.print(Object.getOwnPropertyNames(mw));
  onevent,print,exec,say,wholist,urlget,beep,input,termsize

Example:

  function handler(ev)
  {
        if (ev.type == "message_received") {
                msg = ev.data;
                // Some fields only defined for certain message types
                mw.print("msg.text: " + msg.text);
                mw.print("msg.unixtime: " + msg.unixtime);
                mw.print("msg.serial: " + msg.serial);
                mw.print("msg.ipc_type: " + msg.ipc_type);
                mw.print("msg.from_name: " + msg.from_name);
                mw.print("msg.to_name: " + msg.to_name);
                mw.print("msg.type: " + msg.type);
                mw.print("msg.excluded_name: " + msg.excluded_name);
                mw.print("msg.suffix: " + msg.suffix);
        }
  }
  mw.onevent.push(handler);
parent dd30057e
Loading
Loading
Loading
Pipeline #387 failed with stage
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment