import TelegramBot from 'node-telegram-bot-api';
import config from './config'
import * as commandsHelper from './utils/commands';
import Translate from './commands/Translate';

const bot = new TelegramBot(config.apiKey, {polling: true});

bot.on('message', msg => {
  handleCommands(bot, msg);
});

function getParams(command, single = false) {

  // Return a single string
  if (single) {
    return command.split(' ').splice(1).join(' ');
  }

  return command.split(' ').splice(1);
}

function getCommand(command) {
  return command.replace('@TLBot', '').split(' ').shift().substr(1);
}

function handleCommands(bot, msg) {

  // It's not a command
  if (!msg.text || !msg.text.indexOf('/') === 0) {
    return false;
  }

  let rawCommand = msg.text;


  // Get command name
  let command = getCommand(rawCommand);

  // If the command is invalid and it's not in a group (fix multiple bots problem)
  if (!commandsHelper.getCommands(command) && msg.chat.id > 0) {
    bot.sendMessage(msg.chat.id, `Command ${command} not found!
Use /help command to get help about.`);
    return false;
  }

  let params = getParams(rawCommand, true);
  Translate[command]({userId: msg.chat.id, params: params}).then(response => {
    bot.sendMessage(msg.chat.id, response);
  });

}

@@ -848,14 +848,62 @@
 alid
- and i
+%0A  if (!commandsHelper.getCommands(command)) %7B%0A    //I
 t's 
@@ -949,54 +949,16 @@
 em)%0A
+  
   if (
-!commandsHelper.getCommands(command) && 
 msg.
@@ -968,24 +968,26 @@
 t.id %3E 0) %7B%0A
+  
     bot.send
@@ -1078,16 +1078,22 @@
 out.%60);%0A
+    %7D%0A
     retu

fix multiple bots in a group problem