diff --git a/index.js b/index.js index d7ed638..fe141d5 100644 --- a/index.js +++ b/index.js @@ -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[§r§eChomeNS §r§9Discord§r§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)}\``); diff --git a/plugins/chat.js b/plugins/chat.js index c2afc78..e5bffc5 100644 --- a/plugins/chat.js +++ b/plugins/chat.js @@ -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]; diff --git a/plugins/commands.js b/plugins/commands.js index c783bb6..b292028 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -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}"`); }