Answer the question
In order to leave comments, you need to log in
How to fix task(*args, **kwargs) TypeError: 'str' object is not callable?
When there is one more registered person and when the second person wants to register, an error appears.
After specifying the name, a crash occurs.
@bot.message_handler(content_types=['text'])
def reg(message):
conn = sqlite3.connect("database/RXDataBase.db")
cursor = conn.cursor()
cursor.execute(f"SELECT name, surname, patronymic, number FROM Profile WHERE user_id = {message.chat.id}")
if message.text == '/reg':
if cursor.fetchone() is None:
global user_id
global name
bot.send_message(message.from_user.id, 'Регистрация аккаунта.\nУкажите имя:')
user_id = message.from_user.id
bot.register_next_step_handler(message, name)
else:
bot.send_message(message.from_user.id, 'Такой аккаунт существует и активен!')
if message.text == '/log':
if cursor.fetchone() is None:
bot.send_message(message.from_user.id, 'Увы... Такого аккаунта нет!')
else:
inf_profil = get_inf_profil(name, surname, patronymic, number)
bot.send_message(message.from_user.id, f'Привет, {surname} {name}! \n\n\n{inf_profil}')
#Собираем данные для регистрации и БД
def name(message): #получаем имя
if message.text:
bot.send_message(message.from_user.id, 'Укажите фамилию:')
global name
name = message.text
bot.register_next_step_handler(message, surname)
def surname(message): #получаем фамилии
if message.text:
bot.send_message(message.from_user.id, 'Укажите отчество:')
global surname
surname = message.text
bot.register_next_step_handler(message, patronymic)
def patronymic(message): #получаем отчества
if message.text:
bot.send_message(message.from_user.id, 'Укажите номер телефона(Начиная с +7):')
global patronymic
patronymic = message.text
bot.register_next_step_handler(message, number)
def number(message):
if message.text:
bot.send_message(message.from_user.id, 'Регистрация окончено! Напиши /log')
global number
number = message.text
conn = sqlite3.connect("database/RXDataBase.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Profile (user_id, name, surname, patronymic, number) VALUES (?, ?, ?, ?, ?)", (user_id, name, surname, patronymic, number))
conn.commit()
Traceback (most recent call last):
File "c:\Users\Centu\Desktop\bot\RXBotSysteam.py", line 72, in
bot.polling(none_stop=True, interval=0)
File "C:\Users\Centu \AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 619, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\ Centu\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 678, in __threaded_polling
raise e
File "C:\Users\Centu\AppData\Local\Programs\Python\Python39 \lib\site-packages\telebot\__init__.py", line 641, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\Centu\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File "C:\Users\Centu\ AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
TypeError: 'str' object is not callable
from RXConfigBase import *
from RXSQLConfig import *
#from RXKeyboardConfig import *
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
#Начало, логиниться и регистрация
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.from_user.id, "Добро пожаловать!\n" f"♂️>> {message.chat.first_name}|{message.chat.last_name} <<♀️\n\n" "Входа в систему /log\n" "Регистрация /reg")
#регистрация
@bot.message_handler(content_types=['text'])
def reg(message):
conn = sqlite3.connect("database/RXDataBase.db")
cursor = conn.cursor()
cursor.execute(f"SELECT name, surname, patronymic, number FROM Profile WHERE user_id = {message.chat.id}")
if message.text == '/reg':
if cursor.fetchone() is None:
global user_id
global name
bot.send_message(message.from_user.id, 'Регистрация аккаунта.\nУкажите имя:')
user_id = message.from_user.id
bot.register_next_step_handler(message, name)
else:
bot.send_message(message.from_user.id, 'Такой аккаунт существует и активен!')
if message.text == '/log':
if cursor.fetchone() is None:
bot.send_message(message.from_user.id, 'Увы... Такого аккаунта нет!')
else:
inf_profil = get_inf_profil(name, surname, patronymic, number)
bot.send_message(message.from_user.id, f'Привет, {surname} {name}! \n\n\n{inf_profil}')
#Собираем данные для регистрации и БД
def name(message): #получаем имя
if message.text:
bot.send_message(message.from_user.id, 'Укажите фамилию:')
global name
name = message.text
bot.register_next_step_handler(message, surname)
def surname(message): #получаем фамилии
if message.text:
bot.send_message(message.from_user.id, 'Укажите отчество:')
global surname
surname = message.text
bot.register_next_step_handler(message, patronymic)
def patronymic(message): #получаем отчества
if message.text:
bot.send_message(message.from_user.id, 'Укажите номер телефона(Начиная с +7):')
global patronymic
patronymic = message.text
bot.register_next_step_handler(message, number)
def number(message):
if message.text:
bot.send_message(message.from_user.id, 'Регистрация окончено! Напиши /log')
global number
number = message.text
conn = sqlite3.connect("database/RXDataBase.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Profile (user_id, name, surname, patronymic, number) VALUES (?, ?, ?, ?, ?)", (user_id, name, surname, patronymic, number))
conn.commit()
if __name__ == '__main__':
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
def name(message): #получаем имя
global name
name = message.text
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question