Hello everyone, I just registered here today, I don't do programming very much, but I decided to make a bot, I did a video tutorial, but I get this error, I will give my characteristics below, I searched for information about the error on the Internet, but I didn't find an answer, I tried some ways, but it didn't work out . And yes, when I launch the bot through the terminal, they don't give me errors, but after I write to the bot or use the /start command, the terminal immediately gives an error. Please help me. If I somehow wrote a lot and the code could have been inserted in a different way, I'm sorry, this is the first time I use this site
Which version of pyTelegramBotAPI are you using?
pyTelegramBotAPI==4.10.0
Which version of python are you using?
python 3.11
Here is my code and from below there will be an error that appears:
def check(call):
status = ['creator', 'administrator', 'member']
for i in status:
if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status:
check2(call)
break
else:
bot.send_message(call.message.chat.id, "Подпишитесь на каналы !", reply_markup=start_markup())
def check2(call):
status = ['creator', 'administrator', 'member']
for i in status:
if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status:
check3(call)
break
else:
bot.send_message(call.message.chat.id, "Подпишитесь на каналы !", reply_markup=start_markup())
def check3(call):
status = ['creator', 'administrator', 'member']
for i in status:
if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status:
bot.send_message(call.message.chat.id, "Спасибо что подписались на каналы !")
break
else:
bot.send_message(call.message.chat.id, "Подпишитесь на каналы !", reply_markup=start_markup())
@bot.callback_query_handler(func=lambda call: True)
def callback(call):
if call.data == 'check':
check(call)
bot.polling(none_stop=True)
Traceback (most recent call last):
File "C:\Users\admin\PycharmProjects\App\main.py", line 62, in
bot.polling(none_stop=True)
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1043, in polling
self.threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1118, in threaded_polling
raise e
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1074, in threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py", line 148, in raise_exceptions
raise self.exception_info
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py", line 91, in run
task(*args, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init__.py", line 6428, in _run_middlewares_and_handler
result = handler'function'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\admin\PycharmProjects\App\main.py", line 19, in start
full_name = message.chat.full_name
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Chat' object has no attribute 'full_name'
Hello everyone, I just registered here today, I don't do programming very much, but I decided to make a bot, I did a video tutorial, but I get this error, I will give my characteristics below, I searched for information about the error on the Internet, but I didn't find an answer, I tried some ways, but it didn't work out . And yes, when I launch the bot through the terminal, they don't give me errors, but after I write to the bot or use the /start command, the terminal immediately gives an error. Please help me. If I somehow wrote a lot and the code could have been inserted in a different way, I'm sorry, this is the first time I use this site
import telebot from telebot import types
bot = telebot.TeleBot("mytoken") bot.set_webhook()
def start_markup(): markup = types.InlineKeyboardMarkup(row_width=True) link_keyboard1 = types.InlineKeyboardButton(text="1-й канал", url="https://t.me/mylink") link_keyboard2 = types.InlineKeyboardButton(text="2-й канал", url="https://t.me/mylink") link_keyboard3 = types.InlineKeyboardButton(text="3-й канал", url="https://t.me/mylink") check_keyboard = types.InlineKeyboardButton(text="Проверить", callback_data=check) markup.add(link_keyboard1, link_keyboard2, link_keyboard3, check_keyboard) return markup
@bot.message_handler(commands=["start"]) def start(message): chat_id = message.chat.id full_name = message.chat.full_name bot.send_message(chat_id, f"Привет {full_name} !\n" f"Чтобы пользоваться ботом подпишитесь на каналы !", reply_markup=start_markup())
def check(call): status = ['creator', 'administrator', 'member'] for i in status: if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status: check2(call) break
def check2(call): status = ['creator', 'administrator', 'member'] for i in status: if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status: check3(call) break
def check3(call): status = ['creator', 'administrator', 'member'] for i in status: if i == bot.get_chat_member(chat_id="idchannels", user_id=call.message.chat.id).status: bot.send_message(call.message.chat.id, "Спасибо что подписались на каналы !") break
@bot.callback_query_handler(func=lambda call: True) def callback(call): if call.data == 'check': check(call)
bot.polling(none_stop=True)
Traceback (most recent call last): File "C:\Users\admin\PycharmProjects\App\main.py", line 62, in
bot.polling(none_stop=True)
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1043, in polling self.threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout, File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1118, in threaded_polling raise e File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init.py", line 1074, in threaded_polling self.worker_pool.raise_exceptions() File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py", line 148, in raise_exceptions raise self.exception_info File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py", line 91, in run task(*args, **kwargs) File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot__init__.py", line 6428, in _run_middlewares_and_handler result = handler'function' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admin\PycharmProjects\App\main.py", line 19, in start full_name = message.chat.full_name ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Chat' object has no attribute 'full_name'