mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-11 01:27:29 +08:00
✨ 联合黑名单支持
This commit is contained in:
parent
9b8c38cac0
commit
8fa0470187
@ -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
|
||||
|
16
liteyuki/plugins/liteyuki_uniblacklist/__init__.py
Normal file
16
liteyuki/plugins/liteyuki_uniblacklist/__init__.py
Normal 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,
|
||||
}
|
||||
)
|
||||
|
@ -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()
|
||||
|
6
main.py
6
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):
|
||||
|
Loading…
Reference in New Issue
Block a user