@wit0k

Проблема связана с неизвестной ошибкой в питонe, библеотека telebot, не могу понять, что не так?

Пытаюсь сделать бота с проверкой на подписки, но выдает ошибку
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found
Не могу ее найти, помогите пожалуйста, буду благодарен
Вот кусок кода:

def start_markup():
markup = types.InlineKeyboardMarkup(row_width=True)
link_keyboard1 = types.InlineKeyboardButton(text="1-й Канал", url=url_cm_fish)
link_keyboard2 = types.InlineKeyboardButton(text="2-й Канал", url=url_alkash)
link_keyboard3 = types.InlineKeyboardButton(text="3-й Канал", url=url_sancherkin)
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
bot.send_message(chat_id, " Теперь,проверим подписки на каналы", reply_markup=start_markup())

def check(call):
status = ["creator", "administrator", "member"]
for i in status:
if i == bot.get_chat_member(chat_id="-1002058536468", 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="-1001517647456", 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="-1001758164447", user_id=call.message.chat.id).status:
bot.send_message(call.message.chat_id,
f"Спасибо, что подписалиись на каналы,вот ссылка на официальный дискорд сервер:{server}")
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":
bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.id)
check(call)

bot.polling()
  • Вопрос задан
  • 159 просмотров
Пригласить эксперта
Ответы на вопрос 2
febday
@febday
Ошибка гласит о том, что чат не найден. Скорее всего бот не добавлен в чат или не является админом

Одна из функций check(), check2(), check3()
Какая именно мы без понятия, потому что вы не прикрепили полный трейсбэк.
Ответ написан
@YeaNot
chat_id="-1001758164447",

Убери кавычки
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы