Skip to content

Commit 762ad11

Browse files
author
bot
committed
new version
1 parent 2a596ea commit 762ad11

File tree

9 files changed

+77
-64
lines changed

9 files changed

+77
-64
lines changed

src/api/models/crypto.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ var APIError = require('../errors/APIError');
88
module.exports = class CryptoDice extends BaseDice {
99
constructor(){
1010
super();
11-
this.url = 'https://api.crypto-games.net';
11+
//this.url = 'https://api.crypto-games.net';
12+
this.url = 'https://api.crypto.games';
1213
}
1314

1415
async login(userName, password, twoFactor ,apiKey, req) {

src/api/models/prime.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
var BaseDice = require('./base');
44
var APIError = require('../errors/APIError');
5-
var request = require('graphql-request').request;
6-
var GraphQLClient = require('graphql-request').GraphQLClient;
5+
var fetch = require('isomorphic-fetch');
76

87
module.exports = class PrimeDice extends BaseDice {
98
constructor(){
@@ -14,7 +13,8 @@ module.exports = class PrimeDice extends BaseDice {
1413
}
1514

1615
async login(userName, password, twoFactor ,apiKey, req) {
17-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses amount profit currency}}}";
16+
let data = {};
17+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses amount profit currency}}}";
1818
let ret = await this._send('', 'POST', data, apiKey);
1919
req.session.accessToken = apiKey;
2020
req.session.username = apiKey;
@@ -31,7 +31,8 @@ module.exports = class PrimeDice extends BaseDice {
3131
if(!info){
3232
return false;
3333
}
34-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
34+
let data = {};
35+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
3536
let ret = await this._send('', 'POST', data, req.session.accessToken);
3637
ret = ret.user;
3738
let userinfo = {
@@ -64,7 +65,8 @@ module.exports = class PrimeDice extends BaseDice {
6465

6566
async clear(req) {
6667
console.log('loading....');
67-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
68+
let data = {};
69+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
6870
let ret = await this._send('', 'POST', data, req.session.accessToken);
6971
ret=ret.user;
7072
let info = {};
@@ -118,12 +120,14 @@ module.exports = class PrimeDice extends BaseDice {
118120
target = Math.floor((req.body.Chance*100));
119121
}
120122
target = parseFloat(target/100).toFixed(2);
121-
let data = " mutation{primediceRoll(amount:"+amount+",target:"+target+",condition:"+ condition +",currency:"+currency+ ") { id nonce currency amount payout state { ... on CasinoGamePrimedice { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
123+
let data = {};
124+
data.query = " mutation{primediceRoll(amount:"+amount+",target:"+target+",condition:"+ condition +",currency:"+currency+ ") { id nonce currency amount payout state { ... on CasinoGamePrimedice { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
122125
let ret = await this._send('', 'POST', data, req.session.accessToken);
123126
let info = req.session.info;
124127
let betInfo = ret.primediceRoll;
125-
let queryIID = " query{bet(betId:\""+betInfo.id+"\"){iid}}";
126-
let dataIID = await this._send('', 'POST', queryIID, req.session.accessToken);
128+
data = {};
129+
data.query = "{bet(betId:\""+betInfo.id+"\"){iid}}";
130+
let dataIID = await this._send('', 'POST', data, req.session.accessToken);
127131
betInfo.iid = dataIID.bet.iid.split(":")[1];
128132
betInfo.condition = req.body.High == "true"?'>':'<';
129133
betInfo.target = target;
@@ -157,7 +161,8 @@ module.exports = class PrimeDice extends BaseDice {
157161

158162
async resetseed(req) {
159163
let clientSeed = Math.random().toString(36).substring(2);
160-
let data = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + clientSeed + "\"){seed}}"
164+
data = {};
165+
data.query = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + clientSeed + "\"){seed}}"
161166
let ret = await this._send('', 'POST', data, req.session.accessToken);
162167
console.log(clientSeed, ret);
163168
let info = {};
@@ -168,27 +173,26 @@ module.exports = class PrimeDice extends BaseDice {
168173
}
169174

170175
async _send(route, method, body, accessToken){
171-
let endpoint =`${this.url}`;
172-
173-
let graphQLClient = new GraphQLClient(endpoint, {
176+
console.log(JSON.stringify(body));
177+
let url = `${this.url}`;
178+
let res = await fetch(url, {
179+
method,
174180
headers: {
181+
'User-Agent': 'MyDiceBot',
175182
'x-access-token': accessToken,
183+
'Content-Type': 'application/json',
176184
},
177-
})
178-
try {
179-
let res = await graphQLClient.request(body);
180-
return res;
181-
} catch(err) {
182-
if(err.response.errors) {
183-
let errs = new Error(err.response.errors[0].message);
184-
errs.value = err.response.errors[0].message;
185-
throw new APIError(err.response.errors[0].message, errs);
186-
} else {
187-
let errs = new Error(err.response.error);
188-
errs.value = err.response.error;
189-
throw new APIError(err.response.error, errs);
190-
}
185+
body: JSON.stringify(body),
186+
});
187+
let data = await res.json();
188+
console.log(data);
189+
if(data.errors) {
190+
let errs = new Error(data.errors[0].message);
191+
errs.value = data.errors[0].message;
192+
throw new APIError(data.errors[0].message ,errs);
191193
}
194+
let ret = data.data;
195+
return ret;
192196
}
193197
}
194198
exports.PrimeDice

src/api/models/stake.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
var BaseDice = require('./base');
44
var APIError = require('../errors/APIError');
5-
var request = require('graphql-request').request;
6-
var GraphQLClient = require('graphql-request').GraphQLClient;
5+
var fetch = require('isomorphic-fetch');
76

87
module.exports = class StakeDice extends BaseDice {
98
constructor(){
@@ -14,7 +13,8 @@ module.exports = class StakeDice extends BaseDice {
1413
}
1514

1615
async login(userName, password, twoFactor ,apiKey, req) {
17-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
16+
let data = {};
17+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses amount profit currency}}}";
1818
let ret = await this._send('', 'POST', data, apiKey);
1919
req.session.accessToken = apiKey;
2020
req.session.username = apiKey;
@@ -31,7 +31,8 @@ module.exports = class StakeDice extends BaseDice {
3131
if(!info){
3232
return false;
3333
}
34-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
34+
let data = {};
35+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
3536
let ret = await this._send('', 'POST', data, req.session.accessToken);
3637
ret = ret.user;
3738
let userinfo = {
@@ -64,7 +65,8 @@ module.exports = class StakeDice extends BaseDice {
6465

6566
async clear(req) {
6667
console.log('loading....');
67-
let data = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
68+
let data = {};
69+
data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}";
6870
let ret = await this._send('', 'POST', data, req.session.accessToken);
6971
ret=ret.user;
7072
let info = {};
@@ -118,12 +120,14 @@ module.exports = class StakeDice extends BaseDice {
118120
target = Math.floor((req.body.Chance*10000))-1;
119121
}
120122
target = parseFloat(target/10000).toFixed(2);
121-
let data = " mutation{diceRoll(amount:"+amount+",target:"+target+",condition:"+ condition +",currency:"+currency+ ") { id nonce currency amount payout state { ... on CasinoGameDice { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
123+
let data = {};
124+
data.query = " mutation{diceRoll(amount:"+amount+",target:"+target+",condition:"+ condition +",currency:"+currency+ ") { id nonce currency amount payout state { ... on CasinoGameDice { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
122125
let ret = await this._send('', 'POST', data, req.session.accessToken);
123126
let info = req.session.info;
124127
let betInfo = ret.diceRoll;
125-
let queryIID = " query{bet(betId:\""+betInfo.id+"\"){iid}}";
126-
let dataIID = await this._send('', 'POST', queryIID, req.session.accessToken);
128+
data = {};
129+
data.query = "{bet(betId:\""+betInfo.id+"\"){iid}}";
130+
let dataIID = await this._send('', 'POST', data, req.session.accessToken);
127131
betInfo.iid = dataIID.bet.iid.split(":")[1];
128132
betInfo.condition = req.body.High == "true"?'>':'<';
129133
betInfo.target = target;
@@ -157,7 +161,8 @@ module.exports = class StakeDice extends BaseDice {
157161

158162
async resetseed(req) {
159163
let clientSeed = Math.random().toString(36).substring(2);
160-
let data = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + clientSeed + "\"){seed}}"
164+
data = {};
165+
data.query = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + clientSeed + "\"){seed}}"
161166
let ret = await this._send('', 'POST', data, req.session.accessToken);
162167
console.log(clientSeed, ret);
163168
let info = {};
@@ -168,27 +173,26 @@ module.exports = class StakeDice extends BaseDice {
168173
}
169174

170175
async _send(route, method, body, accessToken){
171-
let endpoint =`${this.url}`;
172-
173-
let graphQLClient = new GraphQLClient(endpoint, {
176+
console.log(JSON.stringify(body));
177+
let url = `${this.url}`;
178+
let res = await fetch(url, {
179+
method,
174180
headers: {
181+
'User-Agent': 'MyDiceBot',
175182
'x-access-token': accessToken,
183+
'Content-Type': 'application/json',
176184
},
177-
})
178-
try {
179-
let res = await graphQLClient.request(body);
180-
return res;
181-
} catch(err) {
182-
if(err.response.errors) {
183-
let errs = new Error(err.response.errors[0].message);
184-
errs.value = err.response.errors[0].message;
185-
throw new APIError(err.response.errors[0].message, errs);
186-
} else {
187-
let errs = new Error(err.response.error);
188-
errs.value = err.response.error;
189-
throw new APIError(err.response.error, errs);
190-
}
185+
body: JSON.stringify(body),
186+
});
187+
let data = await res.json();
188+
console.log(data);
189+
if(data.errors) {
190+
let errs = new Error(data.errors[0].message);
191+
errs.value = data.errors[0].message;
192+
throw new APIError(data.errors[0].message ,errs);
191193
}
194+
let ret = data.data;
195+
return ret;
192196
}
193197
}
194198
exports.StakeDice

src/package.json.console

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "mydicebot-console-200516",
2+
"name": "mydicebot-console-200530",
33
"version": "1.0.0",
44
"description": "MyDiceBot - Bet more, earn more!",
55
"homepage": "https://mydicebot.com",
@@ -32,7 +32,6 @@
3232
"body-parser": "^1.10.2",
3333
"formidable": "^1.2.1",
3434
"fs-extra": "^8.1.0",
35-
"graphql-request": "^1.8.2",
3635
"isomorphic-fetch": "^2.2.1",
3736
"mathjs": "^6.6.1",
3837
"minimist": "^1.2.0",

src/public/css/contrast.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4017,8 +4017,8 @@ legend.webix_forminput_label_top {
40174017
font-family: "Webix Awesome Icons";
40184018
font-size: 50px;
40194019
position: absolute;
4020-
left: 90%;
4021-
top: 20%;
4020+
left: 50%;
4021+
top: 50%;
40224022
margin-left: -25px;
40234023
margin-top: -25px;
40244024
display: inline-block;

src/public/css/material.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5049,8 +5049,8 @@ legend.webix_forminput_label_top {
50495049
font-family: "Webix Material Icons";
50505050
font-size: 50px;
50515051
position: absolute;
5052-
left: 90%;
5053-
top: 20%;
5052+
left: 50%;
5053+
top: 50%;
50545054
margin-left: -25px;
50555055
margin-top: -25px;
50565056
display: inline-block;

src/public/js/reg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var registerUrls = {
55
"BitDice":"https://www.bitdice.me/?r=90479",
66
"Bitsler":"https://www.bitsler.com/?ref=mydicebot",
77
"BitVest":"https://bitvest.io?r=108792",
8-
"Crypto-Games":"https://www.crypto-games.net?i=CpQP3V8Up2",
8+
"Crypto-Games":"https://crypto.games?i=CpQP3V8Up2",
99
"Dice-Bet":"https://dice-bet.com/?ref=u:mydicebot",
1010
"WolfBet":"https://wolf.bet/?c=mydicebot",
1111
"DuckDice":"https://duckdice.com/ab61534783",

src/views/info.pug

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,7 @@ block content
19851985
document.getElementById("python_stop_button").click();
19861986
}
19871987
} else {
1988+
resetBetTime();
19881989
start(true);
19891990
}
19901991
});
@@ -2002,6 +2003,7 @@ block content
20022003
});
20032004
$$("auto_bet_start_stop_button").setValue('STOP');
20042005
autoBet();
2006+
resetBetTime();
20052007
betTime();
20062008
isloop = true;
20072009
stopOnWin = false;
@@ -2195,11 +2197,9 @@ block content
21952197
resetseed();
21962198
});
21972199
function resetsession(){
2198-
bets = 0;
2199-
totalprofit = 0;
2200-
difftime = 0;
22012200
currencyValue = $$("bet_currency_selection").getValue();
22022201
refresh(currencyValue);
2202+
resetBetTime();
22032203
}
22042204
function resetseed(){
22052205
let now = Math.floor(Date.now()/1000);
@@ -3070,6 +3070,11 @@ block content
30703070
function stopBetTime() {
30713071
clearTimeout(settime);
30723072
}
3073+
function resetBetTime() {
3074+
bets = 0;
3075+
totalprofit = 0;
3076+
difftime = 0;
3077+
}
30733078
try {
30743079
require('electron').ipcRenderer.on('chart', (event, message) => {
30753080
if (message == 'show') {

src/views/login.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ block content
296296
{view: "label", label: "<a target='_blank' href='https://www.999dice.com/?224280708'>999Dice</a>"},
297297
{view: "label", label: "<a target='_blank' href='https://www.999doge.com/?224280708'>999Doge</a>"},
298298
{view: "label", label: "<a target='_blank' href='https://www.bitsler.com/?ref=mydicebot'>Bitsler</a>"},
299-
{view: "label", label: "<a target='_blank' href='https://www.crypto.games/?i=CpQP3V8Up2'>Crypto-Games</a>"},
299+
{view: "label", label: "<a target='_blank' href='https://crypto.games/?i=CpQP3V8Up2'>Crypto-Games</a>"},
300300
{view: "label", label: "<a target='_blank' href='https://duckdice.com/ab61534783'>DuckDice</a>"},
301301
{view: "label", label: "<a target='_blank' href='https://freebitco.in/?r=16392656'>Freebitco.in</a>"},
302302
{view: "label", label: "<a target='_blank' href='https://paradice.in/?c=mydicebot'>ParaDice</a>"},

0 commit comments

Comments
 (0)