from utils.exception import ExceptionProcess from utils.manager import PluginManager from utils.message import processSession from utils.objects import callModuleAPI, convertImageFormat from utils.tmpFile import tmpFile __plugin_name__ = "time_reminder" PluginManager.registerPlugin(__plugin_name__) POWER_GROUP = GROUP_ADMIN | SUPERUSER CONFIG_DIR = "./configs/greeting.yml" DEFAULT_DIR = "./configs/default.greeting.yml" _IMAGE_LIST_CACHE = None if not isfile(CONFIG_DIR): copyFileInText(DEFAULT_DIR, CONFIG_DIR) CONFIG = configsReader(CONFIG_DIR, DEFAULT_DIR) logger.debug(f"Apscheduler status: {apscheduler.version_info}.") def resizeImage(image: bytes, *, height: Optional[int] = None, width: Optional[int] = None) -> bytes: with tmpFile() as tmpFileName: with open(tmpFileName, "wb") as f: f.write(image) with Image.open(tmpFileName) as img: originWidth, originHeight = img.size if height:
from utils.configsReader import configsReader, copyFileInText from utils.decorators import CatchRequestsException, SyncToAsync from utils.message import processSession from utils.network import NetworkUtils from utils.manager import PluginManager __plugin_name__ = "wikipedia" PluginManager.registerPlugin(__plugin_name__) CONFIG_PATH = "configs/wikipedia.yml" DEFAULT_PATH = "configs/default.wikipedia.yml" if not os.path.isfile(CONFIG_PATH): copyFileInText(DEFAULT_PATH, CONFIG_PATH) CONFIG_READ = Config = configsReader(CONFIG_PATH, DEFAULT_PATH) @CatchRequestsException(prompt="从维基获取数据出错") def getWiki(keyword: str) -> dict: requestParam = { "action": "query", "generator": "prefixsearch", "gpssearch": keyword, "format": "json", "prop": "extracts|info", "inprop": "url", "exintro": "1", "explaintext": "1",
from zipfile import PyZipFile from nonebot import CommandSession, on_command from utils.configsReader import configsReader, copyFileInText from utils.decorators import SyncToAsync from utils.message import processSession __plugin_name__ = "generateID" _DATA_BINARY_DIR = "./data/id.bin" _DEFAULT_DIR = "./configs/default.gen_id.yml" _CONFIG_DIR = "./configs/gen_id.yml" if not isfile(_CONFIG_DIR): copyFileInText(_DEFAULT_DIR, _CONFIG_DIR) CONFIG = configsReader(_CONFIG_DIR, _DEFAULT_DIR) MESSAGE = CONFIG.format BIRTH_BEGIN = datetime(*[int(i) for i in CONFIG.birth.begin]) BIRTH_END = datetime(*[int(i) for i in CONFIG.birth.end]) def _loadMainData() -> Tuple[Dict[str, str], Dict[str, List[str]]]: with PyZipFile(_DATA_BINARY_DIR, "r") as zipFile: with zipFile.open("name.json", "r") as f: nameLoad = json.loads(f.read().decode()) with zipFile.open("area.json", "r") as f: areaLoad = json.loads(f.read().decode()) return areaLoad, nameLoad