mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 00:32:06 +08:00
添加单例注解
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from typing import List, Tuple, Dict, Optional
|
||||
from configs.path_config import IMAGE_PATH
|
||||
from utils.decorator import Singleton
|
||||
from utils.image_utils import BuildImage
|
||||
from configs.config import Config
|
||||
import os
|
||||
@@ -109,20 +110,15 @@ def group_image(image_list: List[BuildImage]) -> Tuple[List[List[BuildImage]], i
|
||||
return image_group, max(max_h + 250, max_w + 70)
|
||||
|
||||
|
||||
@Singleton
|
||||
class HelpImageBuild:
|
||||
|
||||
build: Optional["HelpImageBuild"] = None
|
||||
|
||||
def __init__(self):
|
||||
print('初始化咯')
|
||||
self._data: Dict[str, PluginData] = plugin_data_manager.get_data()
|
||||
self._sort_data: Dict[str, List[PluginData]] = {}
|
||||
self._image_list = []
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if not cls.build:
|
||||
cls.build = super().__new__(cls)
|
||||
return cls.build
|
||||
|
||||
def sort_type(self):
|
||||
"""
|
||||
说明:
|
||||
@@ -156,7 +152,8 @@ class HelpImageBuild:
|
||||
:param group_id: 群号
|
||||
"""
|
||||
self._image_list = []
|
||||
self.sort_type()
|
||||
if not self._sort_data.keys():
|
||||
self.sort_type()
|
||||
font_size = 24
|
||||
build_type = Config.get_config("help", "TYPE")
|
||||
_image = BuildImage(0, 0, plain_text="1", font_size=font_size)
|
||||
|
||||
@@ -19,6 +19,7 @@ from models.friend_user import FriendUser
|
||||
from models.group_member_info import GroupInfoUser
|
||||
from models.level_user import LevelUser
|
||||
from models.user_shop_gold_log import UserShopGoldLog
|
||||
from utils.decorator import Singleton
|
||||
from utils.manager import (
|
||||
plugins2block_manager,
|
||||
StaticData,
|
||||
@@ -119,24 +120,18 @@ class ReturnException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@Singleton
|
||||
class AuthChecker:
|
||||
"""
|
||||
权限检查
|
||||
"""
|
||||
|
||||
checker: Optional["AuthChecker"] = None
|
||||
|
||||
def __init__(self):
|
||||
self._flmt = FreqLimiter(Config.get_config("hook", "CHECK_NOTICE_INFO_CD"))
|
||||
self._flmt_g = FreqLimiter(Config.get_config("hook", "CHECK_NOTICE_INFO_CD"))
|
||||
self._flmt_s = FreqLimiter(Config.get_config("hook", "CHECK_NOTICE_INFO_CD"))
|
||||
self._flmt_c = FreqLimiter(Config.get_config("hook", "CHECK_NOTICE_INFO_CD"))
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if not cls.checker:
|
||||
cls.checker = super().__new__(cls)
|
||||
return cls.checker
|
||||
|
||||
async def auth(self, matcher: Matcher, bot: Bot, event: Event):
|
||||
"""
|
||||
说明:
|
||||
|
||||
Reference in New Issue
Block a user