Как-то так:
def password_generator(message):
global chars_all
global chars_number
global chars_letters
chars_all = '1234567890qwertyuiopasdfghjklzxcvbnm!@#$%^&*()_+=-/?.,|<>/'
chars_number = '1234567890'
chars_letters = 'qwertyuiopasdfghjklzxcvbnm'
mes='1 - all chars\n2 - only numbers\n3 - only letters'
bot.send_message(message.from_user.id, text=mes)
type_of_choice=bot.send_message(message.from_user.id, "Type:")
bot.register_next_step_handler(type_of_choice, choosing_type)
def choosing_type(message):
#Получаем Type пароля
global type_of_choice
type_of_choice=int(message.text)
num=bot.send_message(message.from_user.id, "Quantity of passwords:")
bot.register_next_step_handler(num, choosing_num)
def choosing_num(message):
#Получаем количество паролей
global num
num = int(message.text)
length=bot.send_message(message.from_user.id, "Length of password:")
bot.register_next_step_handler(length, choosing_length)
def choosing_length(message):
#Получаем длину пароля
global length
length=int(message.text)
password = ''
for i in range (num):
if type_of_choice == 1:
for j in range(length):
password += random.choice(chars_all)
if type_of_choice == 2:
for j in range(length):
password += random.choice(chars_number)
if type_of_choice == 3:
for j in range(length):
password += random.choice(chars_letters)
password=password+'\n'
#Получаем все пароли
return bot.send_message(message.from_user.id, password)
Ваша проверка на команду теперь выглядет вот так:
@bot.message_handler(commands = ['start', 'help', 'info', 'time', 'password'])
def get_text_messages(message):
if message.text == "/password":
#Вызываем начало функции, где спрашивается Type
password_generator(message)