This commit is contained in:
ChomeNS 2022-10-18 10:05:27 +07:00
parent 5579733b6f
commit a016da4d52
3 changed files with 6 additions and 18 deletions

View file

@ -304,7 +304,7 @@ function main() {
// fs.appendFileSync('./logs.txt', `${bot.options.host}: ${message.toMotd()}\r\n`);
// if (discordMsg)return channel.send(`${discordMsg.substring(0, 2000)}`)
if (message.toMotd().startsWith('§8[§eChomeNS §r§9Discord§8] §r§c')) return;
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return;
if (message.toString()==='') return;
if (message.toString().startsWith(' ')) return;
dcmsg.queue += '\n' + discordMsg;
@ -379,15 +379,6 @@ function main() {
bot.emit('end', 'uncaughtException', 'process: uncaughtException');
});
process.on('SIGINT', async function() {
try {
bot.chat('Interrupted by console');
} catch (e) {
return;
}
process.exit();
});
bot.once('end', (reason, event) => {
console.log(`Disconnected (${event} event): ${util.inspect(reason)}`);
channel.send(`Disconnected (${event} event): \`${util.inspect(reason)}\``);

View file

@ -18,12 +18,7 @@ function inject(bot) {
bot.on('parsed_chat', (message, packet) => {
try {
const raw = message.toMotd().substring(0, 32767);
if (raw.match(/.* .*§r: §.*/g)) {
// if (packet.sender === '00000000-0000-0000-0000-000000000000') return;
const username = raw.replace(/.*?\[.*?\] /, '').replace(/:.*/g, '').replace(/§#....../gm, '');
const message = raw.split('§r: ')[1].substring(2);
bot.emit('message', username, message, packet.sender);
} else if (raw.match(/.* .*: .*/g)) {
if (raw.match(/.* .*: .*/g)) {
// if (packet.sender === '00000000-0000-0000-0000-000000000000') return;
const username = raw.replace(/.*?\[.*?\] /, '').replace(/:.*/g, '').replace(/§#....../gm, '');
const message = raw.split(': ')[1];

View file

@ -8,15 +8,17 @@ function inject(bot, dcclient) {
bot.command_handler.commands = loadFiles(path.join(__dirname, '../commands'));
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc) {
let raw;
let command;
if (typeof message.content!=='undefined') raw = message.content.substring(prefix.length);
if (typeof message.content==='undefined') raw = message.substring(prefix.length);
const [commandName, ...args] = raw.split(' ');
var command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase());
command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase());
try {
var alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()));
if (alias !== undefined) {
var command = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()));
command = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()));
}
if (prefix === '*' && message.endsWith('*') && message !== '*') return;
if (command === undefined) {
throw new Error(`Unknown command: "${commandName}"`);
}