@@ -15,7 +15,8 @@ module.exports = class PrimeDice extends BaseDice {
1515
1616 async login ( userName , password , twoFactor , apiKey , req ) {
1717 let data = { } ;
18- data . query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses amount profit currency}}}" ;
18+ //data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses amount profit currency} }}";
19+ data . query = "query DiceBotGetBalance{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" ;
1920 let ret = await this . _send ( '' , 'POST' , data , apiKey ) ;
2021 req . session . accessToken = apiKey ;
2122 req . session . username = apiKey ;
@@ -33,7 +34,8 @@ module.exports = class PrimeDice extends BaseDice {
3334 return false ;
3435 }
3536 let data = { } ;
36- data . query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" ;
37+ //data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency} }}";
38+ data . query = "query DiceBotGetBalance{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" ;
3739 let ret = await this . _send ( '' , 'POST' , data , req . session . accessToken ) ;
3840 ret = ret . user ;
3941 let userinfo = {
@@ -67,7 +69,8 @@ module.exports = class PrimeDice extends BaseDice {
6769 async clear ( req ) {
6870 console . log ( 'loading....' ) ;
6971 let data = { } ;
70- data . query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" ;
72+ //data.query = "{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency} }}";
73+ data . query = "query DiceBotGetBalance{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" ;
7174 let ret = await this . _send ( '' , 'POST' , data , req . session . accessToken ) ;
7275 ret = ret . user ;
7376 let info = { } ;
@@ -121,14 +124,23 @@ module.exports = class PrimeDice extends BaseDice {
121124 target = Math . floor ( ( req . body . Chance * 100 ) ) ;
122125 }
123126 target = parseFloat ( target / 100 ) . toFixed ( 2 ) ;
124- let data = { } ;
125- 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}}}}" ;
126- let ret = await this . _send ( '' , 'POST' , data , req . session . accessToken ) ;
127+ //let data = {};
128+ //data.query = "mutation DiceBotDiceBet($amount: Float!, $target: Float!, $condition: CasinoGamePrimediceConditionEnum!, $currency: CurrencyEnum!, $identifier: String!) { primediceRoll(amount: $amount, target: $target, condition: $condition, currency: $currency, identifier: $identifier) { 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}} }}";
129+ //let variables = {};
130+ //variables.amount = amount;
131+ //variables.target = target;
132+ //variables.condition = condition;
133+ //variables.currency = currency;
134+ //data.variables = variables;
135+ let betdata = "{\"operationName\":\"PrimediceRoll\",\"variables\":{\"currency\":\"" + currency + "\",\"amount\":" + amount + ",\"target\":" + target + ",\"condition\":\"" + condition + "\"},\"query\":\"mutation PrimediceRoll($amount: Float!, $target: Float!, $condition: CasinoGamePrimediceConditionEnum!, $currency: CurrencyEnum!) {\\n primediceRoll(amount: $amount, target: $target, condition: $condition, currency: $currency) {\\n ...CasinoBetFragment\\n state {\\n ...PrimediceStateFragment\\n __typename\\n }\\n __typename\\n }\\n}\\n\\nfragment CasinoBetFragment on CasinoBet {\\n id\\n active\\n payoutMultiplier\\n amountMultiplier\\n amount\\n payout\\n updatedAt\\n currency\\n game\\n user {\\n id\\n name\\n __typename\\n }\\n __typename\\n}\\n\\nfragment PrimediceStateFragment on CasinoGamePrimedice {\\n result\\n target\\n condition\\n __typename\\n}\\n\"}" ;
136+ let ret = await this . _sendbet ( '' , 'POST' , betdata , req . session . accessToken ) ;
127137 let info = req . session . info ;
128138 let betInfo = ret . primediceRoll ;
129- data = { } ;
130- data . query = "{bet(betId:\"" + betInfo . id + "\"){iid}}" ;
131- let dataIID = await this . _send ( '' , 'POST' , data , req . session . accessToken ) ;
139+ //console.log(betInfo);
140+ betdata = "{\"operationName\":\"Bet\",\"variables\":{\"betId\":\"" + betInfo . id + "\"},\"query\":\"query Bet($iid: String, $betId: String) {\\n bet(iid: $iid, betId: $betId) {\\n ...PrimediceBetFragment\\n __typename\\n }\\n}\\n\\nfragment PrimediceBetFragment on Bet {\\n id\\n iid\\n type\\n bet {\\n ... on CasinoBet {\\n ...CasinoBetFragment\\n state {\\n ... on CasinoGamePrimedice {\\n result\\n target\\n condition\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n}\\n\\nfragment CasinoBetFragment on CasinoBet {\\n id\\n active\\n payoutMultiplier\\n amount\\n payout\\n updatedAt\\n currency\\n game\\n user {\\n id\\n name\\n __typename\\n }\\n __typename\\n}\\n\"}" ;
141+
142+ let dataIID = await this . _sendbet ( '' , 'POST' , betdata , req . session . accessToken ) ;
143+ //console.log(dataIID);
132144 betInfo . iid = dataIID . bet . iid . split ( ":" ) [ 1 ] ;
133145 betInfo . condition = req . body . High == "true" ?'>' :'<' ;
134146 betInfo . target = target ;
@@ -162,8 +174,11 @@ module.exports = class PrimeDice extends BaseDice {
162174
163175 async resetseed ( req ) {
164176 let clientSeed = Math . random ( ) . toString ( 36 ) . substring ( 2 ) ;
165- data = { } ;
166- data . query = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + clientSeed + "\"){seed}}"
177+ let data = { } ;
178+ let variables = { } ;
179+ data . query = "mutation DiceBotRotateSeed ($seed: String!){rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed: $seed){seed}}" ;
180+ variables . seed = clientSeed ;
181+ data . variables = variables ;
167182 let ret = await this . _send ( '' , 'POST' , data , req . session . accessToken ) ;
168183 console . log ( clientSeed , ret ) ;
169184 let info = { } ;
@@ -174,11 +189,11 @@ module.exports = class PrimeDice extends BaseDice {
174189 }
175190
176191 async _send ( route , method , body , accessToken ) {
192+ console . log ( JSON . stringify ( body ) )
177193 let url = `${ this . url } ` ;
178194 let options = {
179195 method,
180196 headers : {
181- 'User-Agent' : 'MyDiceBot' ,
182197 'x-access-token' : accessToken ,
183198 'Content-Type' : 'application/json' ,
184199 } ,
@@ -202,5 +217,35 @@ module.exports = class PrimeDice extends BaseDice {
202217 let ret = data . data ;
203218 return ret ;
204219 }
220+
221+ async _sendbet ( route , method , body , accessToken ) {
222+ let url = `${ this . url } ` ;
223+ let options = {
224+ method : method ,
225+ headers : {
226+ 'x-access-token' : accessToken ,
227+ 'Content-Type' : 'application/json' ,
228+ } ,
229+ body : body
230+ } ;
231+ if ( this . proxy . ip ) {
232+ let socks = 'socks://' + this . proxy . ip + ':' + this . proxy . port ;
233+ if ( this . proxy . user ) {
234+ socks = 'socks://' + this . proxy . user + ':' + this . proxy . password + '@' + this . proxy . ip + ':' + this . proxy . port ;
235+ }
236+ let agent = new SocksProxyAgent ( socks ) ;
237+ options . agent = agent ;
238+ }
239+ options . body = body ;
240+ let res = await fetch ( url , options ) ;
241+ let data = await res . json ( ) ;
242+ if ( data . errors ) {
243+ let errs = new Error ( data . errors [ 0 ] . message ) ;
244+ errs . value = data . errors [ 0 ] . message ;
245+ throw new APIError ( data . errors [ 0 ] . message , errs ) ;
246+ }
247+ let ret = data . data ;
248+ return ret ;
249+ }
205250}
206251exports . PrimeDice
0 commit comments