纯 Python 3 MTProto API 单曲 Telegram客户端库,为bots也!
已移至 ZZURL0ZH GitHub存储器可能在未来被删除.
. 传记:
谢谢,所有主演这个项目的人,都很重要!
Telethon是一个Ayncio ** Python 3 MTProto 库与Telegram 的 API 交互 作为用户或通过bot账户(bot API替代).
重要的是:
如果在《Telethon》1.0版本前有使用该版本的代码,则必须 改为`学习如何移徙的兼容性和方便性。 与Telegram的第三方图书馆一样,请注意不要 断开“ Telegram” 的toSQQ或“ Telegram” 可以禁用账户。
这是什么?
Telegram是一个通俗的短信应用程序. 这个图书馆的意思是 以方便您编写可以交互的 Python 程序 与电报。 把它当作一个包装 已经做了 工作很繁重,因此可以专注于开发应用程序。
安装
. 代码-块:sh
pip3 安装电讯
创建客户端
.代码块:Python
从Telethon导入TelegramClient, 事件, 同步
api id = 12345 api hash = '0123456789abcdef0123456789abcdef' (中文(简体) )
客户端 = TelegramClient ('session name', api id, api hash) 客户端. start ()
做东西
密码:Python
打印( 客户端. get me (. stringify ())
客户端. send message ("用户名","你好!" 从Telethon和你说话。 客户端. send file ('username','/home/myself/Pictures/holidays.jpg') (中文(简体) ).
客户端。 下载 profile photo('我') 消息 = 客户端. get messages ('username') 信件 [0]. download media ()
@client.on (events. NewMessage (pattern=' (?i)hi|hello')). async def 处理器( 事件) : 等待事件。 对应 (“ Hey! ”)
今后的步骤
你喜欢Telethon的样子吗? 看看这个 "多读一下医生" 深入解释,并举出例子,解决问题,以及更多的 有用的信息。
. Ayncio: https://docs.python.org/3/library/asyncio.html (英语). . MTProto: https://core.telegram.org/mtproto . . . . . .