check.js 28.6 KB
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
var Info = require('./Info');
var ids = require('./all_ids')
const request = require('request');
const fs = require('fs');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
var { google } = require('googleapis');
var service = google.youtube('v3');

//세팅,설정값
var setting_userId = []; //유저아이디보관
var setting_Thumbnail = []; // 1:썸네일 출력(기본값) / 0:미출력
var setting_SendAmount = []; // 보낼 양 (1이상, 4이하의 정수) (기본값:1)
var setting_SendAddress = []; // 1:유튜브 주소 출력(기본값) / 0:미출력

function SEND(replyToken,title,url2,thumbnail,SendAmount,sendaddress) //검색해서 나온 내용 전송하는 함수
{
    
    sendMessage = "";
    var temp_title = [], temp_url = [], temp_url2 = [], temp_thumpnail = [];
    for (var i = 0; i < SendAmount; i++) {

        temp_title[i] = title[i];

        temp_url2[i] = url2[i];
        if (sendaddress) //주소 전송 활성화
            temp_url[i] = 'https://www.youtube.com/watch?v=' + (temp_url2[i].replace(/\"/gi, ""));
        else 
            temp_url[i] = "";
        sendMessage += temp_title[i] + "\n" +
            temp_url[i] + "\n" + "\n";
    }

    console.log(sendMessage);
    if (thumbnail) //썸네일을 활성화시켰을 경우, 맨 첫번째 작품 리스트 썸네일만 보여줌.
        request.post(
            {
                url: TARGET_URL,
                headers:
                {
                    'Authorization': `Bearer ${Info.TOKEN}`
                },
                json:
                {
                    "replyToken": replyToken,
                    "messages":
                    [
                        {
                            "type": "image",
                            "originalContentUrl": "https://img.youtube.com/vi/" + url2[0] + "/hqdefault.jpg",
                            "previewImageUrl": "https://img.youtube.com/vi/" + url2[0] + "/hqdefault.jpg"
                        },
                        {
                            "type": "text",
                            "text": sendMessage
                        }
                    ]
                }
            }
        );
    else //썸네일 비활성화
        request.post(
            {
                url: TARGET_URL,
                headers:
                {
                    'Authorization': `Bearer ${Info.TOKEN}`
                },
                json:
                {
                    "replyToken": replyToken,
                    "messages":
                    [
                        {
                            "type": "text",
                            "text": sendMessage
                        }
                    ]
                }
            }
        );
}

function shuffle(array) { //플레이리스트에서 랜덤으로 골라서 출력할 수 있도록 shuffle 함수를 추가함
    for (let i = array.length - 1; i > 0; i--) {
        let j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

function SEND_LIST(replyToken,response,choice,thumbnail,SendAmount,sendaddress)//플레이리스트에서 나온 내용 전송하는 함수
{
    var random_order=[0,1,2,3,4,5,6,7,8,9];
    shuffle(random_order)

    sendMessage = "";
    var temp_title = [], temp_url = [], temp_url2 = [], temp_thumpnail = [];
    for (var i = 0; i < SendAmount; i++) {

        temp_title[i] = JSON.stringify(response.data.items[random_order[i]].snippet.title).replace(/\"/gi, "");

        temp_url2[i] = JSON.stringify(response.data.items[random_order[i]].snippet.resourceId.videoId);
        if (sendaddress) //주소 활성화
            temp_url[i] = 'https://www.youtube.com/watch?v=' + (temp_url2[i].replace(/\"/gi, ""));
        else 
            temp_url[i] = "";
        sendMessage += temp_title[i] + "\n" +
            temp_url[i] + "\n" + "\n";
    }


    console.log(sendMessage);
    if (thumbnail) //썸네일을 활성화시켰을 경우, 맨 첫번째 작품 리스트 썸네일만 보여줌.
        request.post(
            {
                url: TARGET_URL,
                headers:
                {
                    'Authorization': `Bearer ${Info.TOKEN}`
                },
                json:
                {
                    "replyToken": replyToken,
                    "messages":
                    [
                        {
                            "type": "image",
                            "originalContentUrl": "https://img.youtube.com/vi/" + (temp_url2[0].replace(/\"/gi, "")) + "/hqdefault.jpg",
                            "previewImageUrl": "https://img.youtube.com/vi/" + (temp_url2[0].replace(/\"/gi, "")) + "/hqdefault.jpg"
                        },
                        {
                            "type": "text",
                            "text": sendMessage
                        }
                    ]
                }
            }
        );
    else //썸네일 비활성화
        request.post(
            {
                url: TARGET_URL,
                headers:
                {
                    'Authorization': `Bearer ${Info.TOKEN}`
                },
                json:
                {
                    "replyToken": replyToken,
                    "messages":
                    [
                        {
                            "type": "text",
                            "text": sendMessage
                        }
                    ]
                }
            }
        );
}

function HELP(replyToken,sendMessage) //도움말 함수
{
    console.log(sendMessage);
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": sendMessage
                    }
                ]
            }
        }
    );
}

function SETTINGS(replyToken) //설정 함수
{
    console.log("설정 메뉴 진입");
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "template",
                        "altText": "설정메뉴입니다.",
                        "template": {
                            "type": "buttons",
                            "title": "설정",
                            "text": "설정하려는 항목을 골라주세요.",
                            "actions": [
                                {
                                  "type": "postback",
                                  "label": "썸네일 전송 여부 변경",
                                  "data": "썸네일"
                                },
                                {
                                  "type": "postback",
                                  "label": "추천 음악 개수 조정",
                                  "data": "개수"
                                },
                                {
                                  "type": "postback",
                                  "label": "유튜브 주소 전송 여부 변경",
                                  "data": "주소"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    );
}

function sendplaylist(replyToken, userId, choose)
{
    var choice=ids.all_ids[choose];
    service.playlistItems.list(
        {
        key: Info.YoutubeKey,
        part: 'snippet',
        fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
        maxResults: 10,
        playlistId: choice
        }, function (err, response){
            if (err) {
                console.log('The API returned an error: ', err);
                return;
            }
            var video = response.data.items;
            if (video.length == 0) 
                console.log('검색된 동영상이 없습니다.');
            else
                SEND_LIST(replyToken,response,choice,setting_Thumbnail[setting_userId.indexOf(userId)],setting_SendAmount[setting_userId.indexOf(userId)],setting_SendAddress[setting_userId.indexOf(userId)]);
        }
    )
    
}


function PLAYLIST(replyToken) //플레이리스트 함수
{
    console.log("플레이리스트 선택창 진입");
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "template",
                        "altText": "플레이리스트 선택창 입니다.",
                        "template": {
                            "type": "buttons",
                            "title": "분야",
                            "text": "원하시는 분야를 골라주세요.",
                            "actions": [
                                {
                                  "type": "postback",
                                  "label": "장르",
                                  "data": "genre"
                                },
                                {
                                  "type": "postback",
                                  "label": "무드",
                                  "data": "mood"
                                },
                                {
                                  "type": "postback",
                                  "label": "가수",
                                  "data": "singer"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    );
}

exports.genre = function (replyToken)
{
    console.log("플레이리스트-장르");
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "template",
                        "altText": "장르 선택창 입니다.",
                        "template": {
                            "type": "buttons",
                            "title": "장르",
                            "text": "원하시는 장르를 골라주세요.",
                            "actions": [
                                {
                                  "type": "postback",
                                  "label": "힙합",
                                  "data": "hiphop"
                                },
                                {
                                  "type": "postback",
                                  "label": "피아노",
                                  "data": "piano"
                                },
                                {
                                  "type": "postback",
                                  "label": "팝",
                                  "data": "pop"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    );
}

exports.hiphop = function(replyToken,userId)
{
    console.log('플레이리스트-장르-힙합');
    sendplaylist(replyToken, userId, 101);
}

exports.piano = function(replyToken,userId)
{
    console.log('플레이리스트-장르-피아노');
    sendplaylist(replyToken, userId, 102);
}

exports.pop = function(replyToken,userId)
{
    console.log('플레이리스트-장르-팝');
    sendplaylist(replyToken, userId, 103);
}

exports.mood = function (replyToken)
{
    console.log("플레이리스트-무드");
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "template",
                        "altText": "무드 선택창 입니다.",
                        "template": {
                            "type": "buttons",
                            "title": "무드",
                            "text": "원하시는 무드를 골라주세요.",
                            "actions": [
                                {
                                  "type": "postback",
                                  "label": "신남",
                                  "data": "exciting"
                                },
                                {
                                  "type": "postback",
                                  "label": "슬픔",
                                  "data": "sad"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    );
}

exports.exciting = function(replyToken,userId)
{
    console.log('플레이리스트-무드-신남');
    sendplaylist(replyToken, userId, 201);
}

exports.sad = function(replyToken,userId)
{
    console.log('플레이리스트-무드-슬픔');
    sendplaylist(replyToken, userId, 202);
}

exports.singer = function (replyToken)
{
    console.log("플레이리스트-가수");
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "template",
                        "altText": "가수 선택창 입니다.",
                        "template": {
                            "type": "buttons",
                            "title": "가수",
                            "text": "원하시는 가수를 골라주세요.",
                            "actions": [
                                {
                                  "type": "postback",
                                  "label": "블랙핑크",
                                  "data": "blackpink"
                                },
                                {
                                  "type": "postback",
                                  "label": "아이유",
                                  "data": "iu"
                                }
                                ,
                                {
                                  "type": "postback",
                                  "label": "레드벨벳",
                                  "data": "redvelvet"
                                }
                                ,
                                {
                                  "type": "postback",
                                  "label": "트와이스",
                                  "data": "twice"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    );
}

exports.blackpink = function(replyToken,userId)
{
    console.log('플레이리스트-가수-블랙핑크');
    sendplaylist(replyToken, userId, 301);
}

exports.iu = function(replyToken,userId)
{
    console.log('플레이리스트-가수-아이유');
    sendplaylist(replyToken, userId, 302);
}

exports.redvelvet = function(replyToken,userId)
{
    console.log('플레이리스트-가수-레드벨벳');
    sendplaylist(replyToken, userId, 303);
}

exports.twice = function(replyToken,userId)
{
    console.log('플레이리스트-가수-트와이스');
    sendplaylist(replyToken, userId, 304);
}


exports.thumbnail_settings = function (replyToken)
{
    
    console.log('썸네일 전송 설정');
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                    [
                        {
                            "type": "template",
                            "altText": "설정메뉴입니다.",
                            "template": {
                                "type": "buttons",
                                "title": "썸네일 전송 여부 변경",
                                "text": "아래 항목을 골라주세요.",
                                "actions": [
                                    {
                                        "type": "postback",
                                        "label": "썸네일 전송 O",
                                        "data": "enablethumbnail"
                                    },
                                    {
                                        "type": "postback",
                                        "label": "썸네일 전송 X",
                                        "data": "unablethumbnail"
                                    },
                                ]
                            }
                        }
                    ]
            }
        }

    );
}

exports.enablethumbnail = function(replyToken,userId)
{
    console.log('썸네일 활성화 됨.');
    setting_Thumbnail[setting_userId.indexOf(userId)]=1;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 썸네일이 전송됩니다!"
                    }
                ]
            }
        }
    );
}
exports.unablethumbnail = function(replyToken,userId)
{
    console.log('썸네일 비활성화 됨.');
    setting_Thumbnail[setting_userId.indexOf(userId)]=0;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 썸네일이 전송되지 않습니다!"
                    }
                ]
            }
        }
    );
}







exports.amount_settings = function (replyToken, userId)
{
    console.log('출력량 설정');
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                    [
                        {
                            "type": "template",
                            "altText": "설정메뉴입니다.",
                            "template": {
                                "type": "buttons",
                                "title": "추천 음악 개수 조정",
                                "text": "원하는 추천 개수를 골라주세요.",
                                "actions": [
                                    {
                                        "type": "postback",
                                        "label": "1개",
                                        "data": "amount1"
                                    },
                                    {
                                        "type": "postback",
                                        "label": "2개",
                                        "data": "amount2"
                                    },
                                    {
                                        "type": "postback",
                                        "label": "3개",
                                        "data": "amount3"
                                    },
                                    {
                                        "type": "postback",
                                        "label": "4개",
                                        "data": "amount4"
                                    }
                                ]
                            }
                        }
                    ]
            }
        }

    );
}

