kykint

Use direct translation only on private chats

Otherwise it would reply to every single message on e.g. group chats.
Showing 1 changed file with 4 additions and 2 deletions
...@@ -34,10 +34,12 @@ bot.onText(/\/echo (.+)/, (msg, match) => { ...@@ -34,10 +34,12 @@ bot.onText(/\/echo (.+)/, (msg, match) => {
34 // Listen for any kind of message. Translate if it's not a command. 34 // Listen for any kind of message. Translate if it's not a command.
35 bot.on('message', (msg) => { 35 bot.on('message', (msg) => {
36 const chatId = msg.chat.id; 36 const chatId = msg.chat.id;
37 + const chatType = msg.chat.type;
37 const received_msg = msg.text; 38 const received_msg = msg.text;
38 39
39 - // Ignore if input is a command 40 + // Ignore if input is a command or we are not on a private chat,
40 - if (received_msg[0] == '/') { 41 + // since direct translation is to be used only on private chats.
42 + if (received_msg[0] == '/' || chatType != 'private') {
41 return; 43 return;
42 } 44 }
43 45
......