mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-25 00:25:04 +08:00
✨ 联合黑名单支持
This commit is contained in:
parent
9b8c38cac0
commit
8fa0470187
@ -2,7 +2,6 @@ import random
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from liteyuki.utils.message.message import MarkdownMessage as md
|
from liteyuki.utils.message.message import MarkdownMessage as md
|
||||||
|
|
||||||
|
|
||||||
class Dot(BaseModel):
|
class Dot(BaseModel):
|
||||||
row: int
|
row: int
|
||||||
col: 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:
|
else:
|
||||||
nonebot.logger.warning(f"Bug report is disabled: {content}")
|
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:
|
Returns:
|
||||||
图片url
|
|
||||||
"""
|
"""
|
||||||
assert self.liteyuki_id, "Liteyuki ID is not set"
|
url = "https://api.liteyuki.icu/heartbeat"
|
||||||
assert isinstance(image, bytes), "Image must be bytes"
|
data = {
|
||||||
url = "https://api.liteyuki.icu/upload_image"
|
"liteyuki_id": self.liteyuki_id,
|
||||||
data = FormData()
|
"version": __VERSION__,
|
||||||
data.add_field("liteyuki_id", self.liteyuki_id)
|
}
|
||||||
data.add_field('image', image, filename='image', content_type='application/octet-stream')
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.post(
|
async with session.post(url, json=data) as resp:
|
||||||
url,
|
|
||||||
data=data
|
|
||||||
) as resp:
|
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
return (await resp.json()).get("url")
|
nonebot.logger.success("Heartbeat sent successfully")
|
||||||
else:
|
else:
|
||||||
nonebot.logger.error(f"Upload image failed: {await resp.text()}")
|
nonebot.logger.error(f"Heartbeat failed: {await resp.text()}")
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
liteyuki_api = LiteyukiAPI()
|
liteyuki_api = LiteyukiAPI()
|
||||||
|
6
main.py
6
main.py
@ -1,6 +1,5 @@
|
|||||||
import nonebot
|
import nonebot
|
||||||
from nonebot.adapters.onebot import v11, v12
|
from nonebot.adapters.onebot import v11, v12
|
||||||
|
|
||||||
from liteyuki.utils import init
|
from liteyuki.utils import init
|
||||||
from liteyuki.utils.base.config import load_from_yaml
|
from liteyuki.utils.base.config import load_from_yaml
|
||||||
from liteyuki.utils.base.data_manager import StoredConfig, common_db
|
from liteyuki.utils.base.data_manager import StoredConfig, common_db
|
||||||
@ -19,11 +18,10 @@ driver = nonebot.get_driver()
|
|||||||
for adapter in adapters:
|
for adapter in adapters:
|
||||||
driver.register_adapter(adapter)
|
driver.register_adapter(adapter)
|
||||||
|
|
||||||
nonebot.load_plugin("liteyuki.liteyuki_main")
|
|
||||||
nonebot.load_from_toml("pyproject.toml")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
nonebot.load_plugin("liteyuki.liteyuki_main")
|
||||||
|
nonebot.load_from_toml("pyproject.toml")
|
||||||
nonebot.run()
|
nonebot.run()
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
if not isinstance(e, KeyboardInterrupt):
|
if not isinstance(e, KeyboardInterrupt):
|
||||||
|
Loading…
Reference in New Issue
Block a user