robotirc

Multifonction IRC bot written in Node.js
Log | Files | Refs | README | LICENSE

commit d2903b26d41b32ab3e2d9cce99fbb9fb9a3fff5e
parent fe763ca791e07e1c85d5f478c36efa204fd8d920
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Mon,  6 Jan 2014 23:17:48 +0100

User defined configuration file

Diffstat:
MREADME.md | 8+++++++-
Mbin/robotirc | 13+++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -4,9 +4,15 @@ Multifonction IRC bot written in Node.js. +## Usage + +Start RobotIRC by invoking `robotirc`. + ## Configuration -Configuration options are set in the `config.json` file : +Configuration options are set in the `~/.robotirc` file. If RobotIRC cannot find an user defined configuration file in the home directory, the bundled `config.json` if used instead. + +Example configuration with default options : { "server": "irc.freenode.net", diff --git a/bin/robotirc b/bin/robotirc @@ -1,10 +1,19 @@ #!/usr/bin/env node +var fs = require('fs'); var log = require('npmlog'); var robotirc = require('../lib/robotirc'); var config = require("../config.json"); -log.info("", "RobotIRC is running. Press Ctrl+C to stop."); +log.info("", "RobotIRC is running. Press Ctrl+C to stop"); -robotirc(config); +fs.readFile(process.env.HOME + '/.robotirc', function(error, data) { + if (!error) { + config = JSON.parse(data); + } else { + log.warn("", "Can't read ~/.robotirc file, using default configuration"); + } + + robotirc(config); +});