v4.0.2 #172

Merged
profitroll merged 9 commits from dev into main 2025-01-02 15:04:26 +02:00
2 changed files with 45 additions and 54 deletions
Showing only changes of commit d5e390fe66 - Show all commits

View File

@ -1,9 +1,13 @@
import logging import logging
from logging import Logger
from pathlib import Path from pathlib import Path
from typing import Any, Dict from typing import Any, Dict
from typing_extensions import override from typing_extensions import override
from ...i18n.classes import BotLocale
from ...utils import json_read
try: try:
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
@ -11,14 +15,7 @@ try:
except ImportError as exc: except ImportError as exc:
raise ImportError("You need to install libbot[pycord] in order to use this class.") from exc raise ImportError("You need to install libbot[pycord] in order to use this class.") from exc
try: logger: Logger = logging.getLogger(__name__)
from ujson import loads
except ImportError:
from json import loads
from ...i18n.classes import BotLocale
logger = logging.getLogger(__name__)
class PycordBot(Bot): class PycordBot(Bot):
@ -32,11 +29,7 @@ class PycordBot(Bot):
scheduler: AsyncIOScheduler | BackgroundScheduler | None = None, scheduler: AsyncIOScheduler | BackgroundScheduler | None = None,
**kwargs, **kwargs,
): ):
if config is None: self.config: Dict[str, Any] = config if config is not None else json_read(config_path)
with open(config_path, "r", encoding="utf-8") as f:
self.config: dict = loads(f.read())
else:
self.config = config
super().__init__( super().__init__(
debug_guilds=(self.config["bot"]["debug_guilds"] if self.config["debug"] else None), debug_guilds=(self.config["bot"]["debug_guilds"] if self.config["debug"] else None),

View File

@ -2,6 +2,7 @@ import asyncio
import logging import logging
import sys import sys
from datetime import datetime, timedelta from datetime import datetime, timedelta
from logging import Logger
from os import cpu_count, getpid from os import cpu_count, getpid
from pathlib import Path from pathlib import Path
from time import time from time import time
@ -9,6 +10,12 @@ from typing import Any, Dict, List
from typing_extensions import override from typing_extensions import override
from .command import PyroCommand
from .commandset import CommandSet
from ...i18n import _
from ...i18n.classes import BotLocale
from ...utils import json_read
try: try:
import pyrogram import pyrogram
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
@ -35,12 +42,7 @@ try:
except ImportError: except ImportError:
from json import dumps, loads from json import dumps, loads
from ...i18n.classes import BotLocale logger: Logger = logging.getLogger(__name__)
from ...i18n import _
from .command import PyroCommand
from .commandset import CommandSet
logger = logging.getLogger(__name__)
class PyroClient(Client): class PyroClient(Client):
@ -66,11 +68,7 @@ class PyroClient(Client):
scheduler: AsyncIOScheduler | BackgroundScheduler | None = None, scheduler: AsyncIOScheduler | BackgroundScheduler | None = None,
**kwargs, **kwargs,
): ):
if config is None: self.config: Dict[str, Any] = config if config is not None else json_read(config_path)
with open(config_path, "r", encoding="utf-8") as f:
self.config: dict = loads(f.read())
else:
self.config = config
super().__init__( super().__init__(
name=name, name=name,