simplify this: bot.on('chat', (username, message) => { if ((username === 'lseven7l'…
- User
simplify this: bot.on('chat', (username, message) => { if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message === '!Long_bot帮助') { bot.chat(
/msg ${username} 在每个指令前面加个!,指令:AddBlacklist 玩家名字(添加至黑名单)|UnBlacklist 玩家名字(移除黑名单)|!Long_bot tp|blacklist); }}) bot.on('chat', (username, message) => { if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message === '!Long_bot tp') { bot.chat(正在tp ${username}); bot.chat(/tpa ${username}); }}) function handleChat(username, message) { if (username === bot.username){ return; } if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message.includes('!AddBlacklist ')) { if (username === bot.username) return; const usernameToAdd = message.split('!AddBlacklist ')[1]; if (blacklist.includes(usernameToAdd)) { bot.chat(${usernameToAdd}已经在黑名单里了); } else { blacklist.push(usernameToAdd); bot.chat(已将${usernameToAdd}添加至黑名单); fs.writeFileSync('blacklist.json', JSON.stringify(blacklist)); } return; } if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message.includes('!UnBlacklist ')) { if (username === bot.username) return; const usernameToRemove = message.split('!UnBlacklist')[1]; const index = blacklist.indexOf(usernameToRemove); if (index !== -1) { blacklist.splice(index, 1); bot.chat(已将${usernameToRemove}移出黑名单); fs.writeFileSync('blacklist.json', JSON.stringify(blacklist)); } else { bot.chat(${usernameToRemove}不在黑名单中); } return; } if (message.includes('!规则')) { bot.chat(/msg ${username} 1. 禁止使用机器人刷屏); bot.chat(/msg ${username} 2. 请勿使用机器人bug,如果发现可找Yokomi/llseven7ll提供反馈,当bug被证实后,即可奖励至少5w游戏币(根据漏洞大小调节,最大50w)); bot.chat(/msg ${username} 如果违规以上规则, 拉入黑名单,即ban机器人+所有泷拥有admin的领地); } else if (message.includes('!help')) { bot.chat(/msg ${username} 请在每个指令添加!,千万别忘了,您可以使用的指令为:规则|萌新小助手|作者信息|服务器信息|如何搬砖|tps|); } else if (message.includes('!萌新小助手')) { bot.chat(/msg ${username} 请在聊天框内输入"如何搬砖"或"如何赚钱"即可获取搬砖/赚钱方法, 在聊天框内输入"游玩方法"即可获取本服务器游玩方法); } else if (message.includes('!作者信息')) { bot.chat(/msg ${username} 作者:Yokomi_|云服务器提供者:lseven7l|正版号提供者:Stevexzx|赞助:Yokomi_); } else if (message.includes('!服务器信息')) { bot.chat(/msg ${username} 本服务器为生存+mcmmo,可开挂,但是容易被踢,不会被Ban); } else if (message.includes('!如何搬砖')) { bot.chat(/msg ${username} res tp tm,或者其他领地,购买皮革,之后/warp shop卖掉,每个皮革可赚0.7游戏币); } else if (message.includes('!tps')) { bot.chat(/msg ${username} 当前tps为:+ bot.getTps()); } else if (username === 'Yokomi_' && message.includes('Long_bot')) { if (message.includes('!Long_bot')) { return; } else { bot.chat('主人好, (๑´0๑), 有什么可以帮到您的么?'); } } else if (username === 'lseven7l' && message.includes('Long_bot')) { if (message.includes('!Long_bot')) { return; } else { bot.chat('叫本女仆干什么??你没事叫我干什么,闲得慌?'); } } else if (username === 'Yokomi_' && message === '!女仆tp') { bot.chat('主人,正在传送₍ᐢ •͈ ༝ •͈ ᐢ₎♡'); bot.chat('/tpa Yokomi_'); } else if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message === '!权限帮助') { bot.chat(/msg {username} 输入:!ATTC帮助|!Bz帮助|!Long_bot帮助`); } else if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message === '!ATTC帮助') { bot.chat(`/msg {username} !ATTC重启|!开启打怪模式|!关闭打怪模式|!机器人去xxx (xxx改为领地名)|!tp (tp 你)|(注:ATTC自动开启打怪模式)); } else if ((username === 'lseven7l' || username === 'Stevexzx'|| username === 'Yokomi_') && message === '!Bz帮助') { bot.chat(/msg {username} !开启搬砖 (注:Bz会自动开启搬砖,这个指令没必要)|!pay me xxx (xxx改为金额,机器人就会给你这么多,不要有小数点)`); } else if (message.includes('石头')) { bot.chat(`res tp tm 全系石头0.01 平滑/石头/圆石`); } else if (message.includes('吃')) { bot.chat(`res tp tm白嫖免费食物`); } else if (message.includes('食物')) { bot.chat(`res tp tm白嫖免费食物`); } else if (message.includes('铁')) { bot.chat(`res tp tm 全服最低价铁锭 仅需0.99/个`); } else if ((username === 'Yokomi_' || username === 'lseven7l' || username === 'Stevexzx') && (message === '!blacklist')) { const blacklistData = fs.readFileSync('blacklist.json'); const blacklist = JSON.parse(blacklistData); const blacklistString = blacklist.join(', '); bot.chat(`黑名单列表: {blacklistString}); } if (blacklist.includes(username)) { return; } } bot.on('chat', (username, message) => { handleChat(username, message); }) bot.on('message', (message) => { const messageText = message.toString(); const receivedMoneyPattern = /^从(.*)收到了\$(\d+(.\d{1,2})?)。/; const match = messageText.match(receivedMoneyPattern); if (match) { const username = match[1]; const amount = match[2]; bot.chat(感谢${username}赞助的$${amount}`); } }); - Assistant
The code sets up various chat commands for a bot in a Minecraft server. These commands include adding and removing players from a blacklist, displaying server rules and information, providing gameplay tips, and responding to specific messages. Additionally, the code handles incoming messages to the bot, including thanking users for donations.