So i have this python code that figures out channel chat id to send message for multiple channels in a given list.
I only have the channel invite link
I still didn’t figure out how can i get the channel id by the name only.
import os
import telebot
API_KEY = os.environ['API_KEY']
bot = telebot.TeleBot(API_KEY)
a=input("edit msg.txt to send the msg if done press enter")
message=open("message.txt","a+")
bot.send_message(chat_id,message)
2
Answers
You can use the
getChat
method to resolve a channel username to the chat id. You can also just send the message using the username – see the docs ofsendMessage
and e.g. this answer.If you prefer to use Telegram API together with
javascript
andaxios
library then you might consider the following: