'python telegram bot - how to get bot role for private channels?
bot.get_chat_administrators seems to return ChatMember instance for public channels. I need role of my bot in private channels.
Solution 1:[1]
if send message works bot should be admin in the channel. https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot.send_message
but in my case it didn't work. so I referred to official api:
import requests
from telegram import Bot
TOKEN = "YOUR_TOKEN"
bot = Bot(token=TOKEN)
def send_message_to_private(chat_id, text):
api = f'https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={chat_id}&text={text}'
response = requests.get(api).json()
return response['result']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OuzKagan |
