From 9b0249a0f687795caec587342e686300c6c7a39d Mon Sep 17 00:00:00 2001 From: anekos Date: Wed, 22 Aug 2012 00:28:15 +0900 Subject: Add sub-command "tw!restartstreams" to twittperator --- twittperator.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index 651afb0..42da2f2 100644 --- a/twittperator.js +++ b/twittperator.js @@ -26,7 +26,7 @@ // INFO {{{ let INFO = <> - teramako @@ -175,7 +175,7 @@ let INFO = Write the plugin.

- @@ -2475,6 +2475,11 @@ let INFO = description: "Find people with the words.", action: function(arg) Twittperator.showUsersSeachResult(arg), }), + SubCommand({ + command: ["restartstreams"], + description: "Restart streams", + action: function(arg) startStreams(), + }), ]; SubCommands.add = function(subCmd) { @@ -2675,6 +2680,19 @@ let INFO = let ChirpUserStream = Stream({ name: 'chirp stream', url: "https://userstream.twitter.com/2/user.json" }); let TrackingStream = Stream({ name: 'tracking stream', url: "https://stream.twitter.com/1/statuses/filter.json" }); + let startStreams = function () { + if (setting.useChirp){ + if(setting.allReplies) + ChirpUserStream.start({"replies":"all"}); + else + ChirpUserStream.start(); + } + + let trackWords = setting.trackWords || Store.get("trackWords"); + if (trackWords) + TrackingStream.start({track: trackWords}); + }; + // 公開オブジェクト __context__.OAuth = tw; __context__.ChirpUserStream = ChirpUserStream; @@ -2689,20 +2707,7 @@ let INFO = Twittperator.loadPlugins(); - liberator.registerObserver( - 'enter', - function () { - if (setting.useChirp){ - if(setting.allReplies) - ChirpUserStream.start({"replies":"all"}); - else - ChirpUserStream.start(); - } - - let trackWords = setting.trackWords || Store.get("trackWords"); - if (trackWords) - TrackingStream.start({track: trackWords}); - }); + liberator.registerObserver('enter', startStreams); __context__.onUnload = function() { Store.set("history", history); -- cgit v1.2.3