• Andrew Price's avatar
    New mwjs API · 76808c88
    Andrew Price authored
    - 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);
    76808c88
ipc.h 2.04 KB