disable self-tips

This commit is contained in:
unek
2014-02-22 19:36:01 +01:00
parent 00565f5759
commit b8da296bd1
2 changed files with 15 additions and 15 deletions
+10 -13
View File
@@ -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);
});
+5 -2
View File
@@ -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%).'
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!"