Hi guys,
I'm newbie in telegram API, I want to send data to my channel using bot, I've already add my bot to my channel as administrator, but how can I send content via this package?
Hey :)
Check the documentation and the examples on how to send messages in general. To send a message to a channel, you can just put the name of the channel as the chat id.
Example:
bot.sendMessage(chat_id='@channelname', text='Some content')
@jh0ker yeah, I just didn't know that I have to put @channelname in chat_id param.
Thanks man :+1:
and how to send photo to channel ?
i can send text message but cant send image. i got an error that cant parse chat_id with @ symbol!
@alirezakhosraviyan
Since you're asking about posting to a channel directly from your bot, it is very important you understand that a bot needs to be made the administrator to a channel to which you'd like it to post to.
Try:
bot.sendPhoto(chat_id="_your channel name here... example: @Linuxgram", photo="https://telegram.org/img/t_logo.png", caption="Sample photo")
how can i get message from chanel. By MESSAGE ID
Most helpful comment
Hey :)
Check the documentation and the examples on how to send messages in general. To send a message to a channel, you can just put the name of the channel as the chat id.
Example: