diff --git a/bin/tipbot b/bin/tipbot index 03eee44..19e5d40 100644 --- a/bin/tipbot +++ b/bin/tipbot @@ -4,11 +4,13 @@ var irc = require('irc') , yaml = require('js-yaml') , coin = require('node-dogecoin'); +// load settings +var settings = yaml.load(fs.readFileSync('./config/config.yml', 'utf-8')); + // load winston's cli defaults winston.cli(); -// load settings -var settings = yaml.load(fs.readFileSync('./config/config.yml', 'utf-8')); +// winston.add(winston.transports.File, // connect to coin json-rpc winston.info('Connecting to coind...'); @@ -104,7 +106,6 @@ client.addListener('error', function(message) { }); client.addListener('message', function(from, channel, message) { - winston.info('[%s] <%s> %s', channel, from, message); if(/^!tip/.test(message)) { var match = message.match(/^!tip (\S+) (\d+)/); if(match == null || match < 3) { @@ -114,6 +115,11 @@ client.addListener('message', function(from, channel, message) { var to = match[1]; var amount = Number(match[2]); + if(to.toLowerCase() == from.toLowerCase()) { + client.say(channel, settings.messages.self_tip.expand({name: from})); + return; + } + if(amount < settings.coin.min_tip) { client.say(channel, settings.messages.tip_too_small.expand({from: from, to: to, amount: amount})); return; @@ -170,7 +176,7 @@ client.addListener('message', function(from, channel, message) { return; } - client.say(channel, settings.messages.expand({name: user, address: address})); + client.say(channel, settings.messages.deposit_address.expand({name: user, address: address})); }); } @@ -264,12 +270,3 @@ client.addListener('message', function(from, channel, message) { }); } }); - -client.addListener('notice', function(from, to, message) { - if(to == '*') return false; - winston.info('NOTICE: [%s] <%s> %s', to, from, message); -}); - -client.addListener('selfMessage', function(to, message) { - winston.info('[%s] <%s> %s', to, this.nick, message); -}); \ No newline at end of file diff --git a/config/config.yml b/config/config.yml index dbcb079..829d2f0 100644 --- a/config/config.yml +++ b/config/config.yml @@ -7,7 +7,9 @@ login: username: nodetip realname: node.js dogecoin tipping bot channels: - - '##tipbots' + - '##unek' +log: + file: tipbot.log rpc: host: localhost port: 22555 @@ -33,4 +35,5 @@ messages: invalid_address: 'Sorry %name%, the address you specified is invalid (%address%).' withdraw_success: '%name%: %amount%%short_name% has been withdrawn from your account to %address%' withdraw_success2: 'You have been charged %withdrawal_fee%%short_name% withdrawal fee. Transaction id: %transaction%.' - tip_too_small: 'Sorry %from%, your tip to %to% (%amount%%short_name%) is too small (min. %min_tip%%short_name%).' \ No newline at end of file + tip_too_small: 'Sorry %from%, your tip to %to% (%amount%%short_name%) is too small (min. %min_tip%%short_name%).' + tip_self: "Sorry %name%, you can't tip yourself!" \ No newline at end of file