From f58fecd630dfd8ca666159dc60f5304b5a2738af Mon Sep 17 00:00:00 2001
From: anekos
Date: Fri, 3 Dec 2010 06:00:38 +0900
Subject: Utils.parseSayArg を追加。プラグイン等用
---
twittperator.js | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/twittperator.js b/twittperator.js
index 6ec0f18..f14bebc 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.9.6
+ 1.10.0
2.3
2.4
teramako
@@ -1566,6 +1566,20 @@ let PLUGIN_INFO =
return result;
}, // }}}
+ parseSayArg: function(arg) { // {{{
+ let m = arg.match(/^(.*)@(\w{1,15})#(\d+)(.*)$/);
+ return m ? {
+ isReply: true,
+ prefix: m[1],
+ replyUser: m[2],
+ replyID: m[3],
+ postfix: m[4],
+ text: m[1] + '@' + m[2] + m[4]
+ } : {
+ isReply: false,
+ text: arg
+ };
+ }, // }}}
xmlhttpRequest: function(options) { // {{{
let xhr = new XMLHttpRequest();
xhr.open(options.method, options.url, true);
@@ -1636,25 +1650,24 @@ let PLUGIN_INFO =
}, // }}}
say: function(stat) { // {{{
let sendData = {};
- let prefix, replyUser, replyID, postfix;
- if (stat.match(/^(.*)@(\w{1,15})#(\d+)(.*)$/)) {
- [prefix, replyUser, replyID, postfix] = [RegExp.$1, RegExp.$2, RegExp.$3, RegExp.$4];
- if (stat.indexOf("RT @" + replyUser + "#" + replyID) == 0) {
+ let arg = Utils.parseSayArg(stat);
+ if (arg.isReply) {
+ if (stat.indexOf("RT @" + arg.replyUser + "#" + arg.replyID) == 0) {
Twittperator.withProtectedUserConfirmation(
- { screenName: replyUser, statusId: replyID },
+ { screenName: arg.replyUser, statusId: arg.replyID },
"retweet",
- function() Twitter.retweet(replyID)
+ function() Twitter.retweet(arg.replyID)
);
return;
}
- stat = prefix + "@" + replyUser + postfix;
- if (replyID && !prefix)
- sendData.in_reply_to_status_id = replyID;
+ stat = arg.text;
+ if (arg.replyID && !arg.prefix)
+ sendData.in_reply_to_status_id = arg.replyID;
}
Twittperator.withProtectedUserConfirmation(
- { screenName: replyUser, statusId: replyID },
+ { screenName: arg.replyUser, statusId: arg.replyID },
"reply",
- function() Twitter.say(stat, replyID)
+ function() Twitter.say(stat, arg.replyID)
);
}, // }}}
selectAndOpenLink: function(links) { // {{{
--
cgit v1.2.3