联合黑名单支持

This commit is contained in:
远野千束 2024-05-08 23:40:16 +08:00
parent 9b8c38cac0
commit 8fa0470187
4 changed files with 29 additions and 24 deletions

View File

@ -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

View File

@ -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,
}
)

View File

@ -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()

View File

@ -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):