This commit is contained in:
Alex Grintsvayg 2016-07-18 10:07:41 -04:00
parent 2de7db0d8f
commit 3d1b8d687b

View file

@ -22,13 +22,17 @@ function init(rpcuser, rpcpassword) {
});
}
var globalSlackParams = {
icon_emoji: ':money_with_wings:'
};
function respond(bot, data) {
var tipper = data.user,
channel = data.channel,
words = data.text.trim().split(' ');
if (!lbry) {
bot.postMessage(channel, 'Failed to connect to lbrycrd');
bot.postMessage(channel, 'Failed to connect to lbrycrd', {icon_emoji: ':exclamation:'});
return;
}
@ -61,10 +65,10 @@ function respond(bot, data) {
function doBalance(bot, channel, tipper) {
lbry.getBalance(tipper, 1, function(err, balance) {
if (err) {
bot.postMessage(channel, '<@' + tipper + '>: Error getting balance');
bot.postMessage(channel, '<@' + tipper + '>: Error getting balance', {icon_emoji: ':exclamation:'});
}
else {
bot.postMessage(channel, '<@' + tipper + '>: You have *' + balance + '* LBC');
bot.postMessage(channel, '<@' + tipper + '>: You have *' + balance + '* LBC', globalSlackParams);
}
});
}
@ -73,10 +77,10 @@ function doBalance(bot, channel, tipper) {
function doDeposit(bot, channel, tipper) {
getAddress(tipper, function(err, address) {
if (err) {
bot.postMessage(channel, '<@' + tipper + '>: Error getting deposit address');
bot.postMessage(channel, '<@' + tipper + '>: Error getting deposit address', {icon_emoji: ':exclamation:'});
}
else {
bot.postMessage(channel, '<@' + tipper + '>: Your address is ' + address);
bot.postMessage(channel, '<@' + tipper + '>: Your address is ' + address, globalSlackParams);
}
});
}
@ -92,7 +96,7 @@ function doWithdraw(bot, channel, tipper, words) {
amount = words[3];
if (!validateAmount(amount)) {
bot.postMessage(channel, '<@' + tipper + '>: I dont know how to withdraw that many credits');
bot.postMessage(channel, '<@' + tipper + '>: I dont know how to withdraw that many credits', globalSlackParams);
return;
}
@ -101,7 +105,7 @@ function doWithdraw(bot, channel, tipper, words) {
bot.postMessage(channel, err.message);
}
else {
bot.postMessage(channel, '<@' + tipper + '>: You withdrew ' + amount + ' to ' + address + ' (' + txLink(txId) + ')');
bot.postMessage(channel, '<@' + tipper + '>: You withdrew ' + amount + ' to ' + address + ' (' + txLink(txId) + ')', globalSlackParams);
}
});
}
@ -117,7 +121,7 @@ function doTip(bot, channel, tipper, words) {
amount = words[2];
if (!validateAmount(amount)) {
bot.postMessage(channel, '<@' + tipper + '>: I dont know how to tip that many credits');
bot.postMessage(channel, '<@' + tipper + '>: I dont know how to tip that many credits', globalSlackParams);
return;
}
@ -131,7 +135,7 @@ function doTip(bot, channel, tipper, words) {
sendLbc(bot, channel, tipper, data.id, amount);
} else
{
bot.postMessage(channel, '<@' + tipper + '>: Sorry, I dont know that person');
bot.postMessage(channel, '<@' + tipper + '>: Sorry, I dont know that person', globalSlackParams);
}
})
}
@ -148,7 +152,7 @@ function doHelp(bot, channel) {
'\n' +
'Send me a Direct Message if you want to interact privately.\n' +
'If I\'m not responding in some channel, you can invite me by @mentioning me\n'
);
, globalSlackParams);
}
@ -163,7 +167,7 @@ function sendLbc(bot, channel, tipper, id, amount) {
bot.postMessage(channel, err.message);
}
else {
bot.postMessage(channel, 'Wubba lubba dub dub! <@' + tipper + '> tipped <@' + id + '> ' + amount + ' LBC (' + txLink(txId) + ')');
bot.postMessage(channel, 'Wubba lubba dub dub! <@' + tipper + '> tipped <@' + id + '> ' + amount + ' LBC (' + txLink(txId) + ')', globalSlackParams);
}
});
}