exports.amount1 = function(replyToken,userId)
{
    console.log('한 번에 1개씩');
    setting_SendAmount[setting_userId.indexOf(userId)]=1;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 한 번에 한 개씩 추천합니다!"
                    }
                ]
            }
        }
    );
}

exports.amount2 = function(replyToken,userId)
{
    console.log('한 번에 2개씩');
    setting_SendAmount[setting_userId.indexOf(userId)]=2;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 한 번에 두 개씩 추천합니다!"
                    }
                ]
            }
        }
    );
}

exports.amount3 = function(replyToken,userId)
{
    console.log('한 번에 3개씩');
    setting_SendAmount[setting_userId.indexOf(userId)]=3;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 한 번에 세 개씩 추천합니다!"
                    }
                ]
            }
        }
    );
}

exports.amount4 = function(replyToken,userId)
{
    console.log('한 번에 4개씩');
    setting_SendAmount[setting_userId.indexOf(userId)]=4;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 한 번에 네 개씩 추천합니다!"
                    }
                ]
            }
        }
    );
}




exports.address_settings = function (replyToken)
{
    console.log('유튜브 주소 전송 설정');
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                    [
                        {
                            "type": "template",
                            "altText": "설정메뉴입니다.",
                            "template": {
                                "type": "buttons",
                                "title": "유튜브 주소 전송 여부 변경",
                                "text": "아래 항목을 골라주세요.",
                                "actions": [
                                    {
                                        "type": "postback",
                                        "label": "유튜브 주소 전송 O",
                                        "data": "enableaddress"
                                    },
                                    {
                                        "type": "postback",
                                        "label": "유튜브 주소 전송 X",
                                        "data": "unableaddress"
                                    },
                                ]
                            }
                        }
                    ]
            }
        }

    );
}

exports.enableaddress = function(replyToken,userId)
{
    console.log('주소 활성화 됨.');
    setting_SendAddress[setting_userId.indexOf(userId)]=1;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 유튜브 주소가 전송됩니다!"
                    }
                ]
            }
        }
    );
}
exports.unableaddress = function(replyToken,userId)
{
    console.log('주소 비활성화 됨.');
    setting_SendAddress[setting_userId.indexOf(userId)]=0;
    request.post(
        {
            url: TARGET_URL,
            headers:
            {
                'Authorization': `Bearer ${Info.TOKEN}`
            },
            json:
            {
                "replyToken": replyToken,
                "messages":
                [
                    {
                        "type": "text",
                        "text": "이제 유튜브 주소가 전송되지 않습니다!"
                    }
                ]
            }
        }
    );
}

exports.check = function (message, replyToken, userId) {
    if (setting_userId.indexOf(userId)==-1) // 새로운 사용자가 이용할때, 설정 초기값 세팅
    {
        setting_userId.push(userId);
        setting_Thumbnail.push(1);
        setting_SendAmount.push(1);
        setting_SendAddress.push(1);
        console.log("알림: 새로운 사용자가 발견됨");
    }
    
    var choice;
    var choose;

    switch (message) {
        case "플레이리스트":
            PLAYLIST(replyToken);
            break;
        case "도움말":
            sendMessage = "- 기본적으로 찾고 싶은 음악을 입력하여 보내면 적절한 음악 영상을 찾아 추천해드립니다."
                    +"\n"+"예시) 소녀시대 노래"
                    +"\n"+"- '플레이리스트'를 입력하면 분류에 따라 엄선한 음악을 추천드립니다!"
                    +"\n"+"- '설정'을 입력하면 썸네일 출력 여부, 추천 음악 개수(1~4), 유튜브 주소 전송 여부를 설정하실 수 있습니다."
                    +"\n"+"- 이 도움말을 다시 보고 싶으시다면 '도움말'을 입력하시면 됩니다! 음악과 함께 좋은 하루 보내세요.";
            HELP(replyToken,sendMessage);
            break;
        case "설정":
            SETTINGS(replyToken);
            break;
        default: //일반 검색
            var optionParams={
                q:message,
                part:"snippet",
                key:Info.YoutubeKey,
                maxResults:10
             };
            optionParams.q=encodeURI(optionParams.q);
            var url="https://www.googleapis.com/youtube/v3/search?";
            for(var option in optionParams){
                url+=option+"="+optionParams[option]+"&";
            }
            
            //url의마지막에 붙어있는 & 정리
            url=url.substr(0, url.length-1);
            
            request(url, function(err, res, body){
                var title=[]
                var url2=[]
                var data=JSON.parse(body).items;
                for(var content in data)
                {
                    title.push(data[content].snippet.title);
                    url2.push(data[content].id.videoId);
                }
                if (title.length==0)
                    console.log('검색된 동영상이 없습니다.');
                else
                    SEND(replyToken,title,url2,setting_Thumbnail[setting_userId.indexOf(userId)],setting_SendAmount[setting_userId.indexOf(userId)],setting_SendAddress[setting_userId.indexOf(userId)]);
            });
    }
}