Skip to content

Commit 38e6143

Browse files
committed
put password to config, improving comments
1 parent 5997bab commit 38e6143

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ let handlers = require('./lib/handlers');
88
const NODE_ENV = process.env.NODE_ENV || 'development';
99
let config = loadEnv();
1010

11+
// @TODO suport all configurations
1112
const client = new irc.Client(
1213
config.server,
1314
config.botNick,
14-
{ channels: config.channels }
15+
{
16+
channels: config.channels,
17+
password: config.password || null
18+
}
1519
);
1620

21+
// Load env variables based on filename (duh~!?)
1722
function loadEnv() {
1823
try {
1924
return JSON.parse(fs.readFileSync(`./config/${NODE_ENV}.json`));
@@ -23,6 +28,7 @@ function loadEnv() {
2328
}
2429
}
2530

31+
// Clean and (re)bind all listeners to irc client
2632
function bindListeners() {
2733
console.log('Listeners Binded');
2834
Object.keys(handlers).forEach(key => {
@@ -31,11 +37,13 @@ function bindListeners() {
3137
});
3238
};
3339

40+
// Creating a watcher to monitore files
3441
watch.createMonitor('./lib', (monitor) => {
3542
bindListeners();
3643
monitor.on('changed', () => reloadModuleCache());
3744
});
3845

46+
// Sorcery to clean and reload require cache
3947
function reloadModuleCache() {
4048
fs.readdir('./lib', (err, files) => {
4149
files.forEach(deleteFileCache);

0 commit comments

Comments
 (0)