diff --git a/bin/tipbot.js b/bin/tipbot.js index e9a7f2e..fe8269f 100644 --- a/bin/tipbot.js +++ b/bin/tipbot.js @@ -157,7 +157,7 @@ client.addListener('message', function(from, channel, message) { msg.push(settings.messages[command][i].expand({})); } - client.say(msg.join(', ')); + client.say(from, msg.join(', ')); return; } @@ -215,9 +215,10 @@ client.addListener('message', function(from, channel, message) { max = max ? Math.min(max, names.length) : names.length; if(max == 0) return; + var whole_channel = false; + if(max == names.length) whole_channel = true; names = names.slice(0, max); - if(amount / max < settings.coin.min_rain) { client.say(channel, settings.messages.rain_too_small.expand({from: from, amount: amount, min_rain: settings.coin.min_rain * max})); return; @@ -232,7 +233,7 @@ client.addListener('message', function(from, channel, message) { }); } - client.say(channel, settings.messages.rain.expand({name: from, amount: amount / max, list: names.join(', ')})); + client.say(channel, settings.messages.rain.expand({name: from, amount: amount / max, list: whole_channel ? 'the whole channel' : names.join(', ')})); }); } else { winston.info('%s tried to tip %s %d, but has only %d', from, to, amount, balance); diff --git a/lib/webadmin/app.js b/lib/webadmin/app.js index b1751a7..99391d7 100644 --- a/lib/webadmin/app.js +++ b/lib/webadmin/app.js @@ -64,13 +64,21 @@ module.exports.app = function(port, coin, settings, winston) { app.get('/user/:user', function(req, res) { var user = req.params.user; - coin.getAddressesByAccount(user.toLowerCase(), function(err, addresses) { + coin.listReceivedByAddress(settings.coin.min_confirmations, true, function(err, reply) { if(err) { winston.error('Tried to get address listing but failed.', err); res.send(500, 'Could not get address list'); return; } + var addresses = []; + for(var key in reply) { + var address = reply[key]; + if(address.account.toLowerCase() == user.toLowerCase()) { + addresses.push({address: address.address, amount: address.amount}) + } + } + var body = JSON.stringify({ addresses: addresses }); diff --git a/lib/webadmin/views/index.html b/lib/webadmin/views/index.html index b85d386..210717c 100644 --- a/lib/webadmin/views/index.html +++ b/lib/webadmin/views/index.html @@ -87,6 +87,7 @@ # Address + Total deposited @@ -106,9 +107,14 @@ $('#userinfo_address_list').empty(); $.getJSON('/user/' + user, function(data) { $.each(data.addresses, function(key, val) { - $('#userinfo_address_list').append('' + key + '' + val + ''); - }) - }) + $('#userinfo_address_list').append(' + + ' + (key + 1) + ' + ' + val.address + ' + ' + val.amount + ' + '); + }); + }); $('#userinfo_modal').modal('show'); });