3
3
35000sobak2020-07-07 19:30:05
Python
35000sobak, 2020-07-07 19:30:05

How to make a subscription check in a telegram bot channel?

I check like this

@bot.message_handler(commands=['start'])
def start(message):
    user_id = message.chat.id
    my_channel_id = -1001337625079
    statuss = ['creator', 'administrator', 'member']
    for i in statuss:
        if i == bot.get_chat_member(chat_id=my_channel_id, user_id=message.from_user.id).status:
            bot.send_sticker(message.chat.id, "CAACAgIAAxkBAAEBAlVfAc_5RxAVtkCserEzRwiwmh0UAwACPAAD-7g6BAwMRWBCpy3SGgQ")
            break
    else:
        bot.send_message(message.chat.id, "Подпишись на канал {} для продолжения".format(set_channel))


I get an error
2020-07-07 19:22:16,630 (__init__.py:448 MainThread) ERROR - TeleBot: "A reques
 to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request
 Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}']"

What can be wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Link, 2020-07-07
@35000sobak

Maybe a stupid question, but are you sure that the bot is added to the channel?
Duplicated from comments. Another option came to mind, if suddenly someone comes in with a similar problem: make sure that the channel ID is indicated with a minus.

S
soremix, 2020-07-07
@SoreMix

What can be wrong?

chat not found

No idea. Perhaps the chat was not found?

H
Hiroshimakado, 2022-03-07
@Hiroshimakado

Id channel in quotes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question