mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Enhance API by adding support for Context Managers. Closes #122
A batch script would be as simple as this example:
from pyrogram import Client
with Client("...") as app:
app.send_message("haskell", "hi")
This commit is contained in:
parent
cd3649448c
commit
f850d6352e
1 changed files with 7 additions and 0 deletions
|
|
@ -183,6 +183,13 @@ class Client(Methods, BaseClient):
|
|||
|
||||
self.dispatcher = Dispatcher(self, workers)
|
||||
|
||||
def __enter__(self):
|
||||
self.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.stop()
|
||||
|
||||
@property
|
||||
def proxy(self):
|
||||
return self._proxy
|
||||
|
|
|
|||
Loading…
Reference in a new issue