Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/commandlist.py
2020-09-19 18:35:13 +08:00

30 lines
926 B
Python

def commandlist():
clist = {}
import os
path = os.path.abspath('./modules')
dirs = os.listdir(path)
import re
for file in dirs:
filename = os.path.abspath(f'./modules/{file}')
if os.path.isdir(filename):
if file == '__pycache__':
pass
else:
a = __import__('modules.' + file, fromlist=[file])
try:
if isinstance(a.command, dict):
clist.update(a.command)
except:
pass
if os.path.isfile(filename):
b = re.match(r'(.*)(.py)', file)
if b:
a = __import__('modules.' + b.group(1), fromlist=[b.group(1)])
try:
if isinstance(a.command, dict):
clist.update(a.command)
except:
pass
return clist