5

I have a telegram bot which publishes messages to somebot using this code.

import telegram
from telegram import ParseMode
def send_msg(text):
    token = '1*****:AAF*************esns'
    chat_id = "34*****4"
    bot = telegram.Bot(token=token)
    
    bot.sendMessage(chat_id=chat_id, text=text, parse_mode=ParseMode.MARKDOWN_V2)

What I was wondering is if it is possible for the telegram bot to send message to my channel where i have made it an admin and not its own channel called somebot.

Slartibartfast
  • 1,058
  • 4
  • 26
  • 60

1 Answers1

8

As your Bot already is an Admin of the channel you want it to post in, you just need to change the chat_id for Bot.send_message() to the one of the channel the bot is meant to send posts in.

You can obtain this ID for example by using Bgram Telegram client or IDBot. Be aware that you may have to prepend -100 to the ID you get as channels are just special super-groups.

Hope it helps ;)

nyx69
  • 747
  • 10
  • 21
  • I am using a channel called: `GETID BOT` in telegram. And if i forward message from any of my channel. its showing the same ID – Slartibartfast Feb 26 '22 at 10:10
  • 3
    What do you mean by showing the same ID? You send a message from multiple channels, but all have the same channel id? – nyx69 Feb 26 '22 at 10:14