0
0
0x70002018-08-24 20:19:00
Python
0x7000, 2018-08-24 20:19:00

How to implement Input to PyTelegramBotApi variable?

Here I write the function of switching to the directory.

import telebot
@bot.message_handler(commands=['cd'])
def cd(message):
  os.chdir()
  c = os.getcwd()
  bot.send_message(message.chat.id,c)

I can't figure out how to make /cd "/root/"
"/root/" be added to os.chdir when sending the command to the bot (here)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2018-08-24
@0x7000

Look at the message structure to correctly indicate the text itself.

root = message.message.split(' ')[1][1:-1] # /root/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question