#
#
#D3m02021-06-28 18:22:27
Python
#D3m0, 2021-06-28 18:22:27

Why is chat not found?

the code:

def chati(arg):
    return arg.split()[1:]

def text(arg):
    return arg.split()[2]

@bot.message_handler(commands=["text"])
def sendmt(message):
            ci = chati(message.text)
            mt = text(message.text)
            bot.send_message(chat_id=ci,text=mt)
            bot.reply_to(message, 'Отправлено!')


ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-06-28
@StickPY

print(ci)- see the list. If you want to get a word, then get just a word, without a cut.
return arg.split()[1]

M
Mikhail Krostelev, 2021-06-28
@twistfire92

Either you are passing a non-existent chat_id, or the bot in this chat (which you are passing) is not running. If you want to send a message to someone who knows nothing about the bot, nothing will come of it. The user starts the conversation first.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question