Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env node
- // run it like this:
- //
- // JDBOT_USERNAME=bolux JDBOT_PASSWORD=future2000 node jdbot.js
- //
- // or like this:
- //
- // JDBOT_HASH=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3 node jdbot.js
- //
- // and include a JDBOT_CODE=123456 at the start if you need 2FA to log in
- var request = require('request');
- var url = "https://just-dice.com";
- var transport = 'websocket'; // Replace 'websocket' with the desired transport mechanism
- var cookie = 'hash=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3; connect.sid=s%3A6p2Au_V3ZKg2S45GOThxbkrd.9fBLOhWaMPNob9bXsWz5Q0BD7lwIyB0Fqy3cehAZo%2BA';
- var socket = require('socket.io-client')(url, { transports: [transport], extraHeaders: { origin: url, cookie: cookie } });
- // my local test instance doesn't have an SSL certificate
- if (process.env.JDBOT_TESTING == '1') {
- url = "https://test.com";
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
- }
- // EITHER (A) call login_then_run_bot() with your 64 character hash:
- login_then_run_bot({hash: process.env.JDBOT_HASH,
- username: process.env.JDBOT_USERNAME,
- password: process.env.JDBOT_PASSWORD,
- code: process.env.JDBOT_CODE
- });
- // OR (B) as a shortcut, call run_bot() with your full hash+sid cookie (as shown when you use login_then_run_bot()) to skip the login step:
- // cookie = 'hash=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3; connect.sid=s%3A6p2Au_V3ZKg2S45GOThxbkrd.9fBLOhWaMPNob9bXsWz5Q0BD7lwIyB0Fqy3cehAZo%2BA';
- // run_bot(cookie);
- var socket,
- uid,
- bet_in_progress,
- balance = 0.03,
- crazy = parseFloat(balance),
- old = parseFloat(balance),
- score = parseFloat(balance),
- lol = parseFloat(balance),
- arnie = (parseFloat(balance) / 1440000),
- james = (arnie),
- jim = (arnie),
- jly = 0,
- future = 0,
- madman = (james),
- kool = parseFloat(balance),
- have = parseFloat(balance),
- junky = parseFloat(balance),
- chance = '49.5',
- stake = james,
- hilo = 'lo',
- bet_stake_threshold = 1,
- bet_profit_threshold = 1,
- show_all_my_bets = true,
- user_profit = {};
- function init_readline() {
- var readline = require('readline').createInterface({
- input: process.stdin, output: process.stdout, terminal: false
- });
- readline.on('line', handle_command);
- readline.on('close', function() {
- console.log('Have a great day!');
- process.exit(0);
- });
- }
- var last_command;
- function handle_command(txt) {
- // hit return to repeat last line
- if (txt === '') {
- if (last_command)
- return handle_command(last_command);
- txt = '.help';
- }
- last_command = txt;
- if (!socket) {
- console.log('not connected');
- return;
- }
- // lines that don't begin with a dot are sent as if entered in the chat box
- if (!txt.match(/^[.]/)) {
- socket.emit('chat', txt);
- return;
- }
- txt = txt.substring(1);
- // split command into array of words
- txt = txt.split(/\s+/);
- try {
- switch (txt[0]) {
- case 'b':
- case 'bet':
- bet(stake, chance, hilo);
- break;
- case 'c':
- case 'chance':
- validate_number(txt[1]);
- chance = tidy(txt[1], 4);
- console.log('set chance to', chance + '%');
- break;
- case 'h':
- case 'hi':
- case 'high':
- hilo = 'hi';
- console.log('set hi/lo to hi');
- break;
- case 'l':
- case 'lo':
- case 'low':
- hilo = 'lo';
- console.log('set hi/lo to lo');
- break;
- case 'login':
- validate_string(txt[1]);
- validate_string(txt[2]);
- console.log('attempting to log in <username> <password> [2FA code]');
- socket.emit('login', txt[1], txt[2], txt[3]);
- break;
- case 'n':
- case 'name':
- validate_string(txt[1]);
- console.log('attempting to change name to "' + txt[1] + '"');
- socket.emit('name', txt[1]);
- break;
- case 'passwd':
- validate_string(txt[1]);
- validate_string(txt[2]);
- console.log('attempting to change password <from> <to>');
- socket.emit('change_password', txt[1], txt[2]);
- break;
- case 'p':
- case 'payout':
- validate_number(txt[1]);
- chance = tidy(99 / txt[1], 4);
- console.log('set chance to', chance + '%');
- break;
- case 's':
- case 'stake':
- validate_number(txt[1]);
- stake = tidy(txt[1], 8);
- console.log('set stake to', stake);
- break;
- case 't':
- case 'tog':
- case 'toggle':
- hilo = 'tog';
- console.log('set hi/lo to toggle');
- break;
- case 'userpass':
- validate_string(txt[1]);
- validate_string(txt[2]);
- console.log('attempting to set username to "' + txt[1] + '"');
- socket.emit('setup_account', txt[1], txt[2]);
- break;
- case 'w':
- case 'wd':
- case 'withdraw':
- validate_address(txt[1]);
- validate_number(txt[2]);
- console.log('withdrawing', txt[2], 'to', txt[1]);
- socket.emit('withdraw', txt[1], txt[2], txt[3]);
- break;
- case '?':
- case 'help':
- show_help();
- break;
- default:
- console.log('unknown command;', txt[0]);
- break;
- }
- } catch (err) {
- console.log(err);
- }
- }
- function validate_address(addr) {
- if (addr === undefined)
- throw new Error("missing required address");
- if (!addr.match(/^x[1-9a-km-zA-HJ-NP-Z]{33}$/))
- throw new Error("invalid CLAM address");
- }
- function validate_integer(num) {
- if (num === undefined)
- throw new Error("missing required integer");
- if (!num.match(/^[1-9][0-9]*$/))
- throw new Error("number should have nothing other than digits in it");
- }
- function validate_number(num) {
- if (num === undefined)
- throw new Error("missing required number");
- if (!num.match(/[0-9]/))
- throw new Error("number should have some digits in it");
- if (num.match(/[.].*[.]/))
- throw new Error("number should have no more than one dot in it");
- if (!num.match(/^[0-9.]*$/))
- throw new Error("number should have nothing other than digits and dots in it");
- }
- function validate_string(str) {
- if (str === undefined)
- throw new Error("missing required string");
- }
- function show_help() {
- console.log('type to chat, or (.b)et, (.c)hance, (.d)eposit, (.f)latbet, (.h)i, (.l)o, (.m)artingale (.n)ame (.p)ayout, (.s)take, (.t)oggle (.w)ithdraw (.help)');
- console.log('hit return on its own to repeat last line');
- }
- function tidy(val, fixed)
- {
- if (fixed === undefined)
- fixed=8;
- if (typeof(val) == 'number')
- val = val.toFixed(fixed);
- val = val.replace(/([.].*?)0+$/, '$1'); // remove trailing zeroes after the decimal point
- val = val.replace(/[.]$/, ''); // remove trailing decimal point
- return val;
- }
- var last_hilo;
- function bet(stake, chance, hilo) {
- if (bet_in_progress) {
- console.log('you have a bet in progress already');
- return;
- }
- // if we're toggling, toggle
- if (hilo == 'tog') {
- if (last_hilo == 'hi')
- last_hilo = 'lo';
- else
- last_hilo = 'hi';
- } else
- // else just remember what we bet in case we toggle next time
- last_hilo = hilo;
- console.log('BET:', stake, '@', tidy(chance, 4) + '%', last_hilo);
- bet_in_progress = true;
- socket.emit('bet', {chance: tidy(chance, 4), bet: stake, which: last_hilo});
- }
- function login_then_run_bot(credentials) {
- login(credentials, function(err, cookie) {
- if (err) {
- console.log('ERROR:', err);
- return;
- }
- console.log('logged in; got cookie (secret - do not share!):');
- console.log(cookie);
- run_bot(cookie);
- });
- }
- function login(credentials, cb) {
- var jar = request.jar();
- req = {url: url, jar: jar, form: {}}
- if (credentials.hash) {
- if (credentials.username || credentials.password)
- return cb('either specify a hash or a username and password');
- jar.setCookie(request.cookie('hash=' + credentials.hash), url);
- }
- if (credentials.username) req.form.username = credentials.username;
- if (credentials.password) req.form.password = credentials.password;
- if (credentials.code) req.form.code = credentials.code;
- request.post(req, function(err, res, body) {
- if (err)
- return cb(err);
- // console.log(body);
- if (body.match(/Please enter your 6 digit google authentification number/))
- return cb('that account requires a correct 2FA code and hash to log in; 2FA codes can only be used once each');
- if (body.match(/Your account is set up to require a google authentification code for this action/))
- return cb('that account requires a 2FA code in addition to the username and password to log in');
- if (body.match(/Please enter your username/))
- return cb('that account requires a correct username and password, and possibly 2FA code; 2FA codes can only be used once each');
- var cookie = jar.getCookieString(url);
- if (!cookie.match(/hash=/))
- return cb('bad hash');
- return cb(null, cookie);
- });
- }
- var first_login = true;
- function run_bot(cookie) {
- if (first_login) {
- init_readline();
- first_login = false;
- }
- show_help();
- var transport = 'websocket';
- // var transport = 'polling';
- var inits = 0;
- socket = require("socket.io-client")(url, {transports: [transport],
- extraHeaders: {
- origin: url,
- cookie: cookie
- }});
- socket.on('error', function(err) {
- console.log('caught error:', err);
- });
- socket.on('set_hash', function(hash) {
- console.log('INFO:', 'server requested that we reconnect...');
- socket.close();
- run_bot(cookie);
- });
- socket.on('chat', function(txt, date) {
- console.log('CHAT:', txt);
- });
- }
- function go(){
- socket.on('wins', function(count) {
- bet_in_progress = false;
- balance = balance+james;
- bet(stake, chance, hilo);
- });
- socket.on('losses', function(count) {
- bet_in_progress = false;
- balance = balance-james;
- bet(stake, chance, hilo);
- });
- if (balance < crazy && future <= 3) {
- future += 1;
- jim = (jim + arnie);
- jly = (old - balance);
- james = (jly + jim - arnie);
- madman = (james);
- lol = parseFloat(balance);
- crazy = parseFloat(balance);
- }
- if (balance < crazy && future > 3 && balance < score) {
- future += 1;
- james = (madman);
- crazy = parseFloat(balance);
- }
- if (balance > crazy && balance < score) {
- james = (madman);
- crazy = parseFloat(balance);
- }
- if (future > 3 && balance < lol - james * 1.9) {
- james = (james + james);
- madman = james;
- lol = parseFloat(balance);
- }
- if (balance >= score) {
- arnie = parseFloat(balance) / 1440000;
- jim = (arnie);
- james = (arnie);
- jly = 0;
- future = 0;
- old = parseFloat(balance);
- lol = parseFloat(balance);
- crazy = parseFloat(balance);
- madman = parseInt(james);
- score = parseFloat(balance);
- }
- stake = james.toFixed(8);
- hilo = 'lo'
- chance = 49.5
- }
- setTimeout(() => go(), 40000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement