M
M
muvte2020-11-08 17:40:25
Python
muvte, 2020-11-08 17:40:25

Solved How to make a telegram bot write to a channel?

upd: 11/09/2020 SOlVED

Wrote a python bot to send messages to a group. Works great.
And now there is a task for him to send messages to the channel.

When I write a script (after which I write the /start command in private messages with the bot)

import telebot
token = '...'
bot = telebot.TeleBot(token)

@bot.message_handler(commands=['start'])
def default_test(message):

    answer = 'Привет!'
    bot.send_message('@hello_danishere', answer)

bot.polling(none_stop=True, interval=0)


or I make a telegram request myself:
https://api.telegram.org/bot/[email protected]
then I get the following error:
{"ok":false,"error_code":400,"description":" Bad Request: chat not found"}

From what I myself dug up on the Internet, I already did:
1. Made the bot an administrator and gave it all possible rights
2. Used @mychannelname instead of message.chat.id when calling send_message
3. What -something posted on the channel, because the bot can write to you only if you wrote to him
Help! How the hell do I force

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SHADRIN, 2020-11-08
@shadrin_ss

To begin with, you need to create a channel with such a login
Then add the bot to the admins
And only then test
And it's better to create a variable with a nickname and not insert it like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question