Skip to content

Commit

Permalink
Merge pull request #84 from MyXiaoNan/dev
Browse files Browse the repository at this point in the history
合并 Dev 改动
  • Loading branch information
PackageInstaller authored Nov 22, 2024
2 parents 67d4049 + 739639f commit d26a805
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 197 deletions.
4 changes: 0 additions & 4 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_back/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,6 @@ async def main_back_(bot: Bot, event: GroupMessageEvent):
try:
await send_msg_handler(bot, event, '背包', bot.self_id, msg1)
if msg2:
# 如果有第三条及以后的消息,需要等待一段时间再发送,避免触发限制
await asyncio.sleep(1)
await send_msg_handler(bot, event, '背包', bot.self_id, msg2)
except ActionFailed:
await main_back.finish("查看背包失败!", reply_message=True)
Expand All @@ -1075,11 +1073,9 @@ async def main_back_(bot: Bot, event: GroupMessageEvent):
await send_msg_handler(bot, event, '背包', bot.self_id, msg)
except ActionFailed:
await main_back.finish("查看背包失败!", reply_message=True)

await main_back.finish()



@no_use_zb.handle(parameterless=[Cooldown(at_sender=False)])
async def no_use_zb_(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg()):
"""卸载物品(只支持装备)
Expand Down
143 changes: 57 additions & 86 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_back/back_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,62 @@ def get_user_main_back_msg(user_id):
获取背包内的所有物品信息
"""
l_equipment_msg = []
l_skill_msg = []
l_elixir_msg = []
l_shenwu_msg = []
l_xiulianitem_msg = []
l_ldl_msg = []
l_yaocai_msg = []
l_libao_msg = []
l_msg = []
user_backs = sql_message.get_back_msg(user_id) # list(back)
if user_backs is None:
return l_msg
for user_back in user_backs:
if user_back['goods_type'] == "装备":
l_equipment_msg = get_equipment_msg(l_equipment_msg, user_id, user_back['goods_id'], user_back['goods_num'])
l_equipment_msg = get_equipment_msg(l_equipment_msg, user_id, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "技能":
l_skill_msg = get_skill_msg(l_skill_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "丹药":
l_elixir_msg = get_elixir_msg(l_elixir_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "神物":
l_shenwu_msg = get_shenwu_msg(l_shenwu_msg, user_back['goods_id'], user_back['goods_num'])
l_shenwu_msg = get_shenwu_msg(l_shenwu_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "聚灵旗":
l_xiulianitem_msg = get_jlq_msg(l_xiulianitem_msg, user_back['goods_id'], user_back['goods_num'])
l_xiulianitem_msg = get_jlq_msg(l_xiulianitem_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "炼丹炉":
l_ldl_msg = get_ldl_msg(l_ldl_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "药材":
l_yaocai_msg = get_yaocai_msg(l_yaocai_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

elif user_back['goods_type'] == "礼包":
l_libao_msg = get_libao_msg(l_libao_msg, user_back['goods_id'], user_back['goods_num'])
l_libao_msg = get_libao_msg(l_libao_msg, user_back['goods_id'], user_back['goods_num'], user_back['bind_num'])

if l_equipment_msg:
l_msg.append("☆------我的装备------☆")
for msg in l_equipment_msg:
l_msg.append(msg)

if l_skill_msg:
l_msg.append("☆------拥有技能书------☆")
for msg in l_skill_msg:
l_msg.append(msg)

if l_ldl_msg:
l_msg.append("☆------炼丹炉------☆")
for msg in l_ldl_msg:
l_msg.append(msg)

if l_elixir_msg:
l_msg.append("☆------我的丹药------☆")
for msg in l_elixir_msg:
l_msg.append(msg)

if l_shenwu_msg:
l_msg.append("☆------神物------☆")
for msg in l_shenwu_msg:
Expand All @@ -171,6 +202,11 @@ def get_user_main_back_msg(user_id):
l_msg.append("☆------修炼物品------☆")
for msg in l_xiulianitem_msg:
l_msg.append(msg)

if l_yaocai_msg:
l_msg.append("☆------拥有药材------☆")
for msg in l_yaocai_msg:
l_msg.append(msg)

if l_libao_msg:
l_msg.append("☆------礼包------☆")
Expand All @@ -179,115 +215,50 @@ def get_user_main_back_msg(user_id):
return l_msg


def get_user_elixir_back_msg(user_id):
"""
获取背包内的丹药信息
"""
l_elixir_msg = []
l_ldl_msg = []
l_msg = []
user_backs = sql_message.get_back_msg(user_id) # list(back)
if user_backs is None:
return l_msg
for user_back in user_backs:
if user_back['goods_type'] == "丹药":
l_elixir_msg = get_elixir_msg(l_elixir_msg, user_back['goods_id'], user_back['goods_num'])
elif user_back['goods_type'] == "炼丹炉":
l_ldl_msg = get_ldl_msg(l_ldl_msg, user_back['goods_id'], user_back['goods_num'])

if l_ldl_msg:
l_msg.append("☆------炼丹炉------☆")
for msg in l_ldl_msg:
l_msg.append(msg)

if l_elixir_msg:
l_msg.append("☆------我的丹药------☆")
for msg in l_elixir_msg:
l_msg.append(msg)
return l_msg

def get_libao_msg(l_msg, goods_id, goods_num):
def get_libao_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的礼包信息
"""
item_info = items.get_data_by_item_id(goods_id)
msg = f"名字:{item_info['name']}\n"
msg += f"拥有数量:{goods_num}"
msg += f"拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg

def get_user_skill_back_msg(user_id):
"""
获取背包内的技能信息
"""
l_skill_msg = []
l_msg = []
user_backs = sql_message.get_back_msg(user_id) # list(back)
if user_backs is None:
return l_msg
for user_back in user_backs:
if user_back['goods_type'] == "技能":
l_skill_msg = get_skill_msg(l_skill_msg, user_back['goods_id'], user_back['goods_num'])
if l_skill_msg:
l_msg.append("☆------拥有技能书------☆")
for msg in l_skill_msg:
l_msg.append(msg)
return l_msg


def get_user_yaocai_back_msg(user_id):
"""
获取背包内的药材信息
"""
l_yaocai_msg = []
l_msg = []
user_backs = sql_message.get_back_msg(user_id) # list(back)
if user_backs is None:
return l_msg
for user_back in user_backs:
if user_back['goods_type'] == "药材":
l_yaocai_msg = get_yaocai_msg(l_yaocai_msg, user_back['goods_id'], user_back['goods_num'])

if l_yaocai_msg:
l_msg.append("☆------拥有药材------☆")
for msg in l_yaocai_msg:
l_msg.append(msg)
return l_msg


def get_yaocai_msg(l_msg, goods_id, goods_num):
def get_yaocai_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的药材信息
"""
item_info = items.get_data_by_item_id(goods_id)
msg = f"名字:{item_info['name']}\n"
msg += f"品级:{item_info['level']}\n"
msg += get_yaocai_info(item_info)
msg += f"\n拥有数量:{goods_num}"
msg += f"\n拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg


def get_jlq_msg(l_msg, goods_id, goods_num):
def get_jlq_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的修炼物品信息,聚灵旗
"""
item_info = items.get_data_by_item_id(goods_id)
msg = f"名字:{item_info['name']}\n"
msg += f"效果:{item_info['desc']}"
msg += f"\n拥有数量:{goods_num}"
msg += f"\n拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg


def get_ldl_msg(l_msg, goods_id, goods_num):
def get_ldl_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的炼丹炉信息
"""
item_info = items.get_data_by_item_id(goods_id)
msg = f"名字:{item_info['name']}\n"
msg += f"效果:{item_info['desc']}"
msg += f"\n拥有数量:{goods_num}"
msg += f"\n拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg

Expand All @@ -308,7 +279,7 @@ def get_yaocai_info(yaocai_info):
return msg


def get_equipment_msg(l_msg, user_id, goods_id, goods_num):
def get_equipment_msg(l_msg, user_id, goods_id, goods_num, bind_num):
"""
获取背包内的装备信息
"""
Expand All @@ -318,7 +289,7 @@ def get_equipment_msg(l_msg, user_id, goods_id, goods_num):
msg = get_armor_info_msg(goods_id, item_info)
elif item_info['item_type'] == '法器':
msg = get_weapon_info_msg(goods_id, item_info)
msg += f"\n拥有数量:{goods_num}"
msg += f"\n拥有数量:{goods_num},绑定数量:{bind_num}"
is_use = check_equipment_use_msg(user_id, goods_id)
if is_use:
msg += f"\n已装备"
Expand All @@ -328,7 +299,7 @@ def get_equipment_msg(l_msg, user_id, goods_id, goods_num):
return l_msg


def get_skill_msg(l_msg, goods_id, goods_num):
def get_skill_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的技能信息
"""
Expand All @@ -343,35 +314,35 @@ def get_skill_msg(l_msg, goods_id, goods_num):
elif item_info['item_type'] == '辅修功法':#辅修功法12
msg = f"{item_info['level']}辅修功法-"
msg += get_sub_info_msg(goods_id)[1]
msg += f"\n拥有数量:{goods_num}"
msg += f"\n拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg


def get_elixir_msg(l_msg, goods_id, goods_num):
def get_elixir_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的丹药信息
"""
item_info = items.get_data_by_item_id(goods_id)
msg = f"名字:{item_info['name']}\n"
msg += f"效果:{item_info['desc']}\n"
msg += f"拥有数量:{goods_num}"
msg += f"拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg

def get_shenwu_msg(l_msg, goods_id, goods_num):
def get_shenwu_msg(l_msg, goods_id, goods_num, bind_num):
"""
获取背包内的神物信息
"""
item_info = items.get_data_by_item_id(goods_id)
try:
desc = item_info['desc']
except KeyError:
desc = "这个东西本来会报错让背包出不来,当你看到你背包有这个这个东西的时候请联系超管解决。"
desc = "十分神秘的东西,谁也不知道它的作用"

msg = f"名字:{item_info['name']}\n"
msg += f"效果:{desc}\n"
msg += f"拥有数量:{goods_num}"
msg += f"拥有数量:{goods_num},绑定数量:{bind_num}"
l_msg.append(msg)
return l_msg

Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_xiuxian_2/xiuxian/xiuxian_boss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def save_user_boss_fight_info(user_id, data):
user_id = str(user_id)

if not os.path.exists(PLAYERSDATA / user_id):
logger.opt(colors=True).info("<red>目录不存在,创建目录</green>")
logger.opt(colors=True).info("<green>目录不存在,创建目录</green>")
os.makedirs(PLAYERSDATA / user_id)

FILEPATH = PLAYERSDATA / user_id / "boss_fight_info.json"
Expand Down
4 changes: 0 additions & 4 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_buff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
number_to, check_user, send_msg_handler,
check_user_type, get_msg_pic, CommandObjectID
)
from ..xiuxian_back.back_util import get_user_skill_back_msg
from ..xiuxian_utils.lay_out import assign_bot, Cooldown
from .two_exp_cd import two_exp_cd

Expand Down Expand Up @@ -962,7 +961,6 @@ async def buffinfo_(bot: Bot, event: GroupMessageEvent):
await buffinfo.finish()

user_id = user_info['user_id']
skill_msg = get_user_skill_back_msg(user_id)
mainbuffdata = UserBuffDate(user_id).get_user_main_buff_data()
if mainbuffdata != None:
s, mainbuffmsg = get_main_info_msg(str(get_user_buff(user_id)['main_buff']))
Expand All @@ -984,15 +982,13 @@ async def buffinfo_(bot: Bot, event: GroupMessageEvent):
{subbuffmsg}
道友的神通:{secbuffdata["name"] if secbuffdata != None else '无'}
{secbuffmsg}
道友背包内的功法,辅修功法,神通等信息将在下一条消息展示:
"""

if XiuConfig().img:
pic = await get_msg_pic(f"@{event.sender.nickname}\n" + msg)
await bot.send_group_msg(group_id=int(send_group_id), message=MessageSegment.image(pic))
else:
await bot.send_group_msg(group_id=int(send_group_id), message=msg)
await send_msg_handler(bot, event, '背包', bot.self_id, skill_msg)
await buffinfo.finish()


Expand Down
11 changes: 5 additions & 6 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ def __init__(self):
self.twolun_min_level = "祭道境圆满" # 万世轮回最低境界
self.del_boss_id = [] # 支持非管理员和超管天罚boss
self.gen_boss_id = [] # 支持非管理员和超管生成boss
self.merge_forward_send = False # 消息合并转发,True是合并转发,False是长图发送,建议长图发送
self.img_compression_limit = 90 # 图片压缩率,0为不压缩,最高100
self.img_type = "webp" # 图片类型,webp或者jpeg,如果机器人的图片消息不显示请使用jpeg,jpeg请调低压缩率
self.img_send_type = "io" # 图片发送类型,默认io,官方bot建议base64
self.merge_forward_send = True # 使用消息合并转发,True是合并转发,False是合并转发的内容转换成长图发送
self.img_compression_limit = 90 # 图片压缩率,0为不压缩,最高100,jpeg请调低压缩率
self.img_type = "webp" # 图片类型,webp或者jpeg,如果机器人的图片消息不显示请使用jpeg
self.img_send_type = "io" # 图片发送类型官方bot建议base64
self.admin_debug = False # 管理员调试模式,开启后只响应超管指令
self.version = "xiuxian_2.2" # 修仙插件版本,别动

Expand Down Expand Up @@ -158,14 +158,13 @@ def write_data(self, key, group_id=None):
logger.opt(colors=True).info("<red>未知key</red>")
return False

# 去重
json_data['group'] = list(set(json_data['group']))

with open(self.config_jsonpath, 'w', encoding='utf-8') as f:
json.dump(json_data, f, ensure_ascii=False, indent=4)


def get_enabled_groups(self):
"""获取开启修仙功能的群聊列表,去除重复项"""
"""获取开启修仙功能的群聊列表"""
data = self.read_data()
return list(set(data.get("group", [])))
7 changes: 3 additions & 4 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_fusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..xiuxian_utils.utils import (
check_user, get_msg_pic, number_to
)
sql_message = XiuxianDateManage() # sql类
sql_message = XiuxianDateManage()
items = Items()

fusion_help_text = f"""
Expand Down Expand Up @@ -132,7 +132,6 @@ async def fusion_(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg
await bot.send_group_msg(group_id=int(send_group_id), message=msg)
await fusion.finish()

# 检查数量
needed_items = fusion_info.get('need_item', {})
missing_items = []
for item_id, amount_needed in needed_items.items():
Expand All @@ -153,9 +152,9 @@ async def fusion_(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg
await bot.send_group_msg(group_id=int(send_group_id), message=msg)
await fusion.finish()

sql_message.update_user_stone(user_id, required_stone, 2)
sql_message.update_ls(user_id, required_stone, 2) # 扣灵石
for item_id, amount_needed in needed_items.items():
sql_message.update_back_j(user_id, int(item_id), amount_needed)
sql_message.update_back_j(user_id, int(item_id), amount_needed) # 扣道具

sql_message.send_back(user_id, int(equipment_id), equipment['name'], equipment['type'], 1, 1)

Expand Down
Loading

0 comments on commit d26a805

Please sign in to comment.