vanish support (credits to aaa) and somewhat working filter. v6.0.3 build: 1025

This commit is contained in:
Parker2991 2024-09-25 12:20:07 -04:00
parent 2a812961e1
commit 648f4431d7
20 changed files with 145 additions and 23 deletions

1
src/[""] Normal file
View file

@ -0,0 +1 @@
["",{"ignoreCase":false,"name":"amogus"}]

1
src/[] Normal file
View file

@ -0,0 +1 @@
[{"ignoreCase":false,"name":"amogus"}]

1
src/[] Normal file
View file

@ -0,0 +1 @@
[{"ignoreCase":false,"name":"amogus"}]

View file

@ -0,0 +1 @@
[{"ignoreCase":false,"name":"amogus"},"reee"]

1
src/[{}] Normal file
View file

@ -0,0 +1 @@
[{},{"ignoreCase":false,"name":"amogus"}]

View file

@ -25,7 +25,8 @@ function createBot(options = {}, config) {
bot.username = client.username
})
client.on('disconnect', (data) => {
bot.emit("disconnect", JSON.stringify(data.reason))
bot.emit("disconnect", data)
// bot.console.info(JSON.stringify(data))
// bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
@ -49,7 +50,7 @@ function createBot(options = {}, config) {
client.on('kick_disconnect', (data) => {
bot.emit("kick_disconnect", data.reason)
bot.console?.warn(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(data.reason))
bot.console?.warn(ChatMessage.fromNotch(`§8[§bClient Reconnect§8]§r `)?.toAnsi() + util.inspect(data.reason))
bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))

View file

@ -15,7 +15,7 @@ module.exports = {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
if (args[0] === "list") {
if (args[0]?.toLowerCase() === "list") {
const list = Object.keys(cows);
let content = [];
let color = true;

View file

@ -41,7 +41,14 @@ module.exports = {
switch (args[0]?.toLowerCase()) {
case 'version':
if (botInfo.bot.buildstring.codename === '') {
if (bot.options.isSavage) {
bot.chat.message(`&9Friday &9Night &9Funkin &3Boyfriend &1Bot&8&r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}`)
setTimeout(() => {
bot.chat.message(`11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`)
}, 300)
} else {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
}
} else {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}-${botInfo.bot.buildstring.codename}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
}

View file

@ -15,8 +15,8 @@ module.exports = {
execute (context) {
const bot = context.bot
const args = context.arguments;
if (args.join(' ').toLowerCase().startsWith("http://")) {
http.get(args.join(' '), (res) => {
if (args.slice(1).join(' ').toLowerCase().startsWith("http://")) {
http.get(args.slice(1).join(' '), (res) => {
const { statusCode } = res;
const contentType = res.headers['content-type'];
res.setEncoding('utf8');
@ -33,7 +33,7 @@ module.exports = {
bot.chat.message(`&4${e.toString()}`);
});
} else {
https.get(args.join(' '), (res) => {
https.get(args.slice(1).join(' '), (res) => {
res.on('data', (d) => {
bot.tellraw("@a", { text: util.inspect(d.toString().substring(0, 32750)), color: "dark_green", })
// console.log(Object.keys(d.toString().length));

View file

@ -25,6 +25,8 @@ core:
y: 0
z: 15
commandSetMessage: true
keys:
trusted: "trusted key here"
admin: "admin key here"

1
src/data/filter.json Normal file
View file

@ -0,0 +1 @@
[]

View file

@ -1,8 +1,8 @@
{
"bot": {
"buildstring": {
"version": "v6.0.2",
"build":"1000",
"version": "v6.0.3",
"build":"1025",
"codename":""
},
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"

View file

@ -58,6 +58,12 @@ function chat (bot, options, config) {
case 5:
bot.emit('message', { translate: "chat.type.announcement", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ]})
break
case 3:
bot.emit('message', { translate: "commands.message.display.outgoing", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ], color: "gray", italic: true })
break
case 2:
bot.emit('message', { translate: "commands.message.display.incoming", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ], color: "gray", italic: true })
break
default:
bot.emit('message', unsigned)
}

View file

@ -59,7 +59,7 @@ function command_manager (bot, options, config, discordClient) {
const roles = event?.member?.roles?.cache;
if (command?.trustLevel === 1 && !source?.sources?.discord) {
const hash = args[0]
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or and admin or an owner hash" })
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash" })
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' })
} else if (command?.trustLevel === 1 && source?.sources.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
@ -101,9 +101,21 @@ function command_manager (bot, options, config, discordClient) {
]
})
} else if (!source?.sources?.discord && !source?.sources?.console) {
if (error instanceof CommandError)
if (error instanceof CommandError) {
if (bot.options.isSavage || bot.options.isCreayun) {
bot.chat.message(`&4${error.message}`)
} else {
bot.tellraw("@a", { text: error.message, color: "dark_red" })
else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
}
} else {
if (bot.options.isSavage || bot.options.isCreayun) {
bot.chat.message(`${bot.getMessageAsPrismarine({ translate: "command.failed", color: "dark_red" })?.toMotd().replaceAll('§','&')}`)
} else {
bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
}
}
// else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
//}
}
}
},

View file

@ -50,7 +50,7 @@ function Console (bot, options, config) {
},
{
selector: `${bot.username}`, color:'#00FFFF',
clickEvent: { action: 'suggest_command', value: '~help' }
clickEvent: { action: 'suggest_command', value: `${config.prefixes[0]}help` }
},
{
text: '',

View file

@ -0,0 +1,57 @@
const fs = require('fs');
const path = require('path');
const jsonData = fs.readFileSync(path.join(__dirname, '../data/filter.json'));
function filterFunction (bot, options, config) {
bot.filter = {
list () {
try {
return JSON.parse(jsonData);
} catch (e) {
bot.chat.message(`&4${e.toString()}`);
}
},
add (player) {
try {
const filterList = JSON.parse(jsonData);
const addData = {
ignoreCase: false,
name: player
}
filterList.push(addData);
const data = JSON.stringify(filterList);
fs.writeFile(jsonData, data, (err) => {
if (err) throw err;
})
console.log(data);
} catch (e) {
bot.chat.message(`${e.toString()}`);
}
},
ignoreCase (player) {
try {
const filterList = JSON.parse(jsonData);
const addData = {
ignoreCase: true,
name: player
}
filterList.push(addData);
const data = JSON.stringify(filterList);
fs.writeFile(jsonData, data, (err) => {
if (err) throw err;
})
console.log(data);
} catch (e) {
bot.chat.message(`${e.toString()}`);
}
},
clear () {
try {
// fs.rmSync(path.join(__dirname, '../data/filter.json'));
fs.writeFileSync(jsonData, JSON.stringify([]));
} catch (e) {
bot.chat.message(`${e.toString()}`)
}
}
}
}
module.exports = filterFunction;

View file

@ -18,12 +18,21 @@ function player_list (bot, options, config) {
}
})
bot.on('packet.player_remove', ({ players }) => {
// TODO: Add player removal (with validation)
for (const player of players) {
bot.players = bot.players.filter(entry => entry.uuid !== player)
bot.on('packet.player_remove', async ({players}) => { // players has uuids of the players
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude @a, @r, @s, @e, @p -aaa
bot.players.forEach(async player => {
if(!players.includes(player.uuid)) return
const a = player_completion.filter(_ => _.match == player.profile.name)
if(a.length >= 1) {
player.vanished = true
} else {
bot.players = bot.players.filter(_ => _.uuid != player.uuid)
}
})
})
function addPlayer (entry) {
bot.players = bot.players.filter(_entry => _entry.uuid !== entry.uuid)
@ -35,7 +44,8 @@ function player_list (bot, options, config) {
gamemode: undefined,
listed: undefined,
latency: undefined,
displayName: undefined
displayName: undefined,
vanished: false
})
}

View file

@ -0,0 +1,18 @@
module.exports = (bot) => {
// let aaa cook
bot.tab_complete = (str) => {
return new Promise((resolve) => {
bot._client.write('tab_complete', {
text: str, assumeCommand: false, sendBlockInSight: false
})
const tab_completeH = (packet) => {
bot._client.removeListener('tab_complete', tab_completeH)
resolve(packet.matches)
}
bot._client.once('tab_complete', tab_completeH)
})
}
}

View file

@ -1,14 +1,16 @@
const ChatMessage = require('prismarine-chat')('1.20.2');
const util = require('util');
function creayun (messageobj, data) {
let match;
let sender;
const stringify = message => new ChatMessage(message).toString()
const message = stringify(messageobj);
const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/;
const playerWithoutPrefix = /^(\S*?) » (.*?)$/
if (playerWithPrefix.test(message)) {
let match = message.match(playerWithPrefix)
const sender = data.players.find((player) => player.uuid === player.uuid)
if (!sender) return undefined
match = message.match(playerWithPrefix)
sender = data.players.find(player => player.profile.name === match[2])
if (!sender) return;
return { sender, contents: match[3], type: 'minecraft:chat'};
}
}