Answer the question
In order to leave comments, you need to log in
How to implement Caesar cipher in Telegram bot?
/del /del /del /del /del /del /del /del /del
Answer the question
In order to leave comments, you need to log in
def get_arg(arg):
return arg.split()[1:]
@bot.message_handler(commands = ['encrypt'])
def msg_encrypt(message):
arg = get_arg(message.text)
if len(arg) >= 2:
bot.reply_to(message,f"{encrypt(arg[0:-1], arg[-1])}")
else:
bot.reply_to(message,'Вы не указали параметры шифрования!\nПример: `/encrypt {Ваше сверх секретное сообщение} {ключ}`', parse_mode = 'Markdown')
And what about input()? This function only deals with input from the console.
Same with print(), it's purely console output.
The simplest way, if the bot has only this purpose and no other, is not to bathe with commands, but simply to respond to each incoming message in encrypted form. This will be a modification of a simple echo bot that you took as a basis. The message parameter is passed to you in the handler, deal with it.
Otherwise, you will need to parse the incoming message (tear off the command from the beginning), and encrypt it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question