Answer the question
In order to leave comments, you need to log in
Dividing a message into parts?
I want to make a change nickname command, but I don't know how to separate the change nickname command from the new nickname? I only know message.text.split()[]. telebot. example:
Answer the question
In order to leave comments, you need to log in
So through your skills and execute
For example, the user posted /change_nick old_nick new_nick
def some_name(message):
words = message.text.split()
words.remove('/change_nick')
# Соединяемся с базой но для простоты примера давайте представим что сохраняли это в словарик
if nick_names[message.from_user.id] == words[0]:
nick_names[message.from_user.id] = words[-1] # nick_names - хэш-таблица в которую мы сохраняли никнеймы в формате {id пользователя:его ник}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question