11
This commit is contained in:
@@ -7,9 +7,9 @@ from astrbot.api.star import Context, Star, register, StarTools
|
||||
from astrbot.api import logger
|
||||
from astrbot.api import AstrBotConfig
|
||||
|
||||
from .core.load_template import load_template
|
||||
from .core.basic_Function import load_template
|
||||
from .core.jx3_data import jx3_data_jiaoyihang,jx3_data_wujia
|
||||
from .core.sql_data import sql_data_searchdata,sql_data_select
|
||||
from .core.sql_data import AsyncMySQL
|
||||
from .core.jx3_Function import JX3Function
|
||||
|
||||
|
||||
@@ -31,12 +31,25 @@ class Jx3ApiPlugin(Star):
|
||||
# 读取文件内容
|
||||
with open(self.api_file_path, 'r', encoding='utf-8') as f:
|
||||
self.api_config = json.load(f)
|
||||
|
||||
logger.info("jx3api插件初始化完成")
|
||||
|
||||
|
||||
async def initialize(self):
|
||||
"""可选择实现异步的插件初始化方法,当实例化该插件类之后会自动调用该方法。"""
|
||||
# 数据库配置
|
||||
db_config = {
|
||||
'host': '154.201.70.116',
|
||||
'port': 3306,
|
||||
'user': 'asrtbot',
|
||||
'password': 'qsc123456',
|
||||
'db': 'asrtbot',
|
||||
'charset': 'utf8mb4',
|
||||
'autocommit': True
|
||||
}
|
||||
#创建类实例
|
||||
self.jx3fun = JX3Function(self.api_config)
|
||||
self.db = AsyncMySQL(db_config)
|
||||
self.jx3fun = JX3Function(self.api_config,self.db)
|
||||
logger.info("jx3api插件创建实例完成")
|
||||
|
||||
|
||||
@@ -136,6 +149,38 @@ class Jx3ApiPlugin(Star):
|
||||
yield event.plain_result("猪脑过载,请稍后再试")
|
||||
|
||||
|
||||
@jx3.command("物价")
|
||||
async def jx3_wujia(self, event: AstrMessageEvent,Name: str = "秃盒"):
|
||||
"""剑三 外观名称"""
|
||||
try:
|
||||
data=await self.jx3fun.wujia(Name)
|
||||
if data["code"] == 200:
|
||||
url = await self.html_render(data["temp"], data["data"], options={})
|
||||
yield event.image_result(url)
|
||||
else:
|
||||
yield event.plain_result(data["msg"])
|
||||
return
|
||||
except Exception as e:
|
||||
logger.error(f"功能函数执行错误: {e}")
|
||||
yield event.plain_result("猪脑过载,请稍后再试")
|
||||
|
||||
|
||||
@filter.permission_type(filter.PermissionType.ADMIN)
|
||||
@jx3.command("外观数据同步")
|
||||
async def jx3_SearchData(self, event: AstrMessageEvent):
|
||||
"""剑三外观数据同步"""
|
||||
try:
|
||||
data=await self.jx3fun.SearchData()
|
||||
if data["code"] == 200:
|
||||
yield event.plain_result(data["msg"])
|
||||
else:
|
||||
yield event.plain_result(data["msg"])
|
||||
return
|
||||
except Exception as e:
|
||||
logger.error(f"功能函数执行错误: {e}")
|
||||
yield event.plain_result("猪脑过载,请稍后再试")
|
||||
|
||||
|
||||
@filter.command("剑三交易行")
|
||||
async def jx3_data_jiaoyihang(self, event: AstrMessageEvent):
|
||||
"""剑三交易行 物品名称 服务器"""
|
||||
@@ -192,21 +237,11 @@ class Jx3ApiPlugin(Star):
|
||||
yield event.plain_result("查询交易行数据时出错,请稍后再试")
|
||||
|
||||
|
||||
@filter.command("剑三外观数据同步")
|
||||
async def jx3_SearchData(self, event: AstrMessageEvent):
|
||||
"""剑三外观数据同步"""
|
||||
|
||||
try:
|
||||
test = sql_data_searchdata()
|
||||
yield event.plain_result(f"{test}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"处理数据时出错: {e}")
|
||||
yield event.plain_result("处理接口返回信息时出错")
|
||||
|
||||
|
||||
|
||||
@filter.command("剑三物价")
|
||||
async def jx3_wujia(self, event: AstrMessageEvent):
|
||||
async def jx3_wujia11(self, event: AstrMessageEvent):
|
||||
"""剑三物价 外观名称"""
|
||||
|
||||
inname = "秃盒"
|
||||
@@ -244,4 +279,6 @@ class Jx3ApiPlugin(Star):
|
||||
|
||||
|
||||
async def terminate(self):
|
||||
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
||||
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
||||
await self.db.close_pool()
|
||||
logger.info("jx3api插件已卸载/停用")
|
||||
Reference in New Issue
Block a user