1
0
forked from bot/app

🐛 修复生命周期钩子函数的问题

This commit is contained in:
2024-08-08 18:06:03 +08:00
parent c29a3fd6d4
commit f69feb1def
27 changed files with 172 additions and 148 deletions

View File

@ -1,7 +1,7 @@
import threading
from nonebot import logger
from liteyuki.core.spawn_process import chan_in_spawn
from liteyuki.core.spawn_process import chan_in_spawn_nb
def reload(delay: float = 0.0, receiver: str = "nonebot"):
@ -15,5 +15,5 @@ def reload(delay: float = 0.0, receiver: str = "nonebot"):
"""
chan_in_spawn.send(1, receiver)
chan_in_spawn_nb.send(1, receiver)
logger.info(f"Reloading LiteyukiBot({receiver})...")

View File

@ -6,10 +6,9 @@ import aiohttp
import nonebot
import psutil
import requests
from aiohttp import FormData
from .. import __VERSION_I__, __VERSION__, __NAME__
from .config import load_from_yaml
from .. import __NAME__, __VERSION_I__, __VERSION__
class LiteyukiAPI:
@ -69,6 +68,10 @@ class LiteyukiAPI:
else:
nonebot.logger.warning(f"Bug report is disabled: {content}")
def register(self):
pass
async def heartbeat_report(self):
"""
提交心跳,预留接口

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/7 下午10:40
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py
@Software: PyCharm
"""
from .lib_loader import *
__all__ = [
"load_lib"
]

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/7 下午10:40
@Author : snowykami
@Email : snowykami@outlook.com
@File : lib_loader.py
@Software: PyCharm
"""
import os
import sys
import platform
import ctypes
LIB_EXT = None
PLATFORM = platform.system().lower() # linux, windows, darwin etc
ARCH = platform.machine().lower() # x86_64/amd64 i386 i686 arm aarch64 ppc64 ppc mips sparc
if "linux" in PLATFORM:
LIB_EXT = 'so'
elif sys.platform == 'darwin':
LIB_EXT = 'dylib'
elif sys.platform == 'win32':
LIB_EXT = 'dll'
else:
raise RuntimeError("Unsupported platform")
def load_lib(lib_name: str) -> ctypes.CDLL:
"""
Load a dll/so/dylib library, without extension.
Args:
lib_name: str, path/to/library without extension
Returns:
xxx_{platform}_{arch}.{ext} ctypes.CDLL
"""
whole_path = f"{lib_name}_{PLATFORM}_{ARCH}.{LIB_EXT}"
if not os.path.exists(whole_path):
raise FileNotFoundError(f"Library {whole_path} not found")
return ctypes.CDLL(whole_path)