From 4f38d5a8606de71a0739bfba87a2ccf31cb806e6 Mon Sep 17 00:00:00 2001 From: anekos Date: Fri, 23 Sep 2011 19:46:26 +0900 Subject: :tw!lookupuser コマンド追加 --- twittperator.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index c21d719..a4199c3 100644 --- a/twittperator.js +++ b/twittperator.js @@ -28,7 +28,7 @@ let PLUGIN_INFO = Twittperator Twitter Client using OAuth and Streaming API OAuth/StreamingAPI対応Twitterクライアント - 1.15.0 + 1.16.0 2.3 teramako anekos @@ -1493,6 +1493,9 @@ let PLUGIN_INFO = } ); }, // }}} + lookupUser: function({screenNames, ids}, callback) { // {{{ + tw.jsonGet("users/lookup", { user_id: String(ids || []), screen_name: String(screenNames || []) }, callback); + }, // }}} say: function(status, inReplyToStatusId) { // {{{ let sendData = {status: status, source: "Twittperator"}; if (inReplyToStatusId) @@ -1649,6 +1652,58 @@ let PLUGIN_INFO = io.getRuntimeDirectories("plugin/twittperator").forEach(loadPluginFromDir(true)); io.getRuntimeDirectories("twittperator").forEach(loadPluginFromDir(false)); }, // }}} + lookupUser: function(users) { // {{{ + function showUsersInfo(json) { // {{{ + let xml = modules.template.map(json, function(user) { + return <> + + + + + + + {user.name} + + + + {user.location} - + id {user.id_str} - + {user.following ? '' : 'not'} following - + {user.friends_count}/{user.followers_count} ee/er - + {user.statuses_count} tweets - + {user.favourites_count} favs - + {user.listed_count} listed - + from {new Date(user.created_at).toLocaleString()} + + + + + {user.description} + + + ; + }); + liberator.echo( + <> + + {xml}
+ + ); + } // }}} + + let ids = [], screenNames = []; + for (let [, v] in Iterator(users)) + (/^\d+$/.test(v) ? ids : screenNames).push(v); + Twitter.lookupUser({ids: ids, screenNames: screenNames}, function(json) { + showUsersInfo(json); + }); + }, // }}} onFriends: function(msg) { // {{{ __context__.Friends = friends = msg.friends; }, // }}} @@ -2105,6 +2160,15 @@ let PLUGIN_INFO = timelineCompleter: true, completer: Completers.rawid(function(st) st.id) }), + SubCommand({ + command: ["lookupuser"], + description: "Lookup users", + action: function(arg) { + Twittperator.lookupUser(arg.split(/\s+/)); + }, + timelineCompleter: true, + completer: Completers.screenName() + }), SubCommand({ command: ["track"], description: "Track the specified words.", -- cgit v1.2.3