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) => { ...@@ -272,10 +272,16 @@ bot.onText(/^\/(t|translate)($| ((.|\n)+))/, (msg, match) => {
272 bot.on('photo', (msg) => { 272 bot.on('photo', (msg) => {
273 const user = msg.from; 273 const user = msg.from;
274 const chatId = msg.chat.id; 274 const chatId = msg.chat.id;
275 + const chatType = msg.chat.type;
275 const photo = msg.photo[msg.photo.length - 1]; // Choose largest image possible 276 const photo = msg.photo[msg.photo.length - 1]; // Choose largest image possible
276 const photoId = photo.file_id; 277 const photoId = photo.file_id;
277 const caption = msg.caption; 278 const caption = msg.caption;
278 279
280 + // Ignore if we are not on a private chat
281 + if (chatType != 'private') {
282 + return;
283 + }
284 +
279 // Detect text from given image 285 // Detect text from given image
280 detectText(photoId).then(function (text) { 286 detectText(photoId).then(function (text) {
281 // Translate the result 287 // Translate the result
......