Skip to content

Commit

Permalink
bring back import_ytdl() functions (UsergeTeam#479)
Browse files Browse the repository at this point in the history
* testing codes

* testing
  • Loading branch information
SpEcHiDe authored Feb 27, 2022
1 parent 5dfc35f commit ebef9c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion userge/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
take_screen_shot,
parse_buttons,
is_command,
extract_entities)
extract_entities,
get_custom_import_re)
10 changes: 10 additions & 0 deletions userge/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# All rights reserved.

import asyncio
import importlib
import re
import shlex
from os.path import basename, join, exists
Expand Down Expand Up @@ -229,3 +230,12 @@ def extract_entities(message: Message, typeofentity: List[str]) -> List[str]:
if url and cet in typeofentity:
tero.append(url)
return tero


def get_custom_import_re(req_module):
""" import custom modules dynamically """
try:
return importlib.import_module(req_module)
except ModuleNotFoundError:
_LOG.warning(f"please fix your requirements.txt file [{req_module}]")
raise

0 comments on commit ebef9c1

Please sign in to comment.