python 3的全功能telegram客户端库
TelethonGoblenusTest的Python项目详细描述
⭐️ Thanks everyone who has starred the project, it means a lot!
Telethon是Python 3中的电报客户端实现,它使用 最新可用的电报API请记住使用pip3安装!
安装
pip install telethon
创建客户端
fromtelethonimportTelegramClient# These example values won't work. You must get your own api_id and# api_hash from https://my.telegram.org, under API Development.api_id=12345api_hash='0123456789abcdef0123456789abcdef'phone='+34600000000'client=TelegramClient('session_name',api_id,api_hash)client.connect()# If you already have a previous 'session_name.session' file, skip this.client.sign_in(phone=phone)me=client.sign_in(code=77777)# Put whatever code you received here.
做事
print(me.stringify())client.send_message('username','Hello! Talking to you from Telethon')client.send_file('username','/home/myself/Pictures/holidays.jpg')client.download_profile_photo(me)total,messages,senders=client.get_message_history('username')client.download_media(messages[0])
下一步
你喜欢Telethon的样子吗?检查 wiki over GitHub对于 更深入的解释、示例、疑难解答等 有用的信息。