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-06-06 03:36:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8916d40c0bd850515c5cd1005d8738b64aca45c9
8916d40c
1 parent
4bc74eaa
Directly translate images only on private chats
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
app.js
app.js
View file @
8916d40
...
...
@@ -272,10 +272,16 @@ bot.onText(/^\/(t|translate)($| ((.|\n)+))/, (msg, match) => {
bot
.
on
(
'photo'
,
(
msg
)
=>
{
const
user
=
msg
.
from
;
const
chatId
=
msg
.
chat
.
id
;
const
chatType
=
msg
.
chat
.
type
;
const
photo
=
msg
.
photo
[
msg
.
photo
.
length
-
1
];
// Choose largest image possible
const
photoId
=
photo
.
file_id
;
const
caption
=
msg
.
caption
;
// Ignore if we are not on a private chat
if
(
chatType
!=
'private'
)
{
return
;
}
// Detect text from given image
detectText
(
photoId
).
then
(
function
(
text
)
{
// Translate the result
...
...
Please
register
or
login
to post a comment