[base] Petites modifs
This commit is contained in:
parent
bf21ebe41a
commit
5612fac842
@ -2,7 +2,7 @@ import os
|
|||||||
from aiofile import AIOFile, Reader, Writer
|
from aiofile import AIOFile, Reader, Writer
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from config.base import Config
|
from config.Base import Config
|
||||||
|
|
||||||
|
|
||||||
class FSConfig(Config):
|
class FSConfig(Config):
|
||||||
|
2
config/__init__.py
Normal file
2
config/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from .Base import Config
|
||||||
|
from .FileSystem import FSConfig
|
6
main.py
6
main.py
@ -222,14 +222,16 @@ class LBI(discord.Client):
|
|||||||
error = log_LBI.error
|
error = log_LBI.error
|
||||||
critical = log_LBI.critical
|
critical = log_LBI.critical
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, config=None, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
if config is None:
|
||||||
|
config = FSConfig(path="data/config.yml")
|
||||||
self.reloading = False
|
self.reloading = False
|
||||||
self.id = ClientById(self)
|
self.id = ClientById(self)
|
||||||
self.ready = False
|
self.ready = False
|
||||||
# Content: {"module_name": {"module": imported module, "class": initialized class}}
|
# Content: {"module_name": {"module": imported module, "class": initialized class}}
|
||||||
self.modules = {}
|
self.modules = {}
|
||||||
self.config = FSConfig(path="data/config.yml")
|
self.config = config
|
||||||
self.config["modules"] = self.config["modules"] if self.config["modules"] is not None else ["modules","errors"]
|
self.config["modules"] = self.config["modules"] if self.config["modules"] is not None else ["modules","errors"]
|
||||||
self.config["prefix"] = self.config["prefix"] or "%"
|
self.config["prefix"] = self.config["prefix"] or "%"
|
||||||
self.config["owners"] = self.config["owners"] or []
|
self.config["owners"] = self.config["owners"] or []
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
"""Base class for module, never use directly !!!"""
|
"""Base class for module, never use directly !!!"""
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
|
||||||
import pickle
|
|
||||||
import traceback
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from config.base import Config
|
from config import Config
|
||||||
from storage import FSStorage, FSObjects
|
from storage import FSStorage, FSObjects
|
||||||
import storage.path as path
|
import storage.path as path
|
||||||
|
|
||||||
@ -38,9 +35,8 @@ class BaseClass:
|
|||||||
self.storage = FSStorage(path.join(self.client.base_path, self.name))
|
self.storage = FSStorage(path.join(self.client.base_path, self.name))
|
||||||
self.objects = FSObjects(self.storage)
|
self.objects = FSObjects(self.storage)
|
||||||
self.config = Config(parent=self.client.config, name="mod-"+self.name)
|
self.config = Config(parent=self.client.config, name="mod-"+self.name)
|
||||||
# Non necessaire car géré par fsstorage
|
self.config["authorized_roles"] = self.config["authorized_roles"] or self.authorized_roles
|
||||||
#if not self.storage.isdir(path.join("storage", self.name)):
|
self.config["authorized_users"] = self.config["authorized_users"] or self.authorized_users
|
||||||
# self.storage.makedirs(path.join("storage", self.name), exist_ok=True)
|
|
||||||
|
|
||||||
async def send_help(self, channel):
|
async def send_help(self, channel):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
@ -61,7 +57,7 @@ class BaseClass:
|
|||||||
:param user_list: List of authorized users, if not specified use self.authorized_users
|
:param user_list: List of authorized users, if not specified use self.authorized_users
|
||||||
:param role_list: list of authorized roles, if not specified use self.authorized_roles
|
:param role_list: list of authorized roles, if not specified use self.authorized_roles
|
||||||
:type user_list: List[Int]
|
:type user_list: List[Int]
|
||||||
:type role_list: List[int]
|
:type role_list: List[Int]
|
||||||
:type user: discord.User
|
:type user: discord.User
|
||||||
"""
|
"""
|
||||||
if role_list is None:
|
if role_list is None:
|
||||||
|
@ -5,7 +5,7 @@ import traceback
|
|||||||
import collections
|
import collections
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from config.base import Config
|
from config.Base import Config
|
||||||
from modules.base import BaseClassPython
|
from modules.base import BaseClassPython
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,9 +6,6 @@ from storage import path as pth
|
|||||||
class Storage:
|
class Storage:
|
||||||
"""Basic class for storage interface
|
"""Basic class for storage interface
|
||||||
|
|
||||||
When implementing function be precautionous to forbidden going outside restricted storage zone (storage/modulename
|
|
||||||
for example).
|
|
||||||
|
|
||||||
All path are on unix format (`/folder1/folder2/file`)
|
All path are on unix format (`/folder1/folder2/file`)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user