Advertisement
coinwalk

need help betting

Jun 4th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.45 KB | None | 0 0
  1. #!/usr/bin/env node
  2.  
  3. // run it like this:
  4. //
  5. // JDBOT_USERNAME=bolux JDBOT_PASSWORD=future2000 node jdbot.js
  6. //
  7. // or like this:
  8. //
  9. // JDBOT_HASH=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3 node jdbot.js
  10. //
  11. // and include a JDBOT_CODE=123456 at the start if you need 2FA to log in
  12.  
  13. var request = require('request');
  14. var url = "https://just-dice.com";
  15. var transport = 'websocket'; // Replace 'websocket' with the desired transport mechanism
  16. var cookie = 'hash=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3; connect.sid=s%3A6p2Au_V3ZKg2S45GOThxbkrd.9fBLOhWaMPNob9bXsWz5Q0BD7lwIyB0Fqy3cehAZo%2BA';
  17.  
  18. var socket = require('socket.io-client')(url, { transports: [transport], extraHeaders: { origin: url, cookie: cookie } });
  19.  
  20. // my local test instance doesn't have an SSL certificate
  21. if (process.env.JDBOT_TESTING == '1') {
  22. url = "https://test.com";
  23. process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
  24. }
  25.  
  26. // EITHER (A) call login_then_run_bot() with your 64 character hash:
  27. login_then_run_bot({hash: process.env.JDBOT_HASH,
  28. username: process.env.JDBOT_USERNAME,
  29. password: process.env.JDBOT_PASSWORD,
  30. code: process.env.JDBOT_CODE
  31. });
  32.  
  33. // 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:
  34. // cookie = 'hash=096af33d16104d4d72db4026fc76471372183c132be8acac9aa03176af68ffc3; connect.sid=s%3A6p2Au_V3ZKg2S45GOThxbkrd.9fBLOhWaMPNob9bXsWz5Q0BD7lwIyB0Fqy3cehAZo%2BA';
  35. // run_bot(cookie);
  36.  
  37. var socket,
  38. uid,
  39. bet_in_progress,
  40. balance = 0.03,
  41. crazy = parseFloat(balance),
  42. old = parseFloat(balance),
  43. score = parseFloat(balance),
  44. lol = parseFloat(balance),
  45. arnie = (parseFloat(balance) / 1440000),
  46. james = (arnie),
  47. jim = (arnie),
  48. jly = 0,
  49. future = 0,
  50. madman = (james),
  51. kool = parseFloat(balance),
  52. have = parseFloat(balance),
  53. junky = parseFloat(balance),
  54. chance = '49.5',
  55. stake = james,
  56. hilo = 'lo',
  57. bet_stake_threshold = 1,
  58. bet_profit_threshold = 1,
  59. show_all_my_bets = true,
  60. user_profit = {};
  61.  
  62. function init_readline() {
  63. var readline = require('readline').createInterface({
  64. input: process.stdin, output: process.stdout, terminal: false
  65. });
  66.  
  67. readline.on('line', handle_command);
  68.  
  69. readline.on('close', function() {
  70. console.log('Have a great day!');
  71. process.exit(0);
  72. });
  73. }
  74.  
  75. var last_command;
  76. function handle_command(txt) {
  77. // hit return to repeat last line
  78. if (txt === '') {
  79. if (last_command)
  80. return handle_command(last_command);
  81. txt = '.help';
  82. }
  83.  
  84. last_command = txt;
  85.  
  86. if (!socket) {
  87. console.log('not connected');
  88. return;
  89. }
  90.  
  91. // lines that don't begin with a dot are sent as if entered in the chat box
  92. if (!txt.match(/^[.]/)) {
  93. socket.emit('chat', txt);
  94. return;
  95. }
  96.  
  97. txt = txt.substring(1);
  98.  
  99. // split command into array of words
  100. txt = txt.split(/\s+/);
  101.  
  102. try {
  103. switch (txt[0]) {
  104.  
  105. case 'b':
  106. case 'bet':
  107. bet(stake, chance, hilo);
  108. break;
  109.  
  110. case 'c':
  111. case 'chance':
  112. validate_number(txt[1]);
  113. chance = tidy(txt[1], 4);
  114. console.log('set chance to', chance + '%');
  115. break;
  116.  
  117. case 'h':
  118. case 'hi':
  119. case 'high':
  120. hilo = 'hi';
  121. console.log('set hi/lo to hi');
  122. break;
  123.  
  124. case 'l':
  125. case 'lo':
  126. case 'low':
  127. hilo = 'lo';
  128. console.log('set hi/lo to lo');
  129. break;
  130.  
  131. case 'login':
  132. validate_string(txt[1]);
  133. validate_string(txt[2]);
  134. console.log('attempting to log in <username> <password> [2FA code]');
  135. socket.emit('login', txt[1], txt[2], txt[3]);
  136. break;
  137.  
  138.  
  139. case 'n':
  140. case 'name':
  141. validate_string(txt[1]);
  142. console.log('attempting to change name to "' + txt[1] + '"');
  143. socket.emit('name', txt[1]);
  144. break;
  145.  
  146. case 'passwd':
  147. validate_string(txt[1]);
  148. validate_string(txt[2]);
  149. console.log('attempting to change password <from> <to>');
  150. socket.emit('change_password', txt[1], txt[2]);
  151. break;
  152.  
  153. case 'p':
  154. case 'payout':
  155. validate_number(txt[1]);
  156. chance = tidy(99 / txt[1], 4);
  157. console.log('set chance to', chance + '%');
  158. break;
  159.  
  160. case 's':
  161. case 'stake':
  162. validate_number(txt[1]);
  163. stake = tidy(txt[1], 8);
  164. console.log('set stake to', stake);
  165. break;
  166.  
  167. case 't':
  168. case 'tog':
  169. case 'toggle':
  170. hilo = 'tog';
  171. console.log('set hi/lo to toggle');
  172. break;
  173.  
  174. case 'userpass':
  175. validate_string(txt[1]);
  176. validate_string(txt[2]);
  177. console.log('attempting to set username to "' + txt[1] + '"');
  178. socket.emit('setup_account', txt[1], txt[2]);
  179. break;
  180.  
  181. case 'w':
  182. case 'wd':
  183. case 'withdraw':
  184. validate_address(txt[1]);
  185. validate_number(txt[2]);
  186. console.log('withdrawing', txt[2], 'to', txt[1]);
  187. socket.emit('withdraw', txt[1], txt[2], txt[3]);
  188. break;
  189.  
  190. case '?':
  191. case 'help':
  192. show_help();
  193. break;
  194.  
  195. default:
  196. console.log('unknown command;', txt[0]);
  197. break;
  198. }
  199. } catch (err) {
  200. console.log(err);
  201. }
  202. }
  203.  
  204. function validate_address(addr) {
  205. if (addr === undefined)
  206. throw new Error("missing required address");
  207.  
  208. if (!addr.match(/^x[1-9a-km-zA-HJ-NP-Z]{33}$/))
  209. throw new Error("invalid CLAM address");
  210. }
  211.  
  212. function validate_integer(num) {
  213. if (num === undefined)
  214. throw new Error("missing required integer");
  215.  
  216. if (!num.match(/^[1-9][0-9]*$/))
  217. throw new Error("number should have nothing other than digits in it");
  218. }
  219.  
  220. function validate_number(num) {
  221. if (num === undefined)
  222. throw new Error("missing required number");
  223.  
  224. if (!num.match(/[0-9]/))
  225. throw new Error("number should have some digits in it");
  226.  
  227. if (num.match(/[.].*[.]/))
  228. throw new Error("number should have no more than one dot in it");
  229.  
  230. if (!num.match(/^[0-9.]*$/))
  231. throw new Error("number should have nothing other than digits and dots in it");
  232. }
  233.  
  234. function validate_string(str) {
  235. if (str === undefined)
  236. throw new Error("missing required string");
  237. }
  238.  
  239.  
  240. function show_help() {
  241. 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)');
  242. console.log('hit return on its own to repeat last line');
  243. }
  244.  
  245. function tidy(val, fixed)
  246. {
  247. if (fixed === undefined)
  248. fixed=8;
  249.  
  250. if (typeof(val) == 'number')
  251. val = val.toFixed(fixed);
  252.  
  253. val = val.replace(/([.].*?)0+$/, '$1'); // remove trailing zeroes after the decimal point
  254. val = val.replace(/[.]$/, ''); // remove trailing decimal point
  255. return val;
  256. }
  257.  
  258. var last_hilo;
  259.  
  260. function bet(stake, chance, hilo) {
  261. if (bet_in_progress) {
  262. console.log('you have a bet in progress already');
  263. return;
  264. }
  265.  
  266. // if we're toggling, toggle
  267. if (hilo == 'tog') {
  268. if (last_hilo == 'hi')
  269. last_hilo = 'lo';
  270. else
  271. last_hilo = 'hi';
  272. } else
  273. // else just remember what we bet in case we toggle next time
  274. last_hilo = hilo;
  275.  
  276. console.log('BET:', stake, '@', tidy(chance, 4) + '%', last_hilo);
  277. bet_in_progress = true;
  278. socket.emit('bet', {chance: tidy(chance, 4), bet: stake, which: last_hilo});
  279. }
  280.  
  281. function login_then_run_bot(credentials) {
  282. login(credentials, function(err, cookie) {
  283. if (err) {
  284. console.log('ERROR:', err);
  285. return;
  286. }
  287.  
  288. console.log('logged in; got cookie (secret - do not share!):');
  289. console.log(cookie);
  290. run_bot(cookie);
  291. });
  292. }
  293.  
  294. function login(credentials, cb) {
  295. var jar = request.jar();
  296.  
  297. req = {url: url, jar: jar, form: {}}
  298.  
  299. if (credentials.hash) {
  300. if (credentials.username || credentials.password)
  301. return cb('either specify a hash or a username and password');
  302. jar.setCookie(request.cookie('hash=' + credentials.hash), url);
  303. }
  304.  
  305. if (credentials.username) req.form.username = credentials.username;
  306. if (credentials.password) req.form.password = credentials.password;
  307. if (credentials.code) req.form.code = credentials.code;
  308.  
  309. request.post(req, function(err, res, body) {
  310. if (err)
  311. return cb(err);
  312.  
  313. // console.log(body);
  314.  
  315. if (body.match(/Please enter your 6 digit google authentification number/))
  316. return cb('that account requires a correct 2FA code and hash to log in; 2FA codes can only be used once each');
  317.  
  318. if (body.match(/Your account is set up to require a google authentification code for this action/))
  319. return cb('that account requires a 2FA code in addition to the username and password to log in');
  320.  
  321. if (body.match(/Please enter your username/))
  322. return cb('that account requires a correct username and password, and possibly 2FA code; 2FA codes can only be used once each');
  323.  
  324. var cookie = jar.getCookieString(url);
  325.  
  326. if (!cookie.match(/hash=/))
  327. return cb('bad hash');
  328.  
  329. return cb(null, cookie);
  330. });
  331. }
  332.  
  333. var first_login = true;
  334.  
  335. function run_bot(cookie) {
  336. if (first_login) {
  337. init_readline();
  338. first_login = false;
  339. }
  340.  
  341. show_help();
  342.  
  343. var transport = 'websocket';
  344. // var transport = 'polling';
  345.  
  346. var inits = 0;
  347.  
  348. socket = require("socket.io-client")(url, {transports: [transport],
  349. extraHeaders: {
  350. origin: url,
  351. cookie: cookie
  352. }});
  353.  
  354.  
  355.  
  356. socket.on('error', function(err) {
  357. console.log('caught error:', err);
  358. });
  359.  
  360.  
  361.  
  362. socket.on('set_hash', function(hash) {
  363. console.log('INFO:', 'server requested that we reconnect...');
  364. socket.close();
  365. run_bot(cookie);
  366. });
  367.  
  368. socket.on('chat', function(txt, date) {
  369. console.log('CHAT:', txt);
  370. });
  371. }
  372.  
  373. function go(){
  374. socket.on('wins', function(count) {
  375. bet_in_progress = false;
  376. balance = balance+james;
  377. bet(stake, chance, hilo);
  378. });
  379.  
  380. socket.on('losses', function(count) {
  381. bet_in_progress = false;
  382. balance = balance-james;
  383. bet(stake, chance, hilo);
  384. });
  385. if (balance < crazy && future <= 3) {
  386. future += 1;
  387. jim = (jim + arnie);
  388. jly = (old - balance);
  389. james = (jly + jim - arnie);
  390. madman = (james);
  391. lol = parseFloat(balance);
  392. crazy = parseFloat(balance);
  393. }
  394.  
  395. if (balance < crazy && future > 3 && balance < score) {
  396. future += 1;
  397. james = (madman);
  398. crazy = parseFloat(balance);
  399. }
  400.  
  401. if (balance > crazy && balance < score) {
  402. james = (madman);
  403. crazy = parseFloat(balance);
  404. }
  405.  
  406. if (future > 3 && balance < lol - james * 1.9) {
  407. james = (james + james);
  408. madman = james;
  409. lol = parseFloat(balance);
  410. }
  411.  
  412. if (balance >= score) {
  413. arnie = parseFloat(balance) / 1440000;
  414. jim = (arnie);
  415. james = (arnie);
  416. jly = 0;
  417. future = 0;
  418. old = parseFloat(balance);
  419. lol = parseFloat(balance);
  420. crazy = parseFloat(balance);
  421. madman = parseInt(james);
  422. score = parseFloat(balance);
  423. }
  424.  
  425.  
  426.  
  427. stake = james.toFixed(8);
  428. hilo = 'lo'
  429. chance = 49.5
  430. }
  431. setTimeout(() => go(), 40000);
  432.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement