Beispiel #1
0
                                coin.getBalance(from.toLowerCase(), function(err, balance) {
                                    if (err) {
                                        winston.error('Something went wrong while transferring fees', err);
                                        return;
                                    }

                                    var balance = typeof(balance) == 'object' ? balance.result : balance;
                                    // moves the rest to bot's wallet
                                    coin.move(from.toLowerCase(), settings.login.nickname.toLowerCase(), balance);
                                });
Beispiel #2
0
                        client.getNames(channel, function(names) {
						// rain only on nicknames active within the last x seconds
							if(settings.commands.rain.rain_on_last_active) {
								for (var i = names.length - 1; i >= 0; i--) {
									if(!last_active.hasOwnProperty(names[i]) || last_active[names[i]] + settings.commands.rain.rain_on_last_active * 1000 < Date.now()) {
										names.splice(i, 1);
									}
								};
							}
                            // remove tipper from the list
                            names.splice(names.indexOf(from), 1);
                            names.splice(names.indexOf(client.nick), 1);
                            // shuffle the array
                            for (var j, x, i = names.length; i; j = Math.floor(Math.random() * i), x = names[--i], names[i] = names[j], names[j] = x);

                            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) {
                            	locks[from.toLowerCase()] = null;
                                client.say(channel, settings.messages.rain_too_small.expand({
                                    from: from,
                                    amount: amount,
                                    min_rain: settings.coin.min_rain * max
                                }));
                                return;
                            }

                            for (var i = 0; i < names.length; i++) {
                                coin.move(from.toLowerCase(), names[i].toLowerCase(), amount / max, function(err, reply) {
                                	if(i == names.length) locks[from.toLowerCase()] = null;
                                	if (err || !reply) {
                                        winston.error('Error in !tip command', err);
                                        return;
                                    }
                                });
                            }

                            client.say(channel, settings.messages.rain.expand({
                                name: from,
                                amount: amount / max,
                                list: (whole_channel && !settings.commands.rain.rain_on_last_active) ? 'the whole channel' : names.join(', ')
                            }));
                        });