aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw
blob: dacaa7312e2bcc713e13184210343b8ac4eb6e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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: