mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Merge branch 'develop' into asyncio
This commit is contained in:
commit
6ade4030b2
@ -35,12 +35,9 @@ Example:
|
|||||||
password="password" # (if you have one)
|
password="password" # (if you have one)
|
||||||
)
|
)
|
||||||
|
|
||||||
app.start()
|
with app:
|
||||||
|
|
||||||
print(app.get_me())
|
print(app.get_me())
|
||||||
|
|
||||||
app.stop()
|
|
||||||
|
|
||||||
Sign Up
|
Sign Up
|
||||||
-------
|
-------
|
||||||
|
|
||||||
@ -67,8 +64,5 @@ Example:
|
|||||||
last_name="" # Can be an empty string
|
last_name="" # Can be an empty string
|
||||||
)
|
)
|
||||||
|
|
||||||
app.start()
|
with app:
|
||||||
|
|
||||||
print(app.get_me())
|
print(app.get_me())
|
||||||
|
|
||||||
app.stop()
|
|
@ -34,6 +34,7 @@ from configparser import ConfigParser
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from hashlib import sha256, md5
|
from hashlib import sha256, md5
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
from pathlib import Path
|
||||||
from signal import signal, SIGINT, SIGTERM, SIGABRT
|
from signal import signal, SIGINT, SIGTERM, SIGABRT
|
||||||
|
|
||||||
from pyrogram.api import functions, types
|
from pyrogram.api import functions, types
|
||||||
@ -979,28 +980,29 @@ class Client(Methods, BaseClient):
|
|||||||
|
|
||||||
def load_plugins(self):
|
def load_plugins(self):
|
||||||
if self.plugins_dir is not None:
|
if self.plugins_dir is not None:
|
||||||
try:
|
|
||||||
dirs = os.listdir(self.plugins_dir)
|
|
||||||
except FileNotFoundError:
|
|
||||||
log.warning('No plugin loaded: "{}" directory is missing'.format(self.plugins_dir))
|
|
||||||
else:
|
|
||||||
plugins_dir = self.plugins_dir.lstrip("./").replace("/", ".")
|
|
||||||
plugins_count = 0
|
plugins_count = 0
|
||||||
|
|
||||||
for i in dirs:
|
for path in Path(self.plugins_dir).rglob("*.py"):
|
||||||
module = import_module("{}.{}".format(plugins_dir, i.split(".")[0]))
|
file_path = os.path.splitext(str(path))[0]
|
||||||
|
import_path = []
|
||||||
|
|
||||||
for j in dir(module):
|
while file_path:
|
||||||
|
file_path, tail = os.path.split(file_path)
|
||||||
|
import_path.insert(0, tail)
|
||||||
|
|
||||||
|
import_path = ".".join(import_path)
|
||||||
|
module = import_module(import_path)
|
||||||
|
|
||||||
|
for name in dir(module):
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
handler, group = getattr(module, j)
|
handler, group = getattr(module, name)
|
||||||
|
|
||||||
if isinstance(handler, Handler) and isinstance(group, int):
|
if isinstance(handler, Handler) and isinstance(group, int):
|
||||||
self.add_handler(handler, group)
|
self.add_handler(handler, group)
|
||||||
|
|
||||||
log.info('{}("{}") from "{}/{}" loaded in group {}'.format(
|
log.info('{}("{}") from "{}" loaded in group {}'.format(
|
||||||
type(handler).__name__, j, self.plugins_dir, i, group)
|
type(handler).__name__, name, import_path, group))
|
||||||
)
|
|
||||||
|
|
||||||
plugins_count += 1
|
plugins_count += 1
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user