Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Steam = require('steam');
- var SteamUser = require('steam-user');
- var usd = SteamUser.ECurrencyCode.USD;
- var prompt = require('prompt');
- var NodeSteamUser = new SteamUser();
- var SteamManager = require('steam-tradeoffer-manager');
- var username;
- var auth = require('steam-totp');
- var fs = require('fs');
- var httprequest = require('request');
- var password;
- var manager;
- var rate;
- var sellrate = 1.80; //Customer sell rate, not bot's.
- var buyrate = 1.85; //Cutomer buy rate, not bot's.
- var steamc = require('steamcommunity');
- var shared_secret;
- var identity_secret;
- var sbalance;
- var cookiesT = [];
- var steamcommunity = new steamc();
- console.log("Loading BTC Bot v1.0");
- fs.readFile('account.txt', function(err,data){
- if (err) throw err;
- var parsed = JSON.parse(data);
- username = parsed.username;
- password = parsed.password;
- shared_secret = parsed.shared_secret;
- identity_secret = parsed.identity_secret;
- var currentcode = auth.getAuthCode(shared_secret);
- NodeSteamUser.logOn({
- accountName: username,
- password: password,
- twoFactorCode: currentcode
- });
- });
- updateRate();
- setInterval(updateRate, 60*1000*10);
- function updateRate(){
- httprequest('https://blockchain.info/ticker', function(error, response, body){
- if (error) console.log(error);
- rate = JSON.parse(body).USD.last;
- });
- }
- manager = new SteamManager({
- "steam" : NodeSteamUser,
- "language" : "en"
- });
- NodeSteamUser.on('loggedOn', function(){console.log("[INFO]Login Success!");NodeSteamUser.webLogOn();});
- NodeSteamUser.on('webSession', function(sessionID, cookies){
- console.log('[INFO] Web Login Success!');
- sessionIDT = sessionID;
- cookiesT = cookies;
- console.log("[INFO] Cookie Array was Set!");
- manager.setCookies(cookies, function(erghab){
- console.log(erghab);
- });
- steamcommunity.setCookies(cookiesT);
- console.log("[INFO] Manager cookies were set.");
- steamcommunity.startConfirmationChecker(10000, identity_secret);
- NodeSteamUser.setPersona(Steam.EPersonaState.Online);
- httprequest('https://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/balance?password=Cabdca1499', function(error, response, bodyir){
- if (error) console.log(error);
- var balance = JSON.parse(bodyir).balance;
- var satoshi = balance / 100000000 * rate;
- satoshi = satoshi.toFixed(2);
- sbalance = satoshi;
- console.log("[INFO] Synced Balance. " + sbalance.toString());
- });
- });
- //Add relationship requests to queue
- NodeSteamUser.on('friendRelationship', function(sid, relationship){
- if (relationship == Steam.EFriendRelationship.RequestRecipient){
- NodeSteamUser.addFriend(sid);
- fs.readFile('current.txt', function(nope, body){
- if (nope) console.log(nope);
- var tmpfile = JSON.parse(body);
- tmpfile[tmpfile.length] = {steamid: sid.getSteamID64(),
- action: "",
- Confirmed: 0,
- Done: 0,
- Keys: 0,
- BTC: ""};
- fs.writeFile('current.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- });
- NodeSteamUser.chatMessage(sid.getSteamID64(), "Hello! I am a bot who sells and buy for BTC. Type help if you need help with my commands. Removing me will reset any interaction with you, so only remove me before starting a sell/buy proccess. Doing so may cause it a bug, resulting you in losing money. Removing me while in a proccess is purely your responsability, and the staff will not refund you.");
- }
- if (relationship == Steam.EFriendRelationship.None){
- fs.readFile('current.txt', function(nope, body){
- if (nope) console.log(nope);
- var tmpfile = JSON.parse(body);
- var index;
- for(var i = 0;i<tmpfile.length;i++){
- if (tmpfile[i].steamid == sid.getSteamID64()){
- tmpfile.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- });
- }
- });
- //Commands Checker
- NodeSteamUser.on('friendMessage', function(sender, message){
- fs.readFile('current.txt', function(err, body){
- if (err) console.log(err);
- var fullbdy = JSON.parse(body);
- var info;
- var rawr = false;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64()){
- info = JSON.parse(body)[i];
- rawr = true;
- }
- }
- if (rawr){
- if (info.action == ""){
- if (message == "help"){
- NodeSteamUser.chatMessage(info.steamid, "My Commands: \n stock - How many keys I have in stock;\n balance - How many Bitcoins I have in my account;\n buy - Starts the trade where you buy keys;\n sell - Starts the trade where you sell keys;");
- }else if (message=="stock"){
- var keys = 0;
- manager.loadInventory(730, 2, true, function(errorlol, inv, currencies){
- if (errorlol) console.log(errorlol);
- for (var i = 0;i<inv.length;i++){
- if (inv[i].market_hash_name != "Case Key" && inv[i].market_hash_name.indexOf("Case Key") >= 0)
- keys++;
- }
- NodeSteamUser.chatMessage(info.steamid, "I have "+keys.toString()+" keys in stock.");
- });
- }else if("balance" == message){
- NodeSteamUser.chatMessage(info.steamid, "I currently have "+sbalance.toString()+" USD.");
- }else if(message == "sell"){
- manager.getEscrowDuration(info.steamid, function(errar, tdays, mdays){
- if (tdays == 0){
- info.action = "sell#1";
- var nr2 = JSON.parse(body);
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64()){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Selling proccess started and no escrow detected. How many keys would you like to sell?");
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Sorry, but I am not buying keys from users that have an Escrow Trade Hold.");
- }
- });
- }
- else if(message=="buy"){
- info.action = "buy#1";
- var nr2 = JSON.parse(body);
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64()){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Buying proccess started! How many keys would you like to buy?");
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Invalid Command!");
- }
- }else{
- var args = info.action.split("#");
- if (args[0] == "buy"){
- if (args[1] == "1"){
- var keys = parseInt(message);
- if (Number(keys) == keys && keys != 0){
- manager.loadInventory(730, 2, true, function(nah, inv){
- if (nah) NodeSteamUser.chatMessage(info.steamid, "Error loading invetory...if this persists, please report to my owner!");
- var stock = 0;
- for (var i = 0;i<inv.length;i++){
- if (inv[i].market_hash_name != "Case Key" && inv[i].market_hash_name.indexOf("Case Key") >= 0){
- stock++;
- }
- }
- if (stock >= keys){
- info.action = "buy#2";
- info.Keys = keys;
- var nr2 = JSON.parse(body);
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64())
- nr2[i] = info;
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Great! I have enough keys in my account! Please input your Bitcoin address from which you are going to send the money. Make sure you double read it before sending it.");
- }else
- NodeSteamUser.chatMessage(info.steamid, "It seems like I don't have enough keys in my account :/ . Select another amount.");
- });
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Sorry! We couldn't parse your response! Please send the amount again.");
- }
- } else if (args[1] == "2"){
- var nr2 = JSON.parse(body);
- info.action = "buy#3";
- info.BTC = message;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == info.steamid){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Are you sure you want to buy "+info.Keys.toString()+" keys for "+(info.Keys * buyrate + 0.01).toString()+" USD(0.01 transaction fee)? Your BTC Address: "+info.BTC+" . Type yes to continue and no to cancel");
- }else if(args[1] == "3"){
- if (message == "no"){
- var nr2 = JSON.parse(body);
- info.action = "";
- info.BTC = "";
- info.Keys = 0;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == info.steamid){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Proccess canceled!");
- }else if(message == "yes"){
- var nr2 = JSON.parse(body);
- info.action = "buy#4";
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == info.steamid){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/new_address?password=Cabdca1499&label='+info.steamid, function(nahr, rezponse, baddi){
- fs.readFile('poll.txt', function(nope, bodylol){
- if (nope) console.log(nope);
- var tmpfile = JSON.parse(bodylol);
- tmpfile[tmpfile.length] = {
- address: JSON.parse(baddi).address,
- satoshi: info.Keys * buyrate / rate * 100000000
- };
- fs.writeFile('poll.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- });
- NodeSteamUser.chatMessage(info.steamid, "Please send me "+(info.Keys * buyrate + 0.01).toString()+" USD(0.01 transaction fee) to "+JSON.parse(baddi).address+" . The BTC servers are polled every 45 seconds, so it might take a while(up to 3 mins) to detect your payment. Waiting for payment...");
- });
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Invalid Response!");
- }
- }
- }else{
- if (args[1] == "1"){
- var keys = parseInt(message);
- if (Number(keys) == keys){
- var price = keys * sellrate;
- if (sbalance > price){
- info.action = "sell#2";
- info.Keys = keys;
- var nr2 = JSON.parse(body);
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64())
- nr2[i] = info;
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Great! I have enough BTC in my account! Please input your Bitcoin address. Make sure you double read it before sending it.");
- }else
- NodeSteamUser.chatMessage(info.steamid, "It seems like I don't have enough money in my BTC account :/ . Select another amount.");
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Sorry! We couldn't parse your response! Please send the amount again.");
- }
- }else if(args[1] == "2"){
- var nr2 = JSON.parse(body);
- info.action = "sell#3";
- info.BTC = message;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64()){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Are you sure you want to sell "+info.Keys.toString()+" keys for "+(info.Keys * sellrate).toString()+" USD? Your BTC Address: "+info.BTC+" . Type yes to continue and no to cancel");
- }else if(args[1] == "3"){
- if (message == "no"){
- var nr2 = JSON.parse(body);
- info.action = "";
- info.BTC = "";
- info.Keys = 0;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == sender.getSteamID64()){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Proccess canceled!");
- }else if(message == "yes"){
- var nr2 = JSON.parse(body);
- info.action = "sell#4";
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == info.steamid){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- NodeSteamUser.chatMessage(info.steamid, "Please send me an offer with "+info.Keys.toString()+" keys. Once I get it, I will send you the money. Waiting for Trade offer...");
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Invalid Response!");
- }
- }else if(args[1] == "69"){
- if (message == "retry"){
- httprequest('https://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/balance?password=Cabdca1499', function(error, response, bodyir){
- if (error) console.log(error);
- var balance = JSON.parse(bodyir).balance;
- var satoshi = balance / 100000000 * rate;
- if (satoshi < info.Keys * sellrate){
- NodeSteamUser.chatMessage(info.steamid, "I still don't have enough money! You can type \"refund\" to get your keys back!");
- }else{
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/payment?password=Cabdca1499&to='+info.BTC+'&amount='+Math.round(info.Keys * sellrate / rate * 100000000).toString(),function(error,response,bodyir){
- if (error) console.log(error);
- NodeSteamUser.chatMessage(info.steamid, JSON.parse(bodyir).message);
- NodeSteamUser.chatMessage(info.steamid, "Thanks you for Buying/Selling keys! If there is a problem, Please add my Owner. I will now remove you! If you want to trade again, simply add me!");
- NodeSteamUser.removeFriend(info.steamid);
- var tmpfile = JSON.parse(body);
- for(var i = 0;i<tmpfile.length;i++){
- if (tmpfile[i].steamid == info.steamid){
- tmpfile.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- });
- }
- });
- }else if(message == "refund"){
- NodeSteamUser.chatMessage(info.steamid, "Refunding Keys...");
- NodeSteamUser.chatMessage(info.steamid, "Proccessing Trade...");
- var offer = manager.createOffer(info.steamid);
- var currkey = 0;
- manager.loadInventory(730, 2, true, function(nah, inv){
- if (nah) NodeSteamUser.chatMessage(info.steamid, "Error loading invetory...if this persists, please report to my owner!");
- for (var i = 0;i<inv.length;i++){
- if (inv[i].market_hash_name != "Case Key" && inv[i].market_hash_name.indexOf("Case Key") >= 0 && currkey < info.Keys){
- offer.addMyItem(inv[i]);
- currkey++;
- console.log("Added for refund: "+inv[i].assetid);
- }
- }
- console.log("Added "+currkey.toString()+" Keys to the refund offer...");
- offer.send("Here is your refund! If you want to buy/sell again, add me!", function(errorah, statusi){
- if (errorah){ NodeSteamUser.chatMessage(info.steamid, "There was an error sending your trade! Please try again later!");
- console.log(errorah);}
- if (statusi == "sent" || statusi == "pending"){
- console.log("Offer sent...");
- NodeSteamUser.chatMessage(info.steamid, "Keys successfully sent! You should receive your offer immediatly! I will now remove you.");
- steamcommunity.checkConfirmations();
- NodeSteamUser.removeFriend(info.steamid);
- var tmpfileii = JSON.parse(body);
- for(var i = 0;i<tmpfileii.length;i++){
- if (tmpfileii[i].steamid == info.steamid){
- tmpfileii.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfileii), function(blah){if (blah) console.log(blah);});
- }
- });
- });
- }else{
- NodeSteamUser.chatMessage(info.steamid, "Invalid Command!");
- }
- } else if (args[1] == 4){
- if (message != "check"){
- NodeSteamUser.chatMessage(info.steamid, "Invalid Command!");
- }else{
- }
- }
- }
- }
- }else
- NodeSteamUser.chatMessage(sender.getSteamID64(), "I cant find you in my database! Please readd me to fix this!");
- });
- });
- manager.on('pollFailure', function(err) {
- logger.error("pollFailure");
- logger.error(err);
- });
- manager.on('newOffer', function(offer){
- console.log("New Offer event triggered!");
- fs.readFile('current.txt', function(err, body){
- if (err) console.log(err);
- var info;
- var tmp = false;
- var rawr = false;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == offer.partner.getSteamID64()){
- info = JSON.parse(body)[i];
- tmp = true;
- rawr = true;
- console.log("Found valid offer...");
- }
- }
- if (rawr){
- if (tmp == false){
- offer.decline();
- console.log("Declined of tmp test...");
- }else if(info.action != "sell#4" && info.action != "buy#69"){
- offer.decline();
- console.log("Declined of invalid action for user"+info.steamid+" with action: "+info.action);
- }else{
- if (info.action == "sell#4"){
- var keys = 0;
- var decline = false;
- NodeSteamUser.chatMessage(info.steamid, "Offer found! Checking offer... If I dont accept the pending offer, cancel it and resend it.");
- if (offer.itemsToGive.length > 0)
- decline = true;
- for (var i = 0;i<offer.itemsToReceive.length;i++){
- if (offer.itemsToReceive[i].market_hash_name != "Case Key" && offer.itemsToReceive[i].market_hash_name.indexOf("Case Key") >= 0){
- keys++;
- }else{
- decline = true;
- }
- }
- if (keys!=info.Keys){
- decline = true;
- }
- if (decline){
- offer.decline();
- NodeSteamUser.chatMessage(info.steamid, "Invalid offer. Please re-send!");
- }else{
- offer.accept(true, function(err,status){
- if (err) console.log(err);else{
- if (offer.state == 3){
- NodeSteamUser.chatMessage(info.steamid, "Offer is valid and was accepted. Sending money...");
- httprequest('https://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/balance?password=Cabdca1499', function(erroriray, response, bodyiralo){
- if (erroriray) console.log(erroriray);
- var balance = JSON.parse(bodyiralo).balance;
- var satoshi = balance / 100000000 * rate;
- if (satoshi < info.Keys * sellrate){
- NodeSteamUser.chatMessage(info.steamid, "Oops! I don't have enough money anymore to complete your pruchase! Send me a message with \"retry\" when you want me to retry your payment.");
- var nr2 = JSON.parse(body);
- info.action = "sell#69";
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == offer.partner.getSteamID64()){
- nr2[i] = info;
- }
- }
- fs.writeFile('current.txt', JSON.stringify(nr2), function(error){if (error) console.log(error);});
- }else{
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/payment?password=Cabdca1499&to='+info.BTC+'&amount='+Math.round(info.Keys * sellrate / rate * 100000000).toString(), function(errorarh,responsearh,bodyirarh){
- if (errorarh) console.log(errorarh);
- console.log(bodyirarh);
- if (JSON.parse(bodyirarh).error){
- NodeSteamUser.chatMessage(info.steamid, "Error: "+JSON.parse(bodyirarh).error);
- }else{
- console.log(JSON.parse(bodyirarh).message);
- NodeSteamUser.chatMessage(info.steamid, JSON.parse(bodyirarh).message);
- NodeSteamUser.chatMessage(info.steamid, "Pleasure doing business with you! I will now remove you! If you want to trade again, simply add me!");
- NodeSteamUser.removeFriend(info.steamid);
- var tmpfile = JSON.parse(body);
- for(var i = 0;i<tmpfile.length;i++){
- if (tmpfile[i].steamid == info.steamid){
- tmpfile.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- }
- });
- }
- });
- }else{
- NodeSteamUser.chatMessage(info.steamid, "WARNING! THERE WAS A PROBLEM ACCEPTING YOUR TRADE OR IT IS IN ESCROW. PLEASE CANCEL IT, AS THE BOT WILL NOT SEND ANY MONEY!");
- }
- }
- });
- }
- } else{
- var keys = 0;
- for(var i = 0;i<offer.itemsToGive.length;i++){
- if (offer.itemsToReceive[i].market_hash_name != "Case Key" && offer.itemsToReceive[i].market_hash_name.indexof("Case Key") >= 0){
- keys++;
- }
- }
- if (keys <= info.Keys){
- offer.accept();
- NodeSteamUser.chatMessage(info.steamid, "Offer accepted! I will now remove you! Please note that it may take a while to confirm, so the offer should be accepted in maximum 5 minutes.");
- steamcommunity.checkConfirmations();
- NodeSteamUser.removeFriend(info.steamid);
- var tmpfile = JSON.parse(body);
- for(var i = 0;i<tmpfile.length;i++){
- if (tmpfile[i].steamid == info.steamid){
- tmpfile.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- }else
- offer.decline();
- }
- }
- }else
- offer.decline();
- }); //Read File
- }); //Event
- //Poll blockchain servers 4 payments...
- setInterval(function() {
- var infolar;
- fs.readFile('poll.txt', function(error, data){
- var parsed = JSON.parse(data);
- if (error) console.log(error);
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/list?password=Cabdca1499', function(err, response, body){
- if (err) console.log(err);
- var adr = JSON.parse(body).addresses;
- fs.readFile('current.txt', 'utf-8', function(erghab, nmilla){
- for (var r = 0;i<JSON.parse(nmilla);i++){
- if (adr[i].label == JSON.parse(nmilla)[r])
- infolar = {Keys: JSON.parse(nmilla)[r].Keys};
- }
- });
- for (var i = 0;i<adr.length;i++){
- for (var j = 0;j<parsed.length;j++){
- if (adr[i].address == parsed[j].address){
- if (adr[i].balance != 0 && adr[i].balance >= parsed[j].satoshi){
- NodeSteamUser.chatMessage(adr[i].label, "Payment Complete... Preparing next step...");
- var curat = adr[i];
- fs.readFile('poll.txt', function(nah, blyat){
- if (nah) console.log(nah);
- var tmpfile = JSON.parse(blyat);
- for(var i = 0;i<tmpfile.length;i++){
- if (tmpfile[i].address == curat.address){
- tmpfile.splice(i, 1);
- }
- }
- fs.writeFile('poll.txt', JSON.stringify(tmpfile), function(blah){if (blah) console.log(blah);});
- });
- fs.readFile('current.txt', function(err, body){
- var info;
- for (var i = 0;i<JSON.parse(body).length;i++){
- if (JSON.parse(body)[i].steamid == curat.label){
- info = JSON.parse(body)[i];
- }
- }
- var offer = manager.createOffer(curat.label);
- var currkey = 0;
- manager.loadInventory(730, 2, true, function(nah, inv){
- if (nah) NodeSteamUser.chatMessage(curat.label, "Error loading invetory...if this persists, please report to my owner!");
- for (var i = 0;i<inv.length;i++){
- if (inv[i].market_hash_name != "Case Key" && inv[i].market_hash_name.indexOf("Case Key") >= 0 && currkey < info.Keys){
- offer.addMyItem(inv[i]);
- currkey++;
- console.log("Added for refund: "+inv[i].assetid);
- }
- }
- console.log("Added "+currkey.toString()+" Keys to the refund offer...");
- offer.send("Thanks for buying! There are "+info.Keys.toString()+" in this offer.", function(errorah, statusi){
- if (errorah){ NodeSteamUser.chatMessage(curat.label, "There was an error sending your trade! Please try again later!");
- console.log(errorah);}
- if (statusi == "sent" || statusi == "pending"){
- console.log("Offer sent...");
- NodeSteamUser.chatMessage(curat.label, "Thanks you for Buying/Selling keys! If there is a problem, Please add my Owner. Keys successfully sent! You should receive your offer immediatly! I will now remove you.");
- steamcommunity.checkConfirmations();
- NodeSteamUser.removeFriend(curat.label);
- fs.readFile('current.txt', 'utf-8', function(erkappa, bodylala){
- var tmpfileii = JSON.parse(bodylala);
- for(var i = 0;i<tmpfileii.length;i++){
- if (tmpfileii[i].steamid == adr[i].label){
- tmpfileii.splice(i, 1);
- }
- }
- fs.writeFile('current.txt', JSON.stringify(tmpfileii), function(blah){if (blah) console.log(blah);});
- });
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/payment?password=Cabdca1499&to=13ttnbpK4Wi1v3NmREegS48v5o93j9tZEc&from='+curat.address+'&amount='+Math.round(info.Keys * sellrate / rate * 100000000).toString(), function(arinoh,absbrh,awol){
- httprequest('http://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/archive_address?password=Cabdca1499&address='+curat.address, function(sjhd,uejeu,jwjje){});
- });
- }
- });
- });
- });
- }else{
- if (adr[i].balance == 0)
- NodeSteamUser.chatMessage(adr[i].label, "I am now checking your payment... You haven't paid anything yet.");
- else
- NodeSteamUser.chatMessage(adr[i].label, "I am now checking your payment... You need to pay "+((parsed[j].satoshi - adr[i].balance) / 100000000 * rate).toString()+" more USD.");
- }
- }
- }
- }
- });
- });
- }, 45*1000);
- //Poll Blockchain for balance
- setInterval(function(){
- httprequest('https://blockchain.info/merchant/d8bf4974-84f9-4f69-a9db-cbf6f610428b/balance?password=Cabdca1499', function(error, response, bodyir){
- if (error) console.log(error);
- var balance = JSON.parse(bodyir).balance;
- var satoshi = balance / 100000000 * rate;
- satoshi = satoshi.toFixed(2);
- sbalance = satoshi;
- });
- }, 60*1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement