Ga Min Cha

Upload transmessage.js

1 +var express = require('express');
2 +const request = require('request');
3 +const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
4 +const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU='
5 +const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
6 +const PAPAGO_ID = 'UZMyxEhDtcZQ4JNNeohy'
7 +const PAPAGO_SECRET = 'J2yR82NwYK'
8 +const fs = require('fs');
9 +const path = require('path');
10 +const HTTPS = require('https');
11 +const domain = "2018102191.osschatbot2022.tk"
12 +const sslport = 23023;
13 +const bodyParser = require('body-parser');
14 +
15 +var replyMsg = "players, seasons, standings, league, Son, Neymar";
16 +
17 +function transMsg(replyMsg){
18 + var language = "ko";
19 +
20 + request.post(
21 + {
22 + url: PAPAGO_URL,
23 + headers: {
24 + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
25 + 'X-Naver-Client-Id': `${PAPAGO_ID}`,
26 + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
27 + },
28 + body: 'source=en&target=' + language + '&text=' + replyMsg,
29 + json:true
30 + },(error, response, body) => {
31 + if(!error && response.statusCode == 200) {
32 + let transMessage = body.message.result.translatedText;
33 + console.log(transMessage);
34 + }
35 + });
36 + }
37 +
38 +transMsg(replyMsg);
...\ No newline at end of file ...\ No newline at end of file