From 8fa0470187ec7ab769887eb3b340fabdcd25d997 Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 8 May 2024 23:40:16 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=81=94=E5=90=88=E9=BB=91?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_minigame/game.py | 1 - .../plugins/liteyuki_uniblacklist/__init__.py | 16 ++++++++++ liteyuki/utils/base/ly_api.py | 30 +++++++------------ main.py | 6 ++-- 4 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 liteyuki/plugins/liteyuki_uniblacklist/__init__.py diff --git a/liteyuki/plugins/liteyuki_minigame/game.py b/liteyuki/plugins/liteyuki_minigame/game.py index f5b1e1c..b95ea90 100644 --- a/liteyuki/plugins/liteyuki_minigame/game.py +++ b/liteyuki/plugins/liteyuki_minigame/game.py @@ -2,7 +2,6 @@ import random from pydantic import BaseModel from liteyuki.utils.message.message import MarkdownMessage as md - class Dot(BaseModel): row: int col: int diff --git a/liteyuki/plugins/liteyuki_uniblacklist/__init__.py b/liteyuki/plugins/liteyuki_uniblacklist/__init__.py new file mode 100644 index 0000000..45bbf49 --- /dev/null +++ b/liteyuki/plugins/liteyuki_uniblacklist/__init__.py @@ -0,0 +1,16 @@ +from nonebot.plugin import PluginMetadata + +__author__ = "snowykami" +__plugin_meta__ = PluginMetadata( + name="联合黑名单(测试中...)", + description="", + usage="", + type="application", + homepage="https://github.com/snowykami/LiteyukiBot", + extra={ + "liteyuki": True, + "toggleable" : True, + "default_enable" : True, + } +) + diff --git a/liteyuki/utils/base/ly_api.py b/liteyuki/utils/base/ly_api.py index d866d62..19e123e 100644 --- a/liteyuki/utils/base/ly_api.py +++ b/liteyuki/utils/base/ly_api.py @@ -68,31 +68,23 @@ class LiteyukiAPI: else: nonebot.logger.warning(f"Bug report is disabled: {content}") - async def upload_image(self, image: bytes) -> str | None: + async def heartbeat_report(self): """ - 上传图片到图床 - Args: - image: - + 提交心跳,预留接口 Returns: - 图片url + """ - assert self.liteyuki_id, "Liteyuki ID is not set" - assert isinstance(image, bytes), "Image must be bytes" - url = "https://api.liteyuki.icu/upload_image" - data = FormData() - data.add_field("liteyuki_id", self.liteyuki_id) - data.add_field('image', image, filename='image', content_type='application/octet-stream') + url = "https://api.liteyuki.icu/heartbeat" + data = { + "liteyuki_id": self.liteyuki_id, + "version": __VERSION__, + } async with aiohttp.ClientSession() as session: - async with session.post( - url, - data=data - ) as resp: + async with session.post(url, json=data) as resp: if resp.status == 200: - return (await resp.json()).get("url") + nonebot.logger.success("Heartbeat sent successfully") else: - nonebot.logger.error(f"Upload image failed: {await resp.text()}") - return None + nonebot.logger.error(f"Heartbeat failed: {await resp.text()}") liteyuki_api = LiteyukiAPI() diff --git a/main.py b/main.py index 861704d..ab89951 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,5 @@ import nonebot from nonebot.adapters.onebot import v11, v12 - from liteyuki.utils import init from liteyuki.utils.base.config import load_from_yaml from liteyuki.utils.base.data_manager import StoredConfig, common_db @@ -19,11 +18,10 @@ driver = nonebot.get_driver() for adapter in adapters: driver.register_adapter(adapter) -nonebot.load_plugin("liteyuki.liteyuki_main") -nonebot.load_from_toml("pyproject.toml") - if __name__ == "__main__": try: + nonebot.load_plugin("liteyuki.liteyuki_main") + nonebot.load_from_toml("pyproject.toml") nonebot.run() except BaseException as e: if not isinstance(e, KeyboardInterrupt):