gmanroney/simplesocial

Connect To Telegram And Read From A Channel

Closed this issue · 1 comments

Connect To Telegram And Read From A Channel

here's how i did it (code snippet)

`from telethon import TelegramClient, events, sync
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
client = TelegramClient('readChannel', api_id, api_hash)
try:
client.start()
client.connect()
except:
NiceMsg("Could not connect to telegram")

try:
channel_entity=client.get_entity(channel_name)
posts = client(GetHistoryRequest(
peer=channel_entity,
limit=1000000,
offset_date=0,
offset_id=0,
max_id=0,
min_id=0,
add_offset=0,
hash=0))
except:
NiceMsg("Could not connect to channel ", channel_name)

NiceMsg("Read messages from chanel " + channel_name)`