Showing
1 changed file
with
5 additions
and
5 deletions
| ... | @@ -31,15 +31,15 @@ bot.onText(/\/echo (.+)/, (msg, match) => { | ... | @@ -31,15 +31,15 @@ bot.onText(/\/echo (.+)/, (msg, match) => { |
| 31 | bot.sendMessage(chatId, resp); | 31 | bot.sendMessage(chatId, resp); |
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | -// Listen for any kind of message. Translate if it's not a command. | 34 | +// [Any normal message which is not a command (not starting with '/')] |
| 35 | -bot.on('message', (msg) => { | 35 | +bot.onText(/(?!\/)(.+)/, (msg, match) => { |
| 36 | const chatId = msg.chat.id; | 36 | const chatId = msg.chat.id; |
| 37 | const chatType = msg.chat.type; | 37 | const chatType = msg.chat.type; |
| 38 | - const received_msg = msg.text; | 38 | + const received_msg = match[1]; |
| 39 | 39 | ||
| 40 | - // Ignore if input is a command or we are not on a private chat, | 40 | + // Ignore if we are not on a private chat, |
| 41 | // since direct translation is to be used only on private chats. | 41 | // since direct translation is to be used only on private chats. |
| 42 | - if (received_msg[0] == '/' || chatType != 'private') { | 42 | + if (chatType != 'private') { |
| 43 | return; | 43 | return; |
| 44 | } | 44 | } |
| 45 | 45 | ... | ... |
-
Please register or login to post a comment