def listener(messages):
for m in messages:
if m.from_user.id not in allowed:
bot.send_message(m.chat.id, 'Ты кто такой??? Давай, до свидания!')
return
if m.content_type == 'text':
req = m.text
req = req.split(' ')
cmd = req[0][1:] # cut /
try:
cmd = commands[cmd]
except KeyError:
bot.send_message(m.chat.id, 'Ничё не понял...')
return
req = req[1:]
p = os.popen('%s %s' % (cmd, " ".join(req)), 'r')
out = p.read()
bot.send_message(m.chat.id, out)