vanish support (credits to aaa) and somewhat working filter. v6.0.3 build: 1025
This commit is contained in:
parent
2a812961e1
commit
648f4431d7
20 changed files with 145 additions and 23 deletions
1
src/[""]
Normal file
1
src/[""]
Normal file
|
@ -0,0 +1 @@
|
||||||
|
["",{"ignoreCase":false,"name":"amogus"}]
|
1
src/[]
Normal file
1
src/[]
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[{"ignoreCase":false,"name":"amogus"}]
|
1
src/[]
Normal file
1
src/[]
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[{"ignoreCase":false,"name":"amogus"}]
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
1
src/[{"ignoreCase":false,"name":"amogus"}]
Normal file
1
src/[{"ignoreCase":false,"name":"amogus"}]
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[{"ignoreCase":false,"name":"amogus"},"reee"]
|
1
src/[{}]
Normal file
1
src/[{}]
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[{},{"ignoreCase":false,"name":"amogus"}]
|
|
@ -25,7 +25,8 @@ function createBot(options = {}, config) {
|
||||||
bot.username = client.username
|
bot.username = client.username
|
||||||
})
|
})
|
||||||
client.on('disconnect', (data) => {
|
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))
|
// bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||||
if (config.console.filelogger) {
|
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))
|
// 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) => {
|
client.on('kick_disconnect', (data) => {
|
||||||
bot.emit("kick_disconnect", data.reason)
|
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))
|
bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||||
if (config.console.filelogger) {
|
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))
|
// 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))
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
const bot = context.bot;
|
const bot = context.bot;
|
||||||
const args = context.arguments;
|
const args = context.arguments;
|
||||||
const source = context.source;
|
const source = context.source;
|
||||||
if (args[0] === "list") {
|
if (args[0]?.toLowerCase() === "list") {
|
||||||
const list = Object.keys(cows);
|
const list = Object.keys(cows);
|
||||||
let content = [];
|
let content = [];
|
||||||
let color = true;
|
let color = true;
|
||||||
|
|
|
@ -41,7 +41,14 @@ module.exports = {
|
||||||
switch (args[0]?.toLowerCase()) {
|
switch (args[0]?.toLowerCase()) {
|
||||||
case 'version':
|
case 'version':
|
||||||
if (botInfo.bot.buildstring.codename === '') {
|
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" })}`);
|
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 {
|
} 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" })}`);
|
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" })}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ module.exports = {
|
||||||
execute (context) {
|
execute (context) {
|
||||||
const bot = context.bot
|
const bot = context.bot
|
||||||
const args = context.arguments;
|
const args = context.arguments;
|
||||||
if (args.join(' ').toLowerCase().startsWith("http://")) {
|
if (args.slice(1).join(' ').toLowerCase().startsWith("http://")) {
|
||||||
http.get(args.join(' '), (res) => {
|
http.get(args.slice(1).join(' '), (res) => {
|
||||||
const { statusCode } = res;
|
const { statusCode } = res;
|
||||||
const contentType = res.headers['content-type'];
|
const contentType = res.headers['content-type'];
|
||||||
res.setEncoding('utf8');
|
res.setEncoding('utf8');
|
||||||
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
bot.chat.message(`&4${e.toString()}`);
|
bot.chat.message(`&4${e.toString()}`);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
https.get(args.join(' '), (res) => {
|
https.get(args.slice(1).join(' '), (res) => {
|
||||||
res.on('data', (d) => {
|
res.on('data', (d) => {
|
||||||
bot.tellraw("@a", { text: util.inspect(d.toString().substring(0, 32750)), color: "dark_green", })
|
bot.tellraw("@a", { text: util.inspect(d.toString().substring(0, 32750)), color: "dark_green", })
|
||||||
// console.log(Object.keys(d.toString().length));
|
// console.log(Object.keys(d.toString().length));
|
||||||
|
|
|
@ -25,6 +25,8 @@ core:
|
||||||
y: 0
|
y: 0
|
||||||
z: 15
|
z: 15
|
||||||
|
|
||||||
|
commandSetMessage: true
|
||||||
|
|
||||||
keys:
|
keys:
|
||||||
trusted: "trusted key here"
|
trusted: "trusted key here"
|
||||||
admin: "admin key here"
|
admin: "admin key here"
|
||||||
|
|
1
src/data/filter.json
Normal file
1
src/data/filter.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"bot": {
|
"bot": {
|
||||||
"buildstring": {
|
"buildstring": {
|
||||||
"version": "v6.0.2",
|
"version": "v6.0.3",
|
||||||
"build":"1000",
|
"build":"1025",
|
||||||
"codename":""
|
"codename":""
|
||||||
},
|
},
|
||||||
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
|
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
|
||||||
|
|
|
@ -58,6 +58,12 @@ function chat (bot, options, config) {
|
||||||
case 5:
|
case 5:
|
||||||
bot.emit('message', { translate: "chat.type.announcement", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ]})
|
bot.emit('message', { translate: "chat.type.announcement", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ]})
|
||||||
break
|
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:
|
default:
|
||||||
bot.emit('message', unsigned)
|
bot.emit('message', unsigned)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ function command_manager (bot, options, config, discordClient) {
|
||||||
const roles = event?.member?.roles?.cache;
|
const roles = event?.member?.roles?.cache;
|
||||||
if (command?.trustLevel === 1 && !source?.sources?.discord) {
|
if (command?.trustLevel === 1 && !source?.sources?.discord) {
|
||||||
const hash = args[0]
|
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' })
|
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) {
|
} 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}`)
|
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) {
|
} 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" })
|
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}` } }])
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -50,7 +50,7 @@ function Console (bot, options, config) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: `${bot.username}`, color:'#00FFFF',
|
selector: `${bot.username}`, color:'#00FFFF',
|
||||||
clickEvent: { action: 'suggest_command', value: '~help' }
|
clickEvent: { action: 'suggest_command', value: `${config.prefixes[0]}help` }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '',
|
text: '',
|
||||||
|
|
57
src/modules/filterFunction.js
Normal file
57
src/modules/filterFunction.js
Normal 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;
|
|
@ -18,12 +18,21 @@ function player_list (bot, options, config) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.on('packet.player_remove', ({ players }) => {
|
bot.on('packet.player_remove', async ({players}) => { // players has uuids of the players
|
||||||
// TODO: Add player removal (with validation)
|
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude @a, @r, @s, @e, @p -aaa
|
||||||
for (const player of players) {
|
|
||||||
bot.players = bot.players.filter(entry => entry.uuid !== player)
|
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) {
|
function addPlayer (entry) {
|
||||||
bot.players = bot.players.filter(_entry => _entry.uuid !== entry.uuid)
|
bot.players = bot.players.filter(_entry => _entry.uuid !== entry.uuid)
|
||||||
|
@ -35,7 +44,8 @@ function player_list (bot, options, config) {
|
||||||
gamemode: undefined,
|
gamemode: undefined,
|
||||||
listed: undefined,
|
listed: undefined,
|
||||||
latency: undefined,
|
latency: undefined,
|
||||||
displayName: undefined
|
displayName: undefined,
|
||||||
|
vanished: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
src/modules/tab_complete.js
Normal file
18
src/modules/tab_complete.js
Normal 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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
const ChatMessage = require('prismarine-chat')('1.20.2');
|
const ChatMessage = require('prismarine-chat')('1.20.2');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
function creayun (messageobj, data) {
|
function creayun (messageobj, data) {
|
||||||
|
let match;
|
||||||
|
let sender;
|
||||||
const stringify = message => new ChatMessage(message).toString()
|
const stringify = message => new ChatMessage(message).toString()
|
||||||
const message = stringify(messageobj);
|
const message = stringify(messageobj);
|
||||||
const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/;
|
const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/;
|
||||||
const playerWithoutPrefix = /^(\S*?) » (.*?)$/
|
const playerWithoutPrefix = /^(\S*?) » (.*?)$/
|
||||||
if (playerWithPrefix.test(message)) {
|
if (playerWithPrefix.test(message)) {
|
||||||
let match = message.match(playerWithPrefix)
|
match = message.match(playerWithPrefix)
|
||||||
const sender = data.players.find((player) => player.uuid === player.uuid)
|
sender = data.players.find(player => player.profile.name === match[2])
|
||||||
if (!sender) return undefined
|
if (!sender) return;
|
||||||
return { sender, contents: match[3], type: 'minecraft:chat'};
|
return { sender, contents: match[3], type: 'minecraft:chat'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue