Как сделать отлавливатель команд в telegram?

Мне нужно что бы человек написал боту(в телеграмме) сообщение $gen, и скрипт сгенерировал ему пароль и отправил, как сделать?

import telebot
import config
import os
import mcrcon
import string
from random import choice

bot = telebot.TeleBot(config.TOKEN)

@bot.message_handler(commands=['start'])
def welcome(message):
    bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЯ - <b>{1.first_name}</b>, бот созданный для создания пароля".format(message.from_user, bot.get_me()),
        parse_mode='html')

@bot.message_handler(content_types=['text'])
def lalala(message):
    bot.send_message(message.chat.id, "Не знаю команды либо вопроса, используй $gen".format(message.from_user, bot.get_me()),
        parse_mode='html')

def random_password():
    alphabet = string.ascii_letters + string.digits
    while True:
        password = ''.join(choice(alphabet) for i in range(8))
        if (any(symbol.islower() for symbol in password)
                and any(symbol.isupper() for symbol in password)
                and sum(symbol.isdigit() for symbol in password) >= 1):
            return password

@bot.message_handler(commands=['gen'])
def lalala(message):
    bot.send_message(message.chat.id, '{}'.format(random_password()))

bot.polling(none_stop=True)

Ответы (1 шт):

Автор решения: D. Violet
import string
from random import choice

def random_password():
    alphabet = string.ascii_letters + string.digits
    while True:
        password = ''.join(choice(alphabet) for i in range(8))
        if (any(symbol.islower() for symbol in password)
                and any(symbol.isupper() for symbol in password)
                and sum(symbol.isdigit() for symbol in password) >= 1):
            return password


@bot.message_handler(commands=['gen'])
def some(message):
    bot.send_message(message.chat.id, '{}'.format(random_password()))
→ Ссылка