transmessage.js
2.13 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
var express = require('express');
const request = require('request');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU='
const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const PAPAGO_ID = 'UZMyxEhDtcZQ4JNNeohy'
const PAPAGO_SECRET = 'J2yR82NwYK'
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "2018102191.osschatbot2022.tk"
const sslport = 23023;
const bodyParser = require('body-parser');
var sampleReplyMsg = "players, seasons, standings, league, Son, Neymar";
function transMsg(replyMsg){
var language = "ko";
request.post(
{
url: PAPAGO_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=en&target=' + language + '&text=' + replyMsg,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
let transMessage = body.message.result.translatedText;
console.log(transMessage);
}
});
}
var replyMsg = "선수, 시즌, 순위, 리그, 손흥민, 네이마르, 1등"
function transMsg_toEn(replyMsg){
var language = "en";
request.post(
{
url: PAPAGO_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=ko&target=' + language + '&text=' + replyMsg,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
let transMessage = body.message.result.translatedText;
console.log(transMessage);
}
});
}