aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator/dump-msg.tw
blob: 7de3c348743eeb4de8722599e843cfbffa89f583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Please write the below line into .vimperatorrc.
 * let g:twittperator_plugin_dump_msg = 1
 */


(function () {
  function objectToString (obj, head) {
    if (!head)
      head = '';

    let result = '';
    for (let [n, v] in Iterator(obj)) {
      if (v && typeof v === 'object') {
        result += head + n + ':\n' + objectToString(v, head + '  ');
      } else {
        result += head + n + ': ' + v + '\n';
      }
    }

    return result;
  }

  plugins.twittperator.ChirpUserStream.addListener(
    function onMsg (msg, raw) {
      liberator.log('\n' + objectToString(msg));
    }
  );
})();

// vim: sw=2 ts=2 et fdm=marker ft=javascript: