@bot.message_handler(content_types = ['text'])
def entry_login(message):
user_id = str(message.from_user.id).replace('(', '').replace(')', '').replace(',', '')
user_login = message.text
print(user_id)
print(user_login)
data = {'user_id': user_id, 'user_login': user_login}
answer = bot.send_message(message.chat.id, 'Пароль:')
bot.register_next_step_handler(answer, entry_password, data)
@bot.message_handler(content_types = ['text'])
def entry_password(message, data):
data['user_password'] = message.text
print(data['user_password'])
answer = bot.send_message(message.chat.id, 'Группа:')
bot.register_next_step_handler(answer, entry_group, data)
@bot.message_handler(content_types = ['text'])
def entry_group(message, data):
data['user_group'] = message.text
print(data['user_group'])
answer = bot.send_message(message.chat.id, 'Входим...')
bot.register_next_step_handler(answer, database, data)
def database(message, data):
db = sqlite3.connect('database.db', check_same_thread = False)
cursor = db.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
user_id INT UNIQUE,
user_login VARCHAR(255),
user_password VARCHAR(255),
user_group INT
)''')
user_id = data['user_id']
user_login = data['user_login']
user_password = data['user_password']
user_group = data['user_group']
cursor.execute('INSERT INTO users (user_id, user_login, user_password, user_group) VALUES (?, ?, ?, ?)', (user_id, user_login, user_password, user_group,))
db.commit()
answer = bot.send_message(message.chat.id, 'Добавлено!')
bot.register_next_step_handler(answer, stop)