Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Steam = require('steam');
- var SteamUser = require('steam-user');
- var TradeOfferManager = require('steam-tradeoffer-manager');
- var SteamTotp = require('steam-totp');
- var SteamConfirm = require('steamcommunity-mobile-confirmations');
- var TOTP = require('onceler').TOTP;
- var request = require('request');
- // GENERAL INFORMATION
- var sitepath;
- sitepath = "csgohazard.com.pl"; // The path to the index.php of your website without HTTP://
- var sitename;
- sitename = "csgohazard.com.pl"; // The name of your site, it will be shown in the Trade Offer Message
- var apik = "2A9ADE7436B9DD4FB3BE595AAB607623"; // Must be the API Key associated with the current bot. Get it here: https://steamcommunity.com/dev/apikey
- var admin = '76561198082437732'; // The Admin, Main Owner of the site. You will be able to communicate with the bot, ask for the rake items, etc. Can be obtained at steamid.io
- var botsteamid = '76561198189319109'; // The bot's steam id, it is required to generate the Device ID and to confirm mobile confirmations. Can be obtained at steamid.io
- var identitysecret = '\/nbg0FZ\/Zks7ITldOuhD+iHi3sU='; // It's required to confirm mobile confirmations
- var sharedsecret = 'S1FXHJP89GAxU7xL5iPlOts5VdA='; // You won't be able to log in without this code
- var pooling_interval = 10000; // 10 seconds by default, the bot checks for outgoing confirmations every X seconds, defined here
- var rsecret='GASDasdgAGW123'; // Also change this to the same code in endround.php and p2endround.php, this prevents people from randomly breaking your site by ending blank games or ending games sooner
- var p2=false; // If this is the bot for your Jackpot 2 set this to true
- // GENERAL INFORMATION
- // LOGIN DETAILS
- var details = {
- "accountName" : "qayman123", // Bot username
- "password" : "bezcyfer", // Bot password
- "twoFactorCode" : SteamTotp.generateAuthCode(sharedsecret)
- };
- // LOGIN DETAILS
- var client = new SteamUser();
- var manager = new TradeOfferManager({
- "steam" : client,
- "domain" : "localhost",
- "language" : "en"
- })
- var deviceid=SteamTotp.getDeviceID(botsteamid);
- if(p2==true)
- {
- var pot2='p2';
- }
- else
- {
- var pot2='';
- }
- var GameTime = 120;
- var endtimer = -1;
- // MYSQL INFO
- var mysql = require('mysql');
- var connection = mysql.createConnection({
- host : 'vior.pl', // MySQL Host
- user : 'w173_1', // MySQL User
- password : '12345', // MySQL Password
- database : 'w173_new' // MySQL Databse
- });
- // MYSQL INFO
- connection.connect();
- client.logOn(details);
- function EndGame()
- {
- endtimer = -1;
- proceedWinners();
- setTimeout(sendOffers,5000);
- }
- function proceedWinners()
- {
- console.log('[SERVER] Ending current game & choosing winner.');
- var url = 'http://'+sitepath+'/'+pot2+'endround.php?secret='+rsecret+'';
- request(url, function(error, response, body)
- {
- if(error)
- {
- console.log('Couldn\'t end round, error: '+error);
- }
- });
- }
- function is_float(mixed_var)
- {
- return +mixed_var === mixed_var && (!isFinite(mixed_var) || !! (mixed_var % 1));
- }
- function isNumeric(n){
- return (typeof n == "number" && !isNaN(n));
- }
- function getUserInfo(steamids,callback)
- {
- var url = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='+apik+'&steamids='+ steamids + '&format=json';
- request({
- url: url,
- json: true
- }, function(error, response, body){
- if(!error && response.statusCode === 200){
- callback(null, body);
- } else if (error) {
- getUserInfo(steamids,callback);
- }
- });
- }
- function addslashes(str)
- {
- str=str.replace(/\\/g,'\\\\');
- str=str.replace(/\'/g,'\\\'');
- str=str.replace(/\"/g,'\\"');
- str=str.replace(/\0/g,'\\0');
- return str;
- }
- client.on('loggedOn', function(details){
- client.on('webSession', function(sessionID, cookies){
- manager.setCookies(cookies, function(err) {
- if(err) {
- console.log('setCookies error: '+err);
- process.exit(1); // Fatal error since we couldn't get our API key
- return;
- }
- var steamapi=manager.apiKey;
- var SteamcommunityMobileConfirmations = require('steamcommunity-mobile-confirmations');
- var steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
- {
- steamid: botsteamid,
- identity_secret: identitysecret,
- device_id: deviceid,
- webCookie: cookies,
- });
- setInterval(function(){
- checkConfirmations(steamcommunityMobileConfirmations)
- }, pooling_interval);
- console.log("[SERVER] The Bot has logged in!");
- client.addFriend(admin);
- client.chatMessage(admin, "[SERVER] Successfully logged in!");
- client.setPersona(Steam.EPersonaState.LookingToTrade);
- });
- });
- });
- manager.on('newOffer', function(offer)
- {
- var proceed=true;
- var steamid=offer.partner.getSteamID64();
- getUserInfo(steamid, function(error, data)
- {
- if(error)
- {
- console.log('getUserInfo error: '+error);
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: getUserInfo error');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Servers are busy, try again in a minute!\',\'25\',\'1\')', function(err, row, fields) {});
- });
- return;
- }
- var datadec = JSON.parse(JSON.stringify(data.response));
- var name = addslashes(datadec.players[0].personaname);
- var avatar = (datadec.players[0].avatarfull);
- console.log('[DEBUG] Processing offer #'+offer.id+' from '+name+' (ID:'+steamid+').');
- if(offer.itemsToGive.length!=0)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Asked for a skin on the Bot');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Asking for any of the bots items? Brave!\',\'25\',\'1\')', function(err, row, fields) {});
- });
- return;
- }
- offer.getEscrowDuration(function(err, daysTheirEscrow, daysMyEscrow)
- {
- if(err)
- {
- console.log('getEscrowDuration error: '+err);
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Steam Servers are busy, couldn\'t get escrow duration');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Servers are busy, couldnt get escrow duration!\',\'25\',\'1\')', function(err, row, fields) {});
- });
- return;
- return;
- }
- else
- {
- if (daysTheirEscrow != 0)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User is in Escrow for '+daysTheirEscrow+' days');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: You are in Escrow for '+daysTheirEscrow+' days!\',\'25\',\'1\')', function(err, row, fields) {});
- });
- return;
- }
- else
- {
- connection.query('SELECT * FROM `'+pot2+'info`', function(err, row)
- {
- var minbet = row[3].value;
- var maxbet = row[7].value;
- var maxitems = row[4].value;
- var maxritems = row[10].value;
- if(offer.itemsToReceive.length>maxitems)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent more than '+maxitems+' skins');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: We only accept up to '+maxitems+' skins!\',\'25\',\'1\')', function(err, row, fields) {});
- });
- return;
- }
- var items = offer.itemsToReceive;
- var totaldeposit=0;
- var depitems=[],skinssent=0;
- items.forEach(function(item, i , arr)
- {
- if (item.appid != 730)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent a Non-CSGO skin');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: We only accept CSGO skins!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(item.market_hash_name.indexOf("Souvenir") != -1)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent a Souvenir Skin');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: No souvenir skins allowed!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- depitems[i]=[];
- depitems[i].name=item.market_name;
- depitems[i].color=item.name_color;
- depitems[i].url=item.icon_url;
- depitems[i].value=0;
- var itemname = item.market_name;
- var url = 'http://'+sitepath+'/cost.php?item='+encodeURIComponent(itemname);
- (function(someshit) {
- request(url, function(error, response, body)
- {
- if(!error && response.statusCode === 200)
- {
- if(body == "notfound")
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Steam Market Issues (Can\'t get the skin\'s value)');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- else
- {
- depitems[i].value = parseFloat(body);
- totaldeposit+=depitems[i].value;
- if(depitems[i].value=="notfound" || depitems[i].value=="NaN" || depitems[i].value=="null" || depitems[i].value=="undefined" || depitems[i].value==0 || !depitems[i].value)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Steam Market Issues (Can\'t get the skin\'s value)');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- }
- }
- else
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Steam Market Issues (Can\'t get the skin\'s value)');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- });
- })(i)
- skinssent++;
- });
- setTimeout(function()
- {
- if(totaldeposit>maxbet)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent too much in skin value');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: You can deposit more than $'+maxbet+'\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(totaldeposit<minbet)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent below the minimal bet amount ($'+minbet+')');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Minimum deposit value: $'+minbet+'\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(skinssent>maxitems)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User sent too many skins');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: We only accept up to '+maxitems+' skins!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(proceed=true)
- {
- connection.query('SELECT * FROM `'+pot2+'info`', function(err, row)
- {
- var cg = row[0].value;
- connection.query('SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `'+pot2+'game'+cg+'` WHERE `userid`=\''+steamid+'\'', function(err, row, fields)
- {
- skinsin = row[0].skinsin;
- skinsin=skinsin+skinssent;
- moneyin = row[0].moneyin;
- moneyin=moneyin+totaldeposit;
- if(skinsin>maxitems)
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: RECHECK - User sent too many skins');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: You can not deposit more than '+maxitems+' skins\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(moneyin > maxbet)
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: RECHECK - User sent too much in skin value');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: You can deposit more than $'+maxbet+'\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- for(var i=0; i < skinssent; i++)
- {
- if(!isNumeric(depitems[i].value))
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: RECHECK - Steam Market Issues (Can\'t get the skin\'s value) ');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- }
- connection.query('SELECT * FROM `users` WHERE `steamid`=\''+steamid+'\'', function(err, row, fields)
- {
- if(err)
- {
- console.log('MYSQL Error: '+err);
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: MYSQL Error (as seen above) ');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: MYSQL Error\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(row.length!=0)
- {
- ban=row[0].ban;
- tlink=row[0].tlink;
- if(ban==1)
- {
- proceed=false;
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User is banned');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: You are banned from betting\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- if(!tlink)
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User doesn\'t have a TradeLink set ');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: No Trade URL Set\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- connection.query('SELECT * FROM `'+pot2+'games` WHERE `id`=\''+cg+'\'', function(err, row, fields)
- {
- itemsin=row[0].itemsnum;
- offer.accept(function(err)
- {
- if(err)
- {
- console.log('Accept error: '+err);
- /*if(err!="error: http error 503") Experimental function please do not use
- {
- return;
- }*/
- doPoll(); // Also experimental
- return;
- }
- for(var i=0; i < skinssent; i++)
- {
- var itemname = addslashes(depitems[i].name);
- connection.query('INSERT INTO `'+pot2+'game' +cg+ '` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES (\'' + steamid + '\',\'' + name + '\',\'' + itemname + '\',\''+offer.id+'\',\'' + depitems[i].color + '\',\'' + depitems[i].value + '\',\'' + avatar + '\',\'' + depitems[i].url + '\')', function(err, row, fields)
- {
- if(err)
- {
- console.log(err);
- }
- });
- connection.query('UPDATE `'+pot2+'games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+\''+depitems[i].value+'\' WHERE `id` = \''+cg+'\'', function(err, row, fields) {});
- }
- connection.query('UPDATE `users` SET `skinssent`=`skinssent`+'+skinssent+' WHERE `steamid` = \'' + steamid + '\'', function(err, row, fields) {});
- console.log('[SERVER] Accepted offer #'+offer.id+' from '+name+' (ID:'+steamid+').');
- offer.getReceivedItems(function(err, items)
- {
- if(err)
- {
- console.log('getReceivedItems SERIOUS GAME BREAKING error: '+err);
- }
- items.forEach(function(item)
- {
- var itemn=addslashes(item.market_name);
- connection.query('UPDATE `'+pot2+'game'+cg+'` SET `assetid`=\''+item.id+'\' WHERE `userid` = \'' + steamid + '\' AND `item`=\''+itemn+'\' AND `assetid`=\'\' LIMIT 1', function(err, row, fields) {});
- })
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'success\',\'0\',\''+steamid+'\',\'Trade Offer Accepted (Game #'+cg+')!\',\'We wish you Good luck and happy betting!\',\'25\',\'1\')', function(err, row, fields) {});
- connection.query('SELECT COUNT(DISTINCT userid) AS playersCount FROM `'+pot2+'game'+cg+'`', function(err, rows)
- {
- players = rows[0].playersCount;
- if(players == 1 && skinssent > 0 && endtimer==-1)
- {
- console.log('[SERVER] Starting the countdown for Game #'+cg+'');
- endtimer = setTimeout(EndGame,GameTime*1000);
- connection.query('UPDATE `'+pot2+'games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = \'' + cg + '\'', function(err, row, fields) {});
- }
- if(itemsin > maxritems)
- {
- clearTimeout(endtimer);
- endtimer = -1;
- EndGame();
- }
- });
- });
- });
- }
- else
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: User is not in the MYSQL Database');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- return;
- }
- return;
- });
- });
- });
- }
- else
- {
- offer.decline(function(err)
- {
- console.log('[DEBUG] Declined offer #'+offer.id+' from '+name+' (ID:'+steamid+'). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues');
- if (err)
- {
- console.log('Decline error: '+err);
- }
- });
- connection.query('INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\''+steamid+'\',\'Trade Offer Declined!\',\'Reason: Steam Issues\',\'25\',\'1\')', function(err, row, fields) {});
- return;
- }
- },2000);
- });
- }
- }
- });
- });
- });
- client.on('friendMessage#'+admin+'', function(steamID, message)
- {
- console.log("[SERVER] Admin to Bot: " + message);
- if(message.indexOf("/sendrake") == 0)
- {
- client.chatMessage(admin, '[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)');
- sendRake(1);
- }
- if(message.indexOf("/sendoffers") == 0)
- {
- client.chatMessage(admin, '[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)');
- sendOffers(1);
- }
- if(message.indexOf("/end") == 0)
- {
- client.chatMessage(admin, '[SERVER] Ending the current game!');
- if(endtimer != -1) clearTimeout(endtimer);
- EndGame();
- }
- if(message.indexOf("/offers") == 0)
- {
- connection.query('SELECT ID FROM `'+pot2+'queue` WHERE `status`=\'active\' GROUP BY `id` DESC', function(err, row, fields)
- {
- if(row.length!=0)
- {
- console.log(row);
- client.chatMessage(admin, '[SERVER] Check your console for the ID\'s!');
- }
- else
- {
- client.chatMessage(admin, '[SERVER] There aren\'t any active queue ID\'s.');
- }
- });
- }
- if(message.indexOf("/rakes") == 0)
- {
- connection.query('SELECT ID FROM `'+pot2+'rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC', function(err, row, fields)
- {
- if(row.length!=0)
- {
- console.log(row);
- client.chatMessage(admin, '[SERVER] Check your console for the ID\'s!');
- }
- else
- {
- client.chatMessage(admin, '[SERVER] There aren\'t any active rake ID\'s.');
- }
- });
- }
- });
- function sendOffers(param)
- {
- connection.query('SELECT * FROM `'+pot2+'queue` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1', function(err, row, fields)
- {
- if(row.length!=0)
- {
- var assetids=(row[0].assetid).split('/');
- manager.loadInventory(730, 2, true, function (err, inventory)
- {
- if (err)
- {
- console.log(err);
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Error while loading the Bot\'s Inventory, try again later boss!');
- }
- return;
- }
- else
- {
- var token=row[0].token;
- var gameid=row[0].id;
- var message='Congratulations! You won on '+sitename+' in Game #'+gameid+'';
- var offer = manager.createOffer(row[0].userid);
- inventory.forEach(function(item)
- {
- assetids.forEach(function(asset)
- {
- if(item.id==asset)
- {
- offer.addMyItem(item);
- }
- })
- })
- setTimeout(function()
- {
- offer.send(message, token, function(err)
- {
- if(err)
- {
- console.log('Error sending Trade Offer for Game #'+gameid+':');
- console.log(err);
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Error while sending the tradeoffer, try again later boss!');
- }
- return;
- }
- connection.query('UPDATE `'+pot2+'queue` SET `status`="sent" WHERE `id`=\''+gameid+'\'');
- console.log('[SERVER] Trade Offer for Game #'+gameid+' has been successfully sent and is awaiting mobile confirmation.');
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Successfully sent the trade for Game #'+gameid+'!');
- }
- });
- },2000);
- }
- });
- }
- else
- {
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] No more Winnings Queries!');
- return;
- }
- }
- });
- }
- function sendRake(param)
- {
- connection.query('SELECT * FROM `'+pot2+'rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1', function(err, row, fields)
- {
- if(row.length!=0)
- {
- var assetids=(row[0].assetid).split('/');
- manager.loadInventory(730, 2, true, function (err, inventory)
- {
- if (err)
- {
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Error while loading the Bot\'s Inventory, try again later boss!');
- }
- return;
- }
- else
- {
- var token=row[0].token;
- var gameid=row[0].id;
- var value=row[0].value;
- var message='Rake for Game #'+gameid+' ($'+value+')';
- var offer = manager.createOffer(row[0].userid);
- inventory.forEach(function(item)
- {
- assetids.forEach(function(asset)
- {
- if(item.id==asset)
- {
- offer.addMyItem(item);
- }
- })
- })
- setTimeout(function()
- {
- offer.send(message, token, function(err)
- {
- if(err)
- {
- console.log('Error sending Rake for Game #'+gameid+':');
- console.log(err);
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Error while sending the tradeoffer for the rake, try again later boss!');
- return;
- }
- return;
- }
- connection.query('UPDATE `'+pot2+'rakeitems` SET `status`="sent" WHERE `id`=\''+gameid+'\'');
- console.log('[SERVER] Rake for Game #'+gameid+' has been successfully sent and is awaiting mobile confirmation.');
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] Successfully sent the rake for Game #'+gameid+'!');
- }
- });
- },2000);
- }
- });
- }
- else
- {
- if(param==1)
- {
- client.chatMessage(admin, '[SERVER] No more Rake Queries!');
- return;
- }
- }
- });
- }
- function checkConfirmations(steamcommunityMobileConfirmations){
- steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations)
- {
- if (err)
- {
- console.log(err);
- return;
- }
- if(confirmations.length>0)
- {
- console.log('[SERVER] Received ' + confirmations.length + ' confirmations');
- }
- if ( ! confirmations.length)
- {
- return;
- }
- steamcommunityMobileConfirmations.AcceptConfirmation(confirmations[0], (function (err, result)
- {
- if (err)
- {
- console.log(err);
- return;
- }
- console.log('[SERVER] Confirmation handling result: ' + result);
- }).bind(this));
- }).bind(this));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement