Compare commits
No commits in common. "a7f5ce1991555bb24be0bb8892461f35f4c69dde" and "83be3a9579c12054a27d342f398b26402320cc30" have entirely different histories.
a7f5ce1991
...
83be3a9579
26
Tool.py
26
Tool.py
@ -1,31 +1,9 @@
|
|||||||
import pymysql
|
|
||||||
|
|
||||||
class Tool:
|
class Tool:
|
||||||
id = 0
|
id = 0
|
||||||
name = ""
|
name = ""
|
||||||
typeid = 0
|
typeid = 0
|
||||||
|
|
||||||
def __init__(self, id, typeid):
|
def __init__(self, id, name, typeid):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.name = name
|
||||||
self.typeid = typeid
|
self.typeid = typeid
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_tool_name(id):
|
|
||||||
conn=pymysql.connect(host = '192.168.31.9' # 连接名称,默认
|
|
||||||
,user = 'saipo'
|
|
||||||
,passwd='Grasste0403' # 密码
|
|
||||||
,port= 3306 # 端口,默认为3306
|
|
||||||
,db='saipo' # 数据库名称
|
|
||||||
,charset='utf8' # 字符编码
|
|
||||||
)
|
|
||||||
cur = conn.cursor()
|
|
||||||
sql = "SELECT name FROM tool WHERE id = %s"
|
|
||||||
cur.execute(sql, (id,))
|
|
||||||
result = cur.fetchone()
|
|
||||||
cur.close()
|
|
||||||
conn.close()
|
|
||||||
if result:
|
|
||||||
return result[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
35
main.py
35
main.py
@ -1,5 +1,3 @@
|
|||||||
import json
|
|
||||||
import Tool
|
|
||||||
from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult
|
from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult
|
||||||
from astrbot.api.star import Context, Star, register
|
from astrbot.api.star import Context, Star, register
|
||||||
from astrbot.api import logger
|
from astrbot.api import logger
|
||||||
@ -130,39 +128,6 @@ class MyPlugin(Star):
|
|||||||
conn.close()
|
conn.close()
|
||||||
yield event.plain_result(f"昵称修改成功!\n新的昵称为:{name}")
|
yield event.plain_result(f"昵称修改成功!\n新的昵称为:{name}")
|
||||||
|
|
||||||
|
|
||||||
@filter.command("我的背包")
|
|
||||||
async def bag(self, event: AstrMessageEvent):
|
|
||||||
if isUserExist(event.get_sender_id()) != True:
|
|
||||||
insertUser(event.get_sender_id())
|
|
||||||
conn=pymysql.connect(host = '192.168.31.9' # 连接名称,默认
|
|
||||||
,user = 'saipo'
|
|
||||||
,passwd='Grasste0403' # 密码
|
|
||||||
,port= 3306 # 端口,默认为3306
|
|
||||||
,db='saipo' # 数据库名称
|
|
||||||
,charset='utf8' # 字符编码
|
|
||||||
)
|
|
||||||
cur = conn.cursor()
|
|
||||||
sql = "SELECT baglist FROM dajiaouser WHERE openid = %s"
|
|
||||||
openid = event.get_sender_id()
|
|
||||||
cur.execute(sql,(openid,))
|
|
||||||
date = cur.fetchone()
|
|
||||||
baglist = json.loads(date[0])
|
|
||||||
baglist_str = ""
|
|
||||||
if len(baglist) == 0:
|
|
||||||
baglist_str = "背包空空如也"
|
|
||||||
else:
|
|
||||||
for item in baglist:
|
|
||||||
if Tool.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"
|
|
||||||
cur.close()
|
|
||||||
conn.close()
|
|
||||||
yield event.plain_result(f"背包列表:\n{baglist_str}")
|
|
||||||
|
|
||||||
@filter.command("跟我念")
|
@filter.command("跟我念")
|
||||||
async def test(self, event: AstrMessageEvent, name: str):
|
async def test(self, event: AstrMessageEvent, name: str):
|
||||||
yield event.plain_result(f"{name}")
|
yield event.plain_result(f"{name}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user