E
E
Ernest Vardanyan2020-07-23 12:05:39
Python
Ernest Vardanyan, 2020-07-23 12:05:39

How to get the id of the channel/chat in which the BOT is located?

Unfortunately, I lost a piece of a small code that, using requests , immediately displayed all the latest SMS in chats to the line where there is a bot, and I found the right id . To send SMS to the desired chat / channel, you must know the id, please help with this.

bot = telegram.Bot(token=BOT_TOKEN)
bot.send_message(chat_id='000000000000', text='199')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick, 2020-07-23
@c00re

You need a command handler, without it there is no way to find out the chat id

#Когда пользователь начинает диалог с ботом мы узнаём чат id
@bot.message_handler(commands = ['start'])
def start(message):
    bot.send_message(message.chat.id, 'Ваш текст')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question