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 14:21:06 +08:00

36 lines
1.1 KiB
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, str):
clist.append(a.command)
else:
for x in a.command:
clist.append(x)
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, str):
clist.append(a.command)
else:
for x in a.command:
clist.append(x)
except:
pass
return clist