def set_custom_name(self, name: str or r.RTextBase): """设置名称, 在执行某些命令时替代@""" if isinstance(name, str): self.data['CustomName'] = r.RText(name).to_json_str() elif isinstance(name, r.RTextBase): self.data['CustomName'] = name.to_json_str() return self
def on_load(server, old): server.add_help_message( '!!bot', r.RText('显示机器人列表').c(r.RAction.run_command, '!!bot').h('点击显示机器人列表')) if not os.path.isfile(config_path): save() else: read()
def set_name(self, name: str or r.RTextBase): """ 设置物品名称 :param name: str或RTextBase """ if 'display' not in self.data.keys(): self.data['display'] = {} if isinstance(name, str): self.data['display']['Name'] = r.RText(name).to_json_str() elif isinstance(name, r.RTextBase): self.data['display']['Name'] = name.to_json_str() return self
def set_lore(self, *args: str or r.RTextBase): """ 设置物品信息 :param args: str或RTextBase """ if 'display' not in self.data.keys(): self.data['display'] = {} self.data['display']['Lore'] = [] for i in args: if isinstance(i, str): self.data['display']['Lore'].append(r.RText(i).to_json_str()) elif isinstance(i, r.RTextBase): self.data['display']['Lore'].append(i.to_json_str()) return self
def on_info(server, info): if info.is_user: if info.content.startswith(cp): if info.content.startswith(cp + "blbl"): args = info.content.split(" ") del (args[0]) on_command(server, info.player, args) else: vid = get_video_id(info.content) if vid is not None: message_checked = rtext.RText( "检测到您发送的信息是bilibili视频链接,是否要解析视频内容?", color=rtext.RColor.green) message_yes = rtext.RText("[是]", color=rtext.RColor.aqua, styles=[rtext.RStyle.bold]) message_yes.set_click_event(rtext.RAction.run_command, cp + "blbl video " + info.content) message_yes.set_hover_text("点击执行命令" + cp + "blbl video " + info.content) server.reply( info, rtext.RTextList(message_checked, rtext.RText(" "), message_yes))
def on_load(server, old): global bot_list server.add_help_message( f'{prefix_short}', r.RText('假人器械映射').c(r.RAction.run_command, f'{prefix_short}').h('点击查看帮助')) if old is not None and old.bot_list is not None: bot_list = old.bot_list else: bot_list = [] if not os.path.isfile(config_path): save() else: try: read() except Exception as e: server.say('§b[BotKikai]§4配置加载失败,请确认配置路径是否正确:{}'.format(e))
def operate_bot(server, info, args): global bot_dic, bot_list permission = server.get_permission_level(info) if len(args) == 1: # server.reply(info, help_msg) head = [help_head] body = [ r.RText(f'{k} {v}\n').c(r.RAction.suggest_command, k.replace('§b', '')).h(v) for k, v in help_body.items() ] server.reply(info, r.RTextList(*(head + body))) elif len(args) == 2: if args[1] == "list": c = [''] for name, bot_info in bot_dic.items(): if name in bot_list: bot_msg = r.RTextList( '\n' f'§7----------- §6{name} §a在线 §7 -----------\n', f'§7此假人用于:§6 {bot_info["nick"]}\n', # f'§7Dimension:§6 {bot_info["dim"]}\n', # r.RText( # f'§7Position:§6 {bot_info["pos"]}\n', ).c( # r.RAction.run_command, # '[x:{}, y:{}, z:{}, name:{}, dim{}]'.format( # *[int(i) for i in bot_info['pos']], name, bot_info['dim'])).h( # '点击显示可识别坐标点'), # f'§7Facing:§6 {bot_info["facing"]}\n', r.RText('§d[点击use] ').c( r.RAction.run_command, f'{prefix_short} {name} use').h(f'§6{name}§7右键一次'), r.RText('§d[点击下线] ').c( r.RAction.run_command, f'{prefix_short} {name} kill ').h(f'下线§6{name}'), r.RText('§d[查看详情] ').c( r.RAction.run_command, f'{prefix_short} {name}').h(f'显示§6{name}§r的详细信息')) else: bot_msg = r.RTextList( '\n' f'§7----------- §6{name} §4离线 §7 -----------\n', f'§7此假人用于:§6 {bot_info["nick"]}\n', # f'§7Dimension:§6 {bot_info["dim"]}\n', # r.RText( # f'§7Position:§6 {bot_info["pos"]}\n', ).c( # r.RAction.run_command, # '[x:{}, y:{}, z:{}, name:{}, dim{}]'.format( # *[int(i) for i in bot_info['pos']], name, bot_info['dim'])).h( # '点击显示可识别坐标点'), # f'§7Facing:§6 {bot_info["facing"]}\n', r.RText('§d[点击召唤] ').c( r.RAction.run_command, f'{prefix_short} {name} spawn').h(f'召唤§6{name}'), r.RText('§d[点击use] ').c( r.RAction.run_command, f'{prefix_short} {name} use ').h( f'召唤§6{name}§r并右键一次'), r.RText('§d[查看详情] ').c( r.RAction.run_command, f'{prefix_short} {name}').h(f'显示§6{name}§r的详细信息')) c.append(bot_msg) server.reply(info, r.RTextList(*c)) elif args[1] == "reload": try: read() server.say('§b[BotKikai]§a由玩家§d{}§a发起的BotKikai重载成功'.format( info.player)) except Exception as e: server.say('§b[BotKikai]§4由玩家§d{}§4发起的BotKikai重载失败:{}'.format( info.player, e)) elif search(args[1]): name = search(args[1]) if name not in bot_list: msg = r.RTextList( '\n' f'§7----------- §6{name} §4离线 §7-----------\n', f'§7此假人用于:§6 {bot_dic.get(name)["nick"]}\n', f'§7维度:§6 {bot_dic.get(name)["dim"]}\n', r.RText(f'§7坐标:§6 {bot_dic.get(name)["pos"]}\n', ).c( r.RAction.run_command, '[x:{}, y:{}, z:{}, name:{}, dim{}]'.format( *[int(i) for i in bot_dic.get(name)['pos']], name, bot_dic.get(name)['dim'])).h('点击显示可识别坐标点'), f'§7朝向:§6 {bot_dic.get(name)["facing"]}\n', r.RText('§d[点击召唤] ').c( r.RAction.run_command, f'{prefix_short} {name} spawn').h(f'召唤§6{name}'), r.RText('§d[点击use] ').c( r.RAction.run_command, f'{prefix_short} {name} use ').h(f'召唤§6{name}并右键一次')) else: msg = r.RTextList( '\n' f'§7----------- §6{name} §a在线 §7-----------\n', f'§7此假人用于:§6 {bot_dic.get(name)["nick"]}\n', f'§7维度:§6 {bot_dic.get(name)["dim"]}\n', r.RText(f'§7坐标:§6 {bot_dic.get(name)["pos"]}\n', ).c( r.RAction.run_command, '[x:{}, y:{}, z:{}, name:{}, dim{}]'.format( *[int(i) for i in bot_dic.get(name)['pos']], name, bot_dic.get(name)['dim'])).h('点击显示可识别坐标点'), f'§7朝向:§6 {bot_dic.get(name)["facing"]}\n', r.RText('§d[点击use] ').c( r.RAction.run_command, f'{prefix_short} {name} use').h(f'§6{name}§7右键一次'), r.RText('§d[点击下线] ').c( r.RAction.run_command, f'{prefix_short} {name} kill ').h(f'下线§6{name}')) server.reply(info, msg) else: server.reply(info, f"§b[BotKikai]§4未查询到§d{args[1]}§4对应的假人") elif len(args) == 3: if args[1] == "del" and permission >= permission_list: name = search(args[2]) if name: del bot_dic[name] bot_list.remove(name) if name in bot_list else bot_list save() server.reply(info, f'§b[BotKikai]§a已删除机器人{name}') else: server.reply(info, f"§b[BotKikai]§4未查询到§d{args[1]}§4对应的假人") else: name = search(args[1]) if name: if args[2] == "spawn" and permission >= permission_bot: if name not in bot_list: server.execute(spawn(server, info, name)) server.reply( info, f"§b[BotKikai]§a已创建假人§d{name}§6({args[1]})") else: server.reply( info, f"§b[BotKikai]§4假人§d{name}§6({args[1]})§4已经在线") elif args[2] == "kill" and permission >= permission_bot: if name in bot_list: server.execute(kill(name)) server.reply( info, f"§b[BotKikai]§a假人§d{name}§6({args[1]})§a已被下线") elif args[2] == "use" and permission >= permission_bot: if name not in bot_list: server.execute(spawn(server, info, name)) server.reply( info, f"§b[BotKikai]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(2) server.execute(use(name)) server.reply( info, f"§b[BotKikai]§a假人§d{name}§6({args[1]})§a右键一次") elif args[2] == "huse" and permission >= permission_bot: if name not in bot_list: server.execute(spawn(server, info, name)) server.reply( info, f"§b[BotKikai]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(2) server.execute(hold_use(name)) server.reply( info, f"§b[BotKikai]§a假人§d{name}§6({args[1]})§a持续右键") elif args[2] == "hatk" and permission >= permission_bot: if name not in bot_list: server.execute(spawn(server, info, name)) server.reply( info, f"§b[BotKikai]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(2) server.execute(hold_attack(name)) server.reply( info, f"§b[BotKikai]§a假人§d{name}§6({args[1]})§a持续左键") else: server.reply( info, f"§b[BotKikai]§4参数输入错误,输入§6{prefix_short}§4查看帮助信息") else: server.reply(info, f"§b[BotKikai]§4未查询到§d{args[1]}§4对应的假人") elif len(args) == 4: if args[1] == 'add' and permission >= permission_list: nick_ls = [] if bot_dic.get( args[2], None) is None else bot_dic.get(args[2])['nick'] if args[2] not in nick_ls: nick_ls.append(args[2]) nick_ls.append(args[3]) if args[3] != args[2] else nick_ls pos, dim, facing = get_pos(server, info) bot_dic[args[2]] = { 'nick': nick_ls, 'dim': dim, 'pos': pos, 'facing': f'{facing[0]} {facing[1]}' } save() server.reply(info, f'§b[BotKikai]§a已添加假人{args[2]}') else: server.reply(info, '§b[BotKikai]§4命令格式不正确或权限不足') elif len(args) == 10: if args[1] == 'add' and permission >= permission_list: if args[4] in dimension_convert.keys(): dim = dimension_convert[args[4]] pos = [int(i) for i in [args[5], args[6], args[7]]] facing = f'{args[8]} {args[9]}' nick_ls = [] if bot_dic.get( args[2], None) is None else bot_dic.get(args[2])['nick'] if args[2] not in nick_ls: nick_ls.append(args[2]) nick_ls.append(args[3]) if args[3] != args[2] else nick_ls bot_dic[args[2]] = { 'nick': nick_ls, 'dim': dim, 'pos': pos, 'facing': facing } save() server.reply(info, f'§b[BotKikai]§a已添加假人{args[2]}') else: server.reply(info, '§b[BotKikai]§4无法识别的维度') else: server.reply(info, '§b[BotKikai]§4命令格式不正确或权限不足')
def on_info(server, info): if info.is_user: if info.content.startswith(prefix) or info.content.startswith( prefix_short): global bot_dic, bot_list read() args = info.content.split(' ') if len(args) == 1: # server.reply(info, help_msg) head = [help_head] body = [ r.RText(f'{k} {v}\n').c(r.RAction.suggest_command, k.replace('§b', '')).h(v) for k, v in help_body.items() ] server.reply(info, r.RTextList(*(head + body))) elif len(args) == 2: if args[1] == "list": msg = ['\n', f'当前共有{len(bot_list)}个假人在线'] for name in bot_list: bot_info = r.RTextList( '\n' f'§7----------- §6{name}§7 -----------\n', f'§7此假人存放:§6 {bot_dic.get(name, "没有索引")}\n', # r.RText('§d[传送] ').c( # r.RAction.run_command, f'{prefix_short} {name} here').h(f'§7将§6{name}§7传送至身边'), r.RText('§d[罪人按钮] ').c( r.RAction.run_command, f'{prefix_short} {name} here').h( f'§4使用此功能你就会变成罪人'), r.RText('§d[扔出所有] ').c( r.RAction.run_command, f'{prefix_short} {name} all').h( f'§6{name}§7扔出身上所有物品'), r.RText('§d[扔出一个] ').c( r.RAction.run_command, f'{prefix_short} {name} one').h( f'§6{name}§7扔出一个物品'), r.RText('§d[扔出手中] ').c( r.RAction.run_command, f'{prefix_short} {name} handall').h( f'§6{name}§7扔出手中物品'), r.RText('§d[下线] ').c( r.RAction.run_command, f'{prefix_short} {name} kill').h( f'§7干掉§6{name}')) msg.append(bot_info) server.reply(info, r.RTextList(*msg)) elif args[1] == "reload": try: read() server.say( '§b[BotMono]§a由玩家§d{}§a发起的BotMono重载成功'.format( info.player)) except Exception as e: server.say( '§b[BotMono]§4由玩家§d{}§4发起的BotMono重载失败:{}'.format( info.player, e)) elif search(args[1]): if search(args[1]) not in bot_list: server.execute(spawn(server, info, search(args[1]))) bot_list.append(search(args[1])) else: server.reply( info, f"§b[BotMono]§4假人§d{search(args[1])}§6({args[1]})§4已经在线" ) else: server.reply(info, f"§b[BotMono]§4未查询到§d{args[1]}§4对应的假人") elif len(args) == 3: name = search(args[1]) if name: if args[2] == "spawn": if name not in bot_list: server.execute(spawn(server, info, name)) bot_list.append(name) else: server.reply( info, f"§b[Botmono]§4假人§d{name}§6({args[1]})§4已经在线") elif args[2] == "kill": if name in bot_list: server.execute(kill(name)) bot_list.remove(name) server.reply( info, f"§b[BotMono]§a假人§d{name}§6({args[1]})§a已被下线") elif args[2] == "here": if name in bot_list: # server.execute(f"/tp {name} {info.player}") server.reply(info, f"§b[BotMono]§4停用了,我可不想当罪人") else: server.reply( info, f"§b[BotMono]§4假人§d{name}§6({args[1]})§4不在线") elif args[2] == "one": if name not in bot_list: server.execute(spawn(server, info, name)) bot_list.append(name) server.reply( info, f"§b[BotMono]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(1) server.execute(drop_one(name)) server.reply( info, f"§b[BotMono]§a假人§d{name}§6({args[1]})§a扔出1个物品") elif args[2] == "all": if name not in bot_list: server.execute(spawn(server, info, name)) bot_list.append(name) server.reply( info, f"§b[BotMono]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(1) server.execute(drop_all(name)) server.reply( info, f"§b[BotMono]§a假人§d{name}§6({args[1]})§a扔出身上所有物品") elif args[2] == "handall": if name not in bot_list: server.execute(spawn(server, info, name)) bot_list.append(name) server.reply( info, f"§b[BotMono]§a已自动创建假人§d{name}§6({args[1]})") time.sleep(1) server.execute(drop_handall(name)) server.reply( info, f"§b[BotMono]§a假人§d{name}§6({args[1]})§a扔出手中所有物品") else: server.reply( info, f"§b[BotMono]§4参数输入错误,输入§6{prefix_short}§4查看帮助信息") else: server.reply(info, f"§b[BotMono]§4未查询到§d{args[1]}§4对应的假人")
def on_command(server, player, args): if len(args) == 0: server.execute("tellraw " + player + " {\"text\":\"参数错误,请使用 " + cp + "blbl help 获取帮助\", \"color\":\"red\"}") return if args[0].lower() == "video": # 检查命令参数 if len(args) != 2: server.execute("tellraw " + player + " {\"text\":\"参数错误,请使用 " + cp + "blbl help 获取帮助\", \"color\":\"red\"}") return # 获取视频id vid = get_video_id(args[1]) if vid is None: server.execute( "tellraw " + player + " {\"text\":\"这不是bilibili视频id或链接\", \"color\":\"red\"}") return if "bv" in vid.lower(): response = requests.get( "https://api.bilibili.com/x/web-interface/view?byid=" + vid) else: response = requests.get( "https://api.bilibili.com/x/web-interface/view?aid=" + vid) # 判断是否成功获取 if response.status_code != 200: server.execute("tellraw " + player + " {\"text\":\"网络连接错误,请稍后重试,错误码: " + str(response.status_code) + "\", \"color\":\"red\"}") return result = response.json() if result["code"] == 0: # 获取的code为0冇表示问题 message = rtext.RText("========视频信息获取成功========\n", color=rtext.RColor.green, styles=[rtext.RStyle.bold]) # av bv号和打开链接 message_avtitle = rtext.RText("AV号: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold]) message_av = rtext.RText("av" + str(result["data"]["aid"]), color=rtext.RColor.green) message_avlink = rtext.RText("[打开链接]", color=rtext.RColor.aqua) message_avlink.set_click_event( rtext.RAction.open_url, "http://www.bilibili.com/video/av" + str(result["data"]["aid"])) message_avlink.set_hover_text( "打开链接: http://www.bilibili.com/video/av" + str(result["data"]["aid"])) message_bvtitle = rtext.RText("\nBV号: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold]) message_bv = rtext.RText(result["data"]["bvid"], color=rtext.RColor.green) message_bvlink = rtext.RText("[打开链接]", color=rtext.RColor.aqua) message_bvlink.set_click_event( rtext.RAction.open_url, "http://www.bilibili.com/video/" + str(result["data"]["bvid"])) message_bvlink.set_hover_text( "打开链接: http://www.bilibili.com/video/" + str(result["data"]["bvid"])) message = rtext.RTextList(message, message_avtitle, message_av, message_avlink, message_bvtitle, message_bv, message_bvlink, rtext.RText("\n")) # 标题信息 message = rtext.RTextList( message, rtext.RText("标题: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(result["data"]["title"] + "\n", color=rtext.RColor.green)) # 封面信息 message = rtext.RTextList( message, rtext.RText("封面: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message_pic = rtext.RText("[查看图片]" + "\n", color=rtext.RColor.aqua) message_pic.set_click_event(rtext.RAction.open_url, result["data"]["pic"]) message_pic.set_hover_text("打开链接: " + result["data"]["pic"]) message = rtext.RTextList(message, message_pic) # 发布日期 message = rtext.RTextList( message, rtext.RText("发布日期: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(result["data"]["pubdate"])) + "\n", color=rtext.RColor.green)) # 简介 result["data"]["desc"] = result["data"]["desc"].replace( "\n", " \n") if len(result["data"]["desc"]) <= 60: message_desc = rtext.RText(result["data"]["desc"] + "\n", color=rtext.RColor.green) else: message_desc = rtext.RText(result["data"]["desc"][0:59] + "……", color=rtext.RColor.green) message_show_full_desc = rtext.RText("[查看完整简介]\n", color=rtext.RColor.aqua) message_show_full_desc.set_hover_text(result["data"]["desc"]) message_desc = rtext.RTextList(message_desc, message_show_full_desc) message = rtext.RTextList( message, rtext.RText("简介: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold]), message_desc) # 播放量 message = rtext.RTextList( message, rtext.RText("播放量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["view"]) + "\n", color=rtext.RColor.green)) # 弹幕总量 message = rtext.RTextList( message, rtext.RText("弹幕总量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["danmaku"]) + "\n", color=rtext.RColor.green)) # 点赞数量 message = rtext.RTextList( message, rtext.RText("点赞数量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["like"]) + "\n", color=rtext.RColor.green)) # 收获硬币 message = rtext.RTextList( message, rtext.RText("收获硬币: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["coin"]) + "\n", color=rtext.RColor.green)) # 收藏数量 message = rtext.RTextList( message, rtext.RText("收藏数量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["favorite"]) + "\n", color=rtext.RColor.green)) # 转发数量 message = rtext.RTextList( message, rtext.RText("转发数量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["share"]) + "\n", color=rtext.RColor.green)) # 评论数量 message = rtext.RTextList( message, rtext.RText("评论数量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(result["data"]["stat"]["reply"]) + "\n", color=rtext.RColor.green)) # 分part数量 message = rtext.RTextList( message, rtext.RText("分part数量: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(str(len(result["data"]["pages"])) + "\n", color=rtext.RColor.green)) # up主 message = rtext.RTextList( message, rtext.RText("投稿人: ", color=rtext.RColor.blue, styles=[rtext.RStyle.bold])) message = rtext.RTextList( message, rtext.RText(result["data"]["owner"]["name"], color=rtext.RColor.green)) message_owner_link = rtext.RText("[打开个人主页]", color=rtext.RColor.aqua) message_owner_link.set_click_event( rtext.RAction.open_url, "http://space.bilibili.com/" + str(result["data"]["owner"]["mid"])) message_owner_link.set_hover_text( "打开链接: http://space.bilibili.com/" + str(result["data"]["owner"]["mid"])) message = rtext.RTextList(message, message_owner_link) server.say(message) else: server.execute("tellraw " + player + " {\"text\":\"Error发生,错误信息: " + result["message"].replace("\"", "\\\"") + "\", \"color\":\"red\"}") elif args[0].lower() == "checkupdate": updateDetectionThread = updateDetection(server, player) updateDetectionThread.setDaemon(True) updateDetection.start(updateDetectionThread) elif args[0].lower() == "help": server.execute("tellraw " + player + " {\"text\":\"" + helpmessage.replace("\"", "\\\"") + "\"}") else: server.execute("tellraw " + player + " {\"text\":\"参数错误,请使用 " + cp + "blbl help 获取帮助\", \"color\":\"red\"}")
def summon_bot(server, info, arg): global bot_list permission = server.get_permission_level(info) if len(arg) == 1: c = [''] for a, b in bot_list.items(): bot_info = r.RTextList( '\n' f'§7----------- §6{a}§7 -----------\n', f'§7Dimension:§6 {b["dim"]}\n', r.RText(f'§7Position:§6 {b["pos"]}\n', ).c( r.RAction.run_command, '[x:{}, y:{}, z:{}, name:{}, dim{}]'.format( *[int(i) for i in b['pos']], a, b['dim'])).h('点击显示可识别坐标点'), f'§7Facing:§6 {b["facing"]}\n', r.RText('§d点击放置\n').c(r.RAction.run_command, f'!!bot spawn {a}').h(f'放置§6{a}'), r.RText('§d点击移除\n').c(r.RAction.run_command, f'!!bot kill {a}').h(f'移除§6{a}')) c.append(bot_info) server.reply(info, r.RTextList(*c)) elif len(arg) == 2: if arg[1] == 'help': c = [ r.RText(f'{a} {b}\n').c(r.RAction.suggest_command, a.replace('§6', '')).h(b) for a, b in help_msg.items() ] server.reply(info, r.RTextList(*c)) elif arg[1] == 'reload' and permission >= 3: read() server.reply(info, '§a已从配置文件重新载入机器人列表') else: server.reply(info, '§c命令格式不正确或权限不足') elif len(arg) == 3: if arg[1] == 'spawn' and permission >= 1: if arg[2] in bot_list.keys(): server.execute(spawn_command(arg[2])) else: server.reply(info, '§c机器人名称不正确') elif arg[1] == 'kill' and permission >= 1: if arg[2] in bot_list.keys(): server.execute(f'player {arg[2]} kill') else: server.reply(info, '§c机器人名称不正确') elif arg[1] == 'remove' and permission >= 2: if arg[2] in bot_list.keys(): del bot_list[arg[2]] save() server.reply(info, f'§a已删除机器人{arg[2]}') else: server.reply(info, '§c机器人名称不正确') else: server.reply(info, '§c命令格式不正确或权限不足') elif len(arg) == 9: if arg[1] == 'add' and permission >= 3: if arg[3] in dimension_convert.keys(): dim = dimension_convert[arg[3]] pos = [int(i) for i in [arg[4], arg[5], arg[6]]] facing = f'{arg[7]} {arg[8]}' bot_list[arg[2]] = {'dim': dim, 'pos': pos, 'facing': facing} save() server.reply(info, f'§a已添加机器人{arg[2]}') else: server.reply(info, '§c无法识别的维度') else: server.reply(info, '§c命令格式不正确或权限不足')