fix demo bot
This commit is contained in:
parent
19d65a4d46
commit
2862af86c9
|
@ -75,16 +75,14 @@ function superSuggestion(params, context) {
|
||||||
status.addListener("on-message-input-change", superSuggestion);
|
status.addListener("on-message-input-change", superSuggestion);
|
||||||
status.addListener("on-message-send", function (params, context) {
|
status.addListener("on-message-send", function (params, context) {
|
||||||
if (isNaN(params.message)) {
|
if (isNaN(params.message)) {
|
||||||
status.sendMessage("Seems that you don't want to send money :(");
|
return {"text-message": "Seems that you don't want to send money :("};
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var balance = web3.eth.getBalance(context.from);
|
var balance = web3.eth.getBalance(context.from);
|
||||||
var value = parseFloat(params.message);
|
var value = parseFloat(params.message);
|
||||||
var weiValue = web3.toWei(value, "ether");
|
var weiValue = web3.toWei(value, "ether");
|
||||||
if (bn(weiValue).greaterThan(bn(balance))) {
|
if (bn(weiValue).greaterThan(bn(balance))) {
|
||||||
status.sendMessage("No way man, you don't have enough money! :)");
|
return {"text-message": "No way man, you don't have enough money! :)"};
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
web3.eth.sendTransaction({
|
web3.eth.sendTransaction({
|
||||||
|
@ -92,8 +90,8 @@ status.addListener("on-message-send", function (params, context) {
|
||||||
to: context.from,
|
to: context.from,
|
||||||
value: weiValue
|
value: weiValue
|
||||||
});
|
});
|
||||||
status.sendMessage("You are the hero, you sent " + value + " ETH to yourself!");
|
return {"text-message": "You are the hero, you sent " + value + " ETH to yourself!"};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
status.sendMessage("Something went wrong :(")
|
return {"text-message": "Something went wrong :("};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue