From 507509a4d2055dd814068ac876295e771bee701d Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 16:45:38 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index e92eeb0..6b05da2 100644 --- a/main.py +++ b/main.py @@ -158,7 +158,7 @@ class MyPlugin(Star): conn.close() yield event.plain_result(f"背包存在异常!") else: - baglist_str += f"{Tool.get_tool_name(item["id"])} x {item['num']}\n" + baglist_str += f"{Tool.get_tool_name(item['id'])} x {item['num']}\n" cur.close() conn.close() yield event.plain_result(f"背包列表:\n{baglist_str}") From c146d96d9117dac89134fddd12443290c1e59013 Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 16:48:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5bug2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6b05da2..0b5c877 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ import json -import Tool +from Tool import * from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult from astrbot.api.star import Context, Star, register from astrbot.api import logger From 5dcbb524c084d5ee634db30adbd16415f4279a94 Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 16:50:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5bug3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 0b5c877..fb7bd82 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ import json -from Tool import * +from .Tool import * from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult from astrbot.api.star import Context, Star, register from astrbot.api import logger From 627e3f7c33e35f6801fdcb652663fe34c38f31d8 Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 17:11:06 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AF=BC=E5=85=A5bug?= =?UTF-8?q?=EF=BC=8C=E4=B8=BA=E4=BB=80=E4=B9=88=E5=AF=BC=E5=85=A5=E7=B1=BB?= =?UTF-8?q?=E4=BC=9A=E6=8A=A5=E9=94=99(=E2=80=A2=CC=81=E3=81=B8=E2=80=A2?= =?UTF-8?q?=CC=81=E2=95=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tool.py | 3 +-- main.py | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Tool.py b/Tool.py index 1ca51e7..2c48e3d 100644 --- a/Tool.py +++ b/Tool.py @@ -10,8 +10,7 @@ class Tool: self.typeid = typeid - @staticmethod - def get_tool_name(id): +def get_tool_name(id): conn=pymysql.connect(host = '192.168.31.9' # 连接名称,默认 ,user = 'saipo' ,passwd='Grasste0403' # 密码 diff --git a/main.py b/main.py index fb7bd82..d8c134e 100644 --- a/main.py +++ b/main.py @@ -1,18 +1,17 @@ import json -from .Tool import * from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult from astrbot.api.star import Context, Star, register from astrbot.api import logger import random from .back import time_long, volume, isUserExist, insertUser, seconds_to_hms, ml_to_l_ml, get_user_name import pymysql +from .Tool import get_tool_name @register("helloworld", "YourName", "一个简单的 Hello World 插件", "1.0.0") class MyPlugin(Star): def __init__(self, context: Context): super().__init__(context) - @filter.command("打打我的") async def dajiao(self, event: AstrMessageEvent): if isUserExist(event.get_sender_id()) != True: @@ -153,12 +152,12 @@ class MyPlugin(Star): baglist_str = "背包空空如也" else: for item in baglist: - if Tool.get_tool_name(item["id"]) is None: + if get_tool_name(item["id"]) is None: cur.close() conn.close() yield event.plain_result(f"背包存在异常!") else: - baglist_str += f"{Tool.get_tool_name(item['id'])} x {item['num']}\n" + baglist_str += f"{get_tool_name(item['id'])} x {item['num']}\n" cur.close() conn.close() yield event.plain_result(f"背包列表:\n{baglist_str}") From 3a6a6242aa8e95710236f171b17eda4f9909873d Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 17:29:05 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=83=8C=E5=8C=85bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index d8c134e..2b34fc1 100644 --- a/main.py +++ b/main.py @@ -148,10 +148,10 @@ class MyPlugin(Star): date = cur.fetchone() baglist = json.loads(date[0]) baglist_str = "" - if len(baglist) == 0: + if len(baglist["baglist"]) == 0: baglist_str = "背包空空如也" else: - for item in baglist: + for item in baglist["baglist"]: if get_tool_name(item["id"]) is None: cur.close() conn.close() From c5b7daa5d8101bd5886645c71d27c9c91924f62f Mon Sep 17 00:00:00 2001 From: Saipo Date: Sun, 27 Apr 2025 17:33:09 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=83=8C=E5=8C=85bug2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool.py b/Tool.py index 2c48e3d..0f40632 100644 --- a/Tool.py +++ b/Tool.py @@ -19,7 +19,7 @@ def get_tool_name(id): ,charset='utf8' # 字符编码 ) cur = conn.cursor() - sql = "SELECT name FROM tool WHERE id = %s" + sql = "SELECT name FROM dajiaotool WHERE id = %s" cur.execute(sql, (id,)) result = cur.fetchone() cur.close()