forked from GodLuciferXD/MightyXBotSpam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
27 lines (23 loc) · 841 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
import logging
import importlib
from telethon import events
from pathlib import Path
import inspect
import re
def load_plugins(plugin_name):
path = Path(f"MightyXSpam/plugins/{plugin_name}.py")
name = "MightyXSpam.plugins.{}".format(plugin_name)
spec = importlib.util.spec_from_file_location(name, path)
load = importlib.util.module_from_spec(spec)
load.logger = logging.getLogger(plugin_name)
spec.loader.exec_module(load)
sys.modules["MightyXSpam.plugins." + plugin_name] = load
print("Mighty X has Imported " + plugin_name)
async def edit_or_reply(event, text):
if event.sender_id in SUDO_USERS:
reply_to = await event.get_reply_message()
if reply_to:
return await reply_to.reply(text)
return await event.reply(text)
return await event.edit(text)