From 44da48dcf205543752c61eaaf44b91282a60d603 Mon Sep 17 00:00:00 2001 From: anekos Date: Sat, 31 Jul 2010 13:17:23 +0000 Subject: 生首をクビにした git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38103 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index 20dfe81..1edf0a6 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1172,28 +1172,21 @@ } function onMsg (msg, raw) { - if (msg.text) { - let talk = msg.user.screen_name + ": " + msg.text; - - liberator.echo(talk, commandline.FORCE_SINGLELINE); + listeners.forEach(function (listener) liberator.trapErrors(function () listener(msg, raw))); + if (msg.text) { history.unshift(msg); if (history.length > 1000) history = history.slice(0, 1000); - - if (plugins.namakubi) - plugins.namakubi.talk(talk); - } else { - let s = []; - for (let [n, v] in Iterator(msg)) - s.push(n + ": " + (n == "user" ? v.screen_name : v)); - liberator.log(s.join("\n")); } } + let listeners = []; + return { start: start, - stop: stop + stop: stop, + addListener: function (func) listeners.push(func) }; })(); // }}} function xmlhttpRequest(options) { // {{{ -- cgit v1.2.3