B
B
Baga2021-05-19 20:27:59
Python
Baga, 2021-05-19 20:27:59

I made a code for sending a message, the bot says that there is no such chat, what should I do?

I made a code for sending a message, the bot says that there is no such chat.
The code:

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

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

@bot.message_handler(commands=["text"])
def text(message):
     if message.from_user.id == айди or message.from_user.id == второй айди:
        ci = argument(message.text)
        mt = argum(message.text)
        bot.send_message(chat_id=ci, text=mt)
        bot.reply_to(message, 'Отправлено!')

Mistake:
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-05-19
@Baga12324

In the argument function, you return a slice of the list. As I understand it, the chat ID goes in the text with a space? Then you wantedreturn arg.split()[1]

M
Mikhail Krostelev, 2021-05-19
@twistfire92

If the chat id is entered correctly, then the problem may lie in the fact that the person you are trying to send a message to did not activate this bot. Just like that, telegram protocols will not allow any person to send anything. So the bot must be run on the other end of the wire.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question