aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator
diff options
context:
space:
mode:
Diffstat (limited to 'twittperator')
-rwxr-xr-xtwittperator/me.tw38
-rw-r--r--twittperator/pebble.tw37
-rw-r--r--twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw66
3 files changed, 141 insertions, 0 deletions
diff --git a/twittperator/me.tw b/twittperator/me.tw
new file mode 100755
index 0000000..e6dd41d
--- /dev/null
+++ b/twittperator/me.tw
@@ -0,0 +1,38 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_me = 1
+ *
+ */
+
+(function () {
+ const TW = liberator.plugins.twittperator;
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['me'],
+ description: 'reply to myself',
+ action: function(arg) {
+ setTimeout(
+ function () {
+ commandline.open(
+ '',
+ 'tw ' + arg + ' ',
+ modes.EX
+ );
+ },
+ 0
+ );
+ },
+ timelineComplete: true,
+ completer: TW.Completers.name_id(
+ function (s)
+ (s.user &&
+ s.user.screen_name == liberator.globalVariables.twittperator_screen_name)
+ ? s.id : false
+ )
+ })
+ );
+})();
+
+// vim: set et fdm=syntax ft=javascript sts=2 sw=2 ts=2 :
+
diff --git a/twittperator/pebble.tw b/twittperator/pebble.tw
new file mode 100644
index 0000000..1feb454
--- /dev/null
+++ b/twittperator/pebble.tw
@@ -0,0 +1,37 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_pebble = 1
+ * let g:twittperator_plugin_pebble_user_id = '<USER_ID>';
+ * let g:twittperator_plugin_pebble_user_token = '<USER_TOKEN>';
+ * let g:twittperator_screen_name = "<YOUR_SCREEN_NAME>"
+ */
+
+(function () {
+ let screenName = liberator.globalVariables.twittperator_screen_name;
+ let userId = liberator.globalVariables.twittperator_plugin_pebble_user_id;
+ let userToken = liberator.globalVariables.twittperator_plugin_pebble_user_token;
+
+ function notify (username) {
+ let body = [
+ 'userId=' + userId,
+ 'userToken=' + userToken,
+ 'title=Twitter',
+ 'body=' + encodeURIComponent('reply from ' + username),
+ 'type=notification'].join('&');
+
+ let xhr = new XMLHttpRequest();
+ xhr.open('POST', 'https://ofkorth.net/pebble/send', true, null, null);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ xhr.send(body);
+ }
+
+ plugins.twittperator.ChirpUserStream.addListener(
+ function onMsg (msg, raw) {
+ if (msg.text && msg.user && msg.in_reply_to_screen_name === screenName)
+ notify(msg.user.screen_name, msg.text);
+ }
+ );
+})();
+
+// vim: sw=2 ts=2 et fdm=marker ft=javascript:
diff --git a/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw b/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw
new file mode 100644
index 0000000..dacaa73
--- /dev/null
+++ b/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw
@@ -0,0 +1,66 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon = 1
+ * let g:twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon_template = '体温 %s'
+ */
+
+(function () {
+
+ let tmpl = liberator.globalVariables.twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon_template || '体温 %s (%S)';
+
+ let taionds = [
+ ['焼死体', 666],
+ ['鶏', 41.5],
+ ['豚', 39.0],
+ ['やぎ', 39.0],
+ ['ひつじ', 39.0],
+ ['うさぎ', 39.5],
+ ['牛', 38.5],
+ ['犬', 38.5],
+ ['猫', 38.1],
+ ['馬', 37.7],
+ ['ヒト', 36.0],
+ ['死体', 0],
+ ];
+ taionds.reverse();
+
+ function whatAmI (myon) {
+ let result = '石';
+ for ([name, taion] of taionds) {
+ if (taion <= myon)
+ result = name;
+ }
+ return result;
+ }
+
+ commands.addUserCommand(
+ ['taioooooooooonoooooooooooooooooooooooooooooon'],
+ 'Description',
+ function (args) {
+ plugins.twittperator.Twittperator.say(
+ tmpl.replace(/%s/g, args.literalArg).replace(/%S/g, function (it) {
+ return whatAmI(parseFloat(args.literalArg.match(/\d{1,2}(\.\d)?/).toString()))
+ })
+ );
+ },
+ {
+ literal: 0,
+ completer: function (context, args) {
+ context.title = ['温度', 'description'];
+
+ let cs = [];
+ for (let i = 30.0; i < 50.0; i += 0.1) {
+ cs.push([i.toString().replace(/\.\d*$/, function (it) it.substring(0, 2)), whatAmI(i)]);
+ }
+ liberator.__cs = cs;
+
+ context.filters = [CompletionContext.Filter.textDescription];
+ context.completions = cs;
+ },
+ },
+ true // replace
+ );
+
+})();
+
+// vim: sw=2 ts=2 et fdm=marker ft=javascript: