kykint

Directly translate images only on private chats

Showing 1 changed file with 6 additions and 0 deletions
......@@ -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
......