Toggle navigation
Toggle navigation
This project
Loading...
Sign in
kykint
/
TELEGRAMBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
kykint
2019-05-30 15:06:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
122d46c16452cdcc0ee1ebaddbad48eaa357d35d
122d46c1
1 parent
cfe880d6
Support more languages
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
app.js
app.js
View file @
122d46c
...
...
@@ -63,17 +63,17 @@ bot.on('message', (msg) => {
var
result
=
{
type
:
'text'
,
text
:
''
};
// Check if detection was successful
console
.
log
(
detect_body
.
langCode
);
console
.
log
(
'Language detected: '
+
detect_body
.
langCode
);
// Translate using papago, only Korean and English are supported atm
if
(
detect_body
.
langCode
==
'ko'
||
detect_body
.
langCode
==
'en'
)
{
source
=
detect_body
.
langCode
==
'ko'
?
'ko'
:
'en'
;
// Translate using papago
// Target defaults to English for Korean source, or Korean for all other langs
if
(
detect_body
.
langCode
!=
'unk'
)
{
source
=
detect_body
.
langCode
;
target
=
source
==
'ko'
?
'en'
:
'ko'
;
// Papago translation options
var
translate_options
=
{
url
:
translate_api_url
,
// 한국어(source : ko), 영어(target: en), 카톡에서 받는 메시지(text)
form
:
{
'source'
:
source
,
// Translate from source
'target'
:
target
,
// to target
...
...
@@ -100,7 +100,7 @@ bot.on('message', (msg) => {
}
// Language not detected
else
{
result
.
text
=
'언어를 감지할 수 없습니다.
\n 번역 언어는 한글 또는 영어만 가능합니다.
'
;
result
.
text
=
'언어를 감지할 수 없습니다.'
;
bot
.
sendMessage
(
chatId
,
result
.
text
);
}
}
...
...
Please
register
or
login
to post a comment