Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

【Javascript】LINEオリジナル絵文字をランダムにreturnする関数

More than 1 year has passed since last update.

node.jsでLINE botを作ったときに使ったもの。もっといいやり方あると思うんだけど、自分用にはこのぐらいで十分なので、メモ。実際はコニーとムーンだけを使用。

LINEオリジナル絵文字

LINE Messaging APIでメッセージ送信する際に、LINEオリジナル絵文字を使うことが出来ます。約170種類ほどあります。これを使うと、ぐっとやりとりがLINEっぽくなるのです。
emoji-list(1)_page-0001.jpg
emoji-list(1)_page-0002.jpg
引用 - LINE公式ドキュメント 絵文字リスト(※pdf)

ランダムで返す

コードが特定の範囲でキレイに揃っていればいいのですが、結構歯抜けもあるので力技で。美しくない。

line_emoji.js
function line_emoji_rondom() {
    var em = Math.floor(Math.random() * 175);

    switch (em) {

        //ムーン
        case 0:
            return '\uDBC0\uDC78';
        case 1:
            return '\uDBC0\uDC79';
        case 2:
            return '\uDBC0\uDC7A';
        case 3:
            return '\uDBC0\uDC7B';
        case 4:
            return '\uDBC0\uDC7C';
        case 5:
            return '\uDBC0\uDC7D';
        case 6:
            return '\uDBC0\uDC7E';
        case 7:
            return '\uDBC0\uDC8C';
        case 8:
            return '\uDBC0\uDC8D';
        case 9:
            return '\uDBC0\uDC8E';
        case 10:
            return '\uDBC0\uDC8F';
        case 11:
            return '\uDBC0\uDC90';
        case 12:
            return '\uDBC0\uDC91';
        case 13:
            return '\uDBC0\uDC92';
        case 14:
            return '\uDBC0\uDC93';
        case 15:
            return '\uDBC0\uDC94';
        case 16:
            return '\uDBC0\uDC95';

        //コニー
        case 17:
            return '\uDBC0\uDC7F';
        case 18:
            return '\uDBC0\uDC80';
        case 19:
            return '\uDBC0\uDC81';
        case 20:
            return '\uDBC0\uDC82';
        case 21:
            return '\uDBC0\uDC83';
        case 22:
            return '\uDBC0\uDC96';
        case 23:
            return '\uDBC0\uDC97';
        case 24:
            return '\uDBC0\uDC98';
        case 25:
            return '\uDBC0\uDC99';
        case 26:
            return '\uDBC0\uDC9A';
        case 27:
            return '\uDBC0\uDC9B';
        case 28:
            return '\uDBC0\uDC9C';
        case 29:
            return '\uDBC0\uDC9D';
        case 30:
            return '\uDBC0\uDC9E';

        //ブラウン
        case 31:
            return '\uDBC0\uDC84';
        case 32:
            return '\uDBC0\uDC85';
        case 33:
            return '\uDBC0\uDC86';

        //ジェームズ
        case 34:
            return '\uDBC0\uDC87';
        case 35:
            return '\uDBC0\uDC88';
        case 36:
            return '\uDBC0\uDC89';
        case 37:
            return '\uDBC0\uDC8A';
        case 38:
            return '\uDBC0\uDC8B';
        case 39:
            return '\uDBC0\uDC9F';

        //顔
        case 40:
            return '\uDBC0\uDC01';
        case 41:
            return '\uDBC0\uDC02';
        case 42:
            return '\uDBC0\uDC03';
        case 43:
            return '\uDBC0\uDC04';
        case 44:
            return '\uDBC0\uDC05';
        case 45:
            return '\uDBC0\uDC06';
        case 46:
            return '\uDBC0\uDC07';
        case 47:
            return '\uDBC0\uDC08';
        case 48:
            return '\uDBC0\uDC09';
        case 49:
            return '\uDBC0\uDC0A';
        case 50:
            return '\uDBC0\uDC0B';
        case 51:
            return '\uDBC0\uDC0C';
        case 52:
            return '\uDBC0\uDC0D';
        case 53:
            return '\uDBC0\uDC0E';
        case 54:
            return '\uDBC0\uDC0F';
        case 55:
            return '\uDBC0\uDC10';
        case 56:
            return '\uDBC0\uDC11';
        case 57:
            return '\uDBC0\uDC12';
        case 58:
            return '\uDBC0\uDC13';
        case 59:
            return '\uDBC0\uDC14';
        case 60:
            return '\uDBC0\uDC15';
        case 61:
            return '\uDBC0\uDC16';
        case 62:
            return '\uDBC0\uDC17';
        case 63:
            return '\uDBC0\uDC18';
        case 64:
            return '\uDBC0\uDC19';
        case 65:
            return '\uDBC0\uDC1A';
        case 66:
            return '\uDBC0\uDC1B';
        case 67:
            return '\uDBC0\uDC1C';
        case 68:
            return '\uDBC0\uDC1D';
        case 69:
            return '\uDBC0\uDC1E';
        case 70:
            return '\uDBC0\uDC1F';
        case 71:
            return '\uDBC0\uDC20';
        case 72:
            return '\uDBC0\uDC21';
        case 73:
            return '\uDBC0\uDC22';
        case 74:
            return '\uDBC0\uDC23';

        //その他
        case 75:
            return '\uDBC0\uDC5D';
        case 76:
            return '\uDBC0\uDC5F';
        case 77:
            return '\uDBC0\uDC5E';
        case 78:
            return '\uDBC0\uDCA0';
        case 79:
            return '\uDBC0\uDCA1';
        case 80:
            return '\uDBC0\uDC24';
        case 81:
            return '\uDBC0\uDCA2';
        case 82:
            return '\uDBC0\uDCA3';
        case 83:
            return '\uDBC0\uDCA4';
        case 84:
            return '\uDBC0\uDCA5';
        case 85:
            return '\uDBC0\uDCA6';
        case 86:
            return '\uDBC0\uDCA7';
        case 87:
            return '\uDBC0\uDC26';
        case 88:
            return '\uDBC0\uDC27';
        case 89:
            return '\uDBC0\uDC29';
        case 90:
            return '\uDBC0\uDC2A';
        case 91:
            return '\uDBC0\uDC2B';
        case 92:
            return '\uDBC0\uDC2C';
        case 93:
            return '\uDBC0\uDC2D';
        case 94:
            return '\uDBC0\uDC2E';
        case 95:
            return '\uDBC0\uDC2F';
        case 96:
            return '\uDBC0\uDC3A';
        case 97:
            return '\uDBC0\uDCA8';
        case 98:
            return '\uDBC0\uDCA9';
        case 99:
            return '\uDBC0\uDCAA';
        case 100:
            return '\uDBC0\uDCAB';
        case 101:
            return '\uDBC0\uDCAC';
        case 102:
            return '\uDBC0\uDC33';
        case 103:
            return '\uDBC0\uDCAD';
        case 104:
            return '\uDBC0\uDC30';
        case 105:
            return '\uDBC0\uDC31';
        case 106:
            return '\uDBC0\uDC32';
        case 107:
            return '\uDBC0\uDCAE';
        case 108:
            return '\uDBC0\uDC35';
        case 109:
            return '\uDBC0\uDC36';
        case 110:
            return '\uDBC0\uDC39';
        case 111:
            return '\uDBC0\uDC37';
        case 112:
            return '\uDBC0\uDC38';
        case 113:
            return '\uDBC0\uDCAF';
        case 114:
            return '\uDBC0\uDCB0';
        case 115:
            return '\uDBC0\uDCB1';
        case 116:
            return '\uDBC0\uDCB2';
        case 117:
            return '\uDBC0\uDCB3';
        case 118:
            return '\uDBC0\uDC3B';
        case 119:
            return '\uDBC0\uDC3C';
        case 120:
            return '\uDBC0\uDC3D';
        case 121:
            return '\uDBC0\uDCB4';
        case 122:
            return '\uDBC0\uDC40';
        case 123:
            return '\uDBC0\uDC41';
        case 124:
            return '\uDBC0\uDC42';
        case 125:
            return '\uDBC0\uDC43';
        case 126:
            return '\uDBC0\uDC44';
        case 127:
            return '\uDBC0\uDC45';
        case 128:
            return '\uDBC0\uDCB5';
        case 129:
            return '\uDBC0\uDC47';
        case 130:
            return '\uDBC0\uDC49';
        case 131:
            return '\uDBC0\uDC4A';
        case 132:
            return '\uDBC0\uDC4B';
        case 133:
            return '\uDBC0\uDC4C';
        case 134:
            return '\uDBC0\uDC4D';
        case 135:
            return '\uDBC0\uDC4E';
        case 136:
            return '\uDBC0\uDC4F';
        case 137:
            return '\uDBC0\uDC50';
        case 138:
            return '\uDBC0\uDC51';
        case 139:
            return '\uDBC0\uDC53';
        case 140:
            return '\uDBC0\uDC54';
        case 141:
            return '\uDBC0\uDC55';
        case 142:
            return '\uDBC0\uDC56';
        case 143:
            return '\uDBC0\uDCB6';
        case 144:
            return '\uDBC0\uDC57';
        case 145:
            return '\uDBC0\uDC58';
        case 146:
            return '\uDBC0\uDC59';
        case 147:
            return '\uDBC0\uDCB7';
        case 148:
            return '\uDBC0\uDC5B';
        case 149:
            return '\uDBC0\uDC5C';
        case 150:
            return '\uDBC0\uDC60';
        case 151:
            return '\uDBC0\uDC61';
        case 152:
            return '\uDBC0\uDC62';
        case 153:
            return '\uDBC0\uDCB8';
        case 154:
            return '\uDBC0\uDCB9';
        case 155:
            return '\uDBC0\uDC64';
        case 156:
            return '\uDBC0\uDC65';
        case 157:
            return '\uDBC0\uDC66';
        case 158:
            return '\uDBC0\uDC67';
        case 159:
            return '\uDBC0\uDC68';
        case 160:
            return '\uDBC0\uDC69';
        case 161:
            return '\uDBC0\uDC6A';
        case 162:
            return '\uDBC0\uDC6B';
        case 163:
            return '\uDBC0\uDC6C';
        case 164:
            return '\uDBC0\uDC6D';
        case 165:
            return '\uDBC0\uDC6E';
        case 166:
            return '\uDBC0\uDC6F';
        case 167:
            return '\uDBC0\uDC70';
        case 168:
            return '\uDBC0\uDC71';
        case 169:
            return '\uDBC0\uDC72';
        case 170:
            return '\uDBC0\uDC73';
        case 171:
            return '\uDBC0\uDC74';
        case 172:
            return '\uDBC0\uDC75';
        case 173:
            return '\uDBC0\uDC76';
        case 174:
            return '\uDBC0\uDC77';
        default:
            break;
    }
}
Puerto
もっぱらexcelのセルを黄色くしたり、太字にしたりする仕事をしてます。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away