Skip to content

Commit 2069d20

Browse files
author
mydicebot
committed
v190703 duckdice added
1 parent 4ca2ef3 commit 2069d20

File tree

6 files changed

+300
-9
lines changed

6 files changed

+300
-9
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# MyDiceBot
33
* [https://mydicebot.com](https://mydicebot.com)
44
* [MyDiceBot](https://mydicebot.com) is World #1 Cross-Platform Dicing Bot.
5-
* Multiple platforms are supported, including __Windows, Mac, Linux,__ and __Web__.
5+
* Multiple platforms are supported, including __Windows, Mac, Linux, Web__ and __Android__.
66
* Multiple blockchains are supported, including __STEEM__.
77
* Multiple programming languages are supported such as __Lua__ and __Javascript__.
88
* [Open Source](https://github.com/mydicebot/mydicebot.github.io) and __Free Forever__.
@@ -44,6 +44,7 @@
4444
* [999Dice](https://www.999dice.com/?224280708)
4545
* [Bitsler](https://www.bitsler.com/?ref=mydicebot)
4646
* [Crypto-Games](https://www.crypto-games.net?i=CpQP3V8Up2)
47+
* [DuckDice](https://duckdice.com/ab61534783)
4748
* [PrimeDice](https://primedice.com/?c=mydicebot)
4849
* [Stake](https://stake.com/?code=mydicebot)
4950
* [YoloDice](https://yolodice.com/r?6fAf-wVz)
@@ -57,7 +58,6 @@
5758
* [BitDice (coming soon)](https://www.bitdice.me/?r=90479)
5859
* [BitVest (coming soon)](https://bitvest.io?r=108792)
5960
* [Dice-Bet (coming soon)](https://dice-bet.com/?ref=u:mydicebot)
60-
* [DuckDice (coming soon)](https://duckdice.com/ab61534783)
6161
* [Freebitco.in (coming soon)](https://freebitco.in/?r=16392656)
6262
* [KingDice (coming soon)](https://kingdice.com/#/welcome?aff=180722)
6363
* [MegaDice (coming soon)](https://www.megadice.com/?a=326492144)
@@ -99,7 +99,7 @@
9999
* Bet and WIN.
100100
101101
# Features
102-
* Supported platforms: __Windows, Mac, Linux, Web__
102+
* Supported platforms: __Windows, Mac, Linux, Web__ and __Android__
103103
* Supported programming languages: __Lua__ and __Javascript__
104104
* Supported multiple dice-sites
105105
* Supported multiple strategies
@@ -109,8 +109,9 @@
109109
* Manual bet
110110
* Auto bet
111111
* Script bet (__compatible with Seuntjies DiceBot scripts__)
112+
* Chat room
112113
* Script upload/download/voting (coming soon)
113-
* Github integration (coming soon)
114+
* Github/STEEM/Google Login integration
114115
115116
# Manual Bet
116117
* You can control every bet by yourself.
@@ -124,7 +125,7 @@
124125
125126
# Script Bet
126127
* Lua programming language
127-
* JavaScript programming language (coming soon)
128+
* JavaScript programming language
128129
* Python programming language (coming soon)
129130
* __Compatible with the variables and functions of Seuntjie DiceBot's Lua script__
130131

src/api/models/duckdice.js

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
'use strict';
2+
3+
import {BaseDice} from './base'
4+
import fetch from 'isomorphic-fetch';
5+
import FormData from 'form-data';
6+
import {APIError} from '../errors/APIError'
7+
8+
export class DuckDice extends BaseDice {
9+
constructor(){
10+
super();
11+
this.url = 'https://duckdice.io';
12+
this.benefit = '&c=ab61534783'
13+
}
14+
15+
async login(userName, password, twoFactor ,apiKey, req) {
16+
let ret = await this._send('stat/btc?api_key='+ apiKey, 'GET', '', '');
17+
req.session.accessToken = apiKey;
18+
req.session.username = apiKey;
19+
return true;
20+
}
21+
22+
async getUserInfo(req) {
23+
return true
24+
}
25+
26+
async refresh(req) {
27+
let formData = new FormData();
28+
let info = req.session.info;
29+
if(info){
30+
console.log("info is not null");
31+
return info;
32+
}
33+
let accessToken = req.session.accessToken;
34+
let ret = await this._send('stat/'+req.query.currency+'?api_key='+ accessToken, 'GET', '','');
35+
let userinfo = {};
36+
userinfo.bets = ret.bets;
37+
userinfo.wins = ret.wins;
38+
userinfo.losses = ret.bets - ret.wins;
39+
userinfo.profit = ret.profit;
40+
userinfo.wagered = ret.volume;
41+
ret = await this._send('load/'+req.query.currency+'?api_key='+ accessToken, 'GET', '','');
42+
userinfo.balance = ret.user.balance;
43+
userinfo.success = true;
44+
info.info = userinfo;
45+
req.session.info = info;
46+
return info;
47+
}
48+
49+
async clear(req) {
50+
let accessToken = req.session.accessToken;
51+
let info = {};
52+
let ret = await this._send('stat/'+req.query.currency+'?api_key='+ accessToken, 'GET', '','');
53+
let userinfo = {};
54+
userinfo.bets = ret.bets;
55+
userinfo.wins = ret.wins;
56+
userinfo.losses = ret.bets - ret.wins;
57+
userinfo.profit = ret.profit;
58+
userinfo.wagered = ret.volume;
59+
ret = await this._send('load/'+req.query.currency+'?api_key='+ accessToken, 'GET', '','');
60+
userinfo.balance = ret.user.balance;
61+
userinfo.success = true;
62+
info.info = userinfo;
63+
info.currentInfo = {};
64+
info.currentInfo.balance = ret.user.balance;
65+
info.currentInfo.bets = 0;
66+
info.currentInfo.wins = 0;
67+
info.currentInfo.losses = 0;
68+
info.currentInfo.profit = 0;
69+
info.currentInfo.wagered = 0;
70+
req.session.info = info;
71+
return info;
72+
}
73+
74+
async bet(req) {
75+
let data = {};
76+
let accessToken = req.session.accessToken;
77+
data.amount = parseFloat(req.body.PayIn/100000000).toFixed(8);
78+
data.symbol = req.body.Currency.toLowerCase();
79+
let condition = req.body.High == "true"?true:false;
80+
let game = 0;
81+
if(req.body.High == "true"){
82+
game = 9999-Math.floor((req.body.Chance*100));
83+
} else {
84+
game = Math.floor((req.body.Chance*100))-1;
85+
}
86+
data.chance = parseFloat(req.body.Chance).toFixed(2);
87+
data.isHigh = condition;
88+
89+
let ret = await this._send('play?api_key='+ accessToken, 'POST',data,'');
90+
let info = req.session.info;
91+
let betInfo = ret.bet;
92+
betInfo.condition = req.body.High == "true"?'>':'<';
93+
betInfo.id = betInfo.hash;
94+
betInfo.target = parseFloat(game/100).toFixed(2);;
95+
betInfo.result = parseFloat(betInfo.number/100).toFixed(2);
96+
betInfo.amount = betInfo.betAmount;
97+
info.info.bets++;
98+
info.currentInfo.bets++;
99+
info.info.profit = parseFloat(info.info.profit) + parseFloat(betInfo.profit);
100+
info.info.balance = ret.user.balance;
101+
info.currentInfo.balance = ret.user.balance;
102+
info.info.wagered = parseFloat(info.info.wagered) + parseFloat(betInfo.amount);
103+
info.currentInfo.wagered = parseFloat(info.currentInfo.wagered) + parseFloat(betInfo.amount);
104+
info.currentInfo.profit = parseFloat(info.currentInfo.profit) + parseFloat(betInfo.profit);
105+
if(betInfo.profit>0){
106+
betInfo.win = true;
107+
info.info.wins++;
108+
info.currentInfo.wins++;
109+
} else {
110+
betInfo.win = false;
111+
info.info.losses++;
112+
info.currentInfo.losses++;
113+
}
114+
let returnInfo = {};
115+
returnInfo.betInfo= betInfo;
116+
returnInfo.info = info;
117+
req.session.info = info;
118+
console.log(returnInfo.betInfo);
119+
return returnInfo;
120+
}
121+
122+
async _send(route, method, body, accessToken){
123+
let url = `${this.url}/api/${route}${this.benefit}`;
124+
let res = null;
125+
if(method == "POST"){
126+
res = await fetch(url, {
127+
method,
128+
headers: {
129+
Accept: 'application/json',
130+
'User-Agent': 'MyDiceBot',
131+
'Content-Type': 'application/json',
132+
},
133+
body: JSON.stringify(body),
134+
});
135+
} else {
136+
res = await fetch(url, {
137+
method,
138+
headers: {
139+
'User-Agent': 'MyDiceBot',
140+
},
141+
});
142+
}
143+
let data = await res.json();
144+
if (data.error) {
145+
let errs = new Error(data.error);
146+
errs.value = data.error;
147+
throw new APIError(data.error ,errs);
148+
}
149+
return data;
150+
}
151+
}

src/api/routes/api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Simulator} from '../models/simulator';
1313
import {EpicDice} from '../models/epic';
1414
import {SteemBet} from '../models/steembet';
1515
import {KryptoGames} from '../models/kryptogames';
16+
import {DuckDice} from '../models/duckdice';
1617
import {Factory} from '../models/factory';
1718
import fs from 'fs';
1819
import path from 'path';
@@ -75,6 +76,7 @@ function createDice (req, res, next) {
7576
Factory.register('EpicDice', new EpicDice());
7677
Factory.register('SteemBet', new SteemBet());
7778
Factory.register('KryptoGames', new KryptoGames());
79+
Factory.register('DuckDice', new DuckDice());
7880
next();
7981
}
8082

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "mydicebot-190628",
2+
"name": "mydicebot-190703",
33
"version": "0.0.1",
44
"description": "My Dice Bot",
55
"homepage": "https://mydicebot.com",

src/public/js/DuckDice/info.js

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
function init() {
2+
console.log('hello DuckDice');
3+
$$("bet_currency_selection").define("options", [
4+
{id:1,value:"BTC"},
5+
{id:2,value:"DOGE"},
6+
{id:3,value:"LTC"},
7+
{id:4,value:"ETH"},
8+
{id:5,value:"DASH"},
9+
{id:6,value:"BCH"},
10+
{id:7,value:"XRP"},
11+
{id:8,value:"XMR"},
12+
{id:9,value:"ETC"},
13+
{id:10,value:"BTG"},
14+
{id:11,value:"ZEC"},
15+
{id:12,value:"XLM"},
16+
{id:13,value:"USDT"},
17+
]);
18+
$$("bet_currency_selection").refresh();
19+
minBetAmount = 0.00000001;
20+
$$("manual_bet_amount").setValue(minBetAmount.toFixed(8));
21+
$$("auto_bet_base_amount").setValue(minBetAmount.toFixed(8));
22+
}
23+
24+
function checkParams(p,ch){
25+
//console.log(p,ch);
26+
if(p < 0.00000001 || p > 1000000000*1000000000) {
27+
return false
28+
}
29+
if(ch>98 || ch<1) {
30+
return false
31+
}
32+
return true;
33+
}
34+
35+
function initScriptBalance(currencyValue, cb){
36+
getInfo(function(userinfo){
37+
if(userinfo.info.success == true){
38+
try {
39+
balance = userinfo.info.balance;
40+
bets = userinfo.info.bets;
41+
wins = userinfo.info.wins;
42+
losses = userinfo.info.losses;
43+
profit = userinfo.info.profit;
44+
} catch(err){
45+
console.error(err.message);
46+
webix.message({type: 'error', text: err.message});
47+
return false;
48+
}
49+
cb();
50+
}
51+
});
52+
}
53+
54+
function getBalance(userinfo){
55+
balance = userinfo.info.balance
56+
return balance;
57+
}
58+
59+
function getProfit(userinfo){
60+
profit = userinfo.currentInfo.profit;
61+
//console.log('actprofit:'+actProfit);
62+
return profit;
63+
}
64+
65+
function getCurrProfit(ret){
66+
currentprofit = ret.betInfo.profit
67+
//console.log('currprofit:'+currProfit);
68+
return currentprofit;
69+
}
70+
71+
function getCurrentBetId(ret){
72+
let betId = ret.betInfo.id;
73+
//console.log('currentBetId:'+betId);
74+
return betId;
75+
}
76+
77+
function getCurrentRoll(ret){
78+
currentroll = ret.betInfo.result;
79+
return currentroll;
80+
}
81+
82+
function outError(ret){
83+
let mess = ret.err;
84+
return checkerr(mess);
85+
}
86+
87+
function isError(ret){
88+
if(typeof ret.err != "undefined")
89+
return false;
90+
else
91+
return true;
92+
}
93+
94+
function getWinStatus(ret){
95+
return ret.betInfo.win;
96+
}
97+
98+
function setDatatable(ret){
99+
let chanceStr = '<font size="3" color="red">'+ ret.betInfo.condition + ' '+ ret.betInfo.target +'</font>';
100+
if(ret.betInfo.win){
101+
chanceStr = '<font size="3" color="green">'+ ret.betInfo.condition + ' '+ ret.betInfo.target +'</font>';
102+
}
103+
let profitStr = '<font size="3" color="red">' + ret.betInfo.profit+ '</font>';
104+
if(ret.betInfo.profit>0) {
105+
profitStr = '<font size="3" color="green">' + ret.betInfo.profit + '</font>';
106+
}
107+
$$('bet_datatable').add({
108+
bet_datatable_id:ret.betInfo.id,
109+
bet_datatable_amount:ret.betInfo.amount,
110+
bet_datatable_low_high:ret.betInfo.condition,
111+
bet_datatable_payout:(ret.betInfo.payout).toFixed(8),
112+
bet_datatable_bet_chance:chanceStr,
113+
bet_datatable_actual_chance:ret.betInfo.result,
114+
bet_datatable_profit:profitStr,
115+
},0);
116+
}
117+
118+
function setStats(userinfo, cv){
119+
if(userinfo.info.success == true){
120+
$$('bet_total_stats').setValues({
121+
bet_total_stats_balance:userinfo.info.balance,
122+
bet_total_stats_win:userinfo.info.wins,
123+
bet_total_stats_loss:userinfo.info.losses,
124+
bet_total_stats_bet:userinfo.info.bets,
125+
bet_total_stats_profit:userinfo.info.profit,
126+
bet_total_stats_wagered:userinfo.info.wagered,
127+
});
128+
$$('bet_current_stats').setValues({
129+
bet_current_stats_balance:userinfo.currentInfo.balance,
130+
bet_current_stats_win:userinfo.currentInfo.wins,
131+
bet_current_stats_loss:userinfo.currentInfo.losses,
132+
bet_current_stats_bet:userinfo.currentInfo.bets,
133+
bet_current_stats_profit:userinfo.currentInfo.profit,
134+
bet_current_stats_wagered:userinfo.currentInfo.wagered,
135+
});
136+
}
137+
}

0 commit comments

Comments
 (0)