Author

Topic: Bitcoin IRC Bot (Read 2502 times)

member
Activity: 65
Merit: 10
June 18, 2011, 01:08:01 AM
#3
How do we verify the bot? Will it list all transactions so we can see if it matches what is expected?

Uhm, right now you can't, I'd be able to add it in the future though if it's needed.
hero member
Activity: 672
Merit: 500
BitLotto - best odds + best payouts + cheat-proof
June 17, 2011, 12:28:41 AM
#2
How do we verify the bot? Will it list all transactions so we can see if it matches what is expected?
member
Activity: 65
Merit: 10
June 15, 2011, 09:14:11 AM
#1
Anyways, basically I have been working on my bitcoin bot all night, it does this right now like !btcstats and !mktstats .

It's unique feature at the moment is it's gambling feature, it follows a very similar design to the bitcoinlotto posted earlier where:
1-50 loses to the pot
51-89 wins 170% of the wager
90-100 wins 220% of the wager

If you submit over 0.1 BTC as a wager, you have a chance to win 75% of the pot, the other 25% is reserved for fees and such.


Anyways, if you wanted to give it a shot you can find him in #btcbot on irc.freenode.net.

Here is the source for the gambling feature:
Code:
$bitcoin = new jsonRPCClient('');
$balance = floatval($bitcoin->getbalance("pot", 1));

switch($args[1]) {
case "pot_balance":
$bot->message($chan, $who[0] . ", Pot balance is: " . $balance);
break;
case "balance":
$bot->message($chan, $who[0] . ", Your balance is: " . $bitcoin->getbalance($who[0], 1));
break;
case "newaddress":
$bot->message($chan, $who[0] . ", Your new address is: " . $bitcoin->getnewaddress($who[0]));
break;
case "withdraw":
if(!$args[2]) {
$bot->message($chan, $who[0] . ", use !btcdouble withdraw ");
return 0;
}
$balance_you = $bitcoin->getbalance($who[0], 1);
$bot->message($chan, $who[0] . ", You have been sent: " . $balance_you);
$bitcoin->sendfrom("pot", $args[2], $balance_you, 1);
break;

case "roll":
if(!$args[2]) {
$bot->message($chan, $who[0] . ", use !btcdouble roll ");
return 0;
}
$wager = floatval($args[2]);
if($bitcoin->getbalance($who[0], 1) < $wager || $wager < 0) {
$bot->message($chan, $who[0] . ", you cannot wager that amount!!!");
return 0;
}
$num = rand(1,100);
if ($num <= 50) {
$bitcoin->move($who[0], "pot", $wager, 0);
$bot->message($chan, $who[0] . ", You rolled a  " . $num . ", " . $wager . " BTC has been sent to the pot");
} elseif($num > 50 && $num < 90) {
$bitcoin->move($who[0], "pot", $wager, 0);
if(($balance + 0.0005) < $wager*1.7) {
$myFile = "debt";
$fh = fopen($myFile, 'a');
$stringData = "Owe " .$wager*1.7. " to " . $who[0] . "\n";
fwrite($fh, $stringData);
fclose($fh);
$bot->message($chan, $who[0] . ", You rolled a  " . $num . " but the pot is unable to pay you off at the moment, contact bool_ and tell him to send you your winnings.");
return 0;
}
$bitcoin->move("pot", $who[0], $wager*1.7, 0);
$bot->message($chan, $who[0] . ", You rolled a  " . $num . ", " . ($wager*1.7) . " BTC has been sent to your balance");
} else {
$bitcoin->move($who[0], "pot", $wager, 0);
if(($balance + 0.0005) < $wager*2.2) {
$myFile = "debt";
$fh = fopen($myFile, 'a');
$stringData = "Owe " .$wager*2.2. " to " . $who[0] . "\n";
fwrite($fh, $stringData);
fclose($fh);
$bot->message($chan, $who[0] . ", You rolled a  " . $num . " but the pot is unable to pay you off at the moment, contact bool_ and tell him to send you your winnings.");
return 0;
}
$bitcoin->move("pot", $who[0], $wager*2.2, 0);
$bot->message($chan, $who[0] . ", You rolled a  " . $num . ", " . ($wager*2.2) . " BTC has been sent to your balance");
}
break;
default:
$bot->message($chan, $who[0] . ", use !btcdouble ");
break;
}
Jump to: