Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
const config = require('./config.js'); const fs = require('fs'); const request = require('request'); const cheerio = require('cheerio'); const SteamTotp = require('steam-totp'); const SteamCommunity = require('steamcommunity'); const SteamUser = require('steam-user'); const TradeOfferManager = require('steam-tradeoffer-manager'); var knapsack = require('knapsack-js'); var prompt = require('prompt'); const notifier = require('node-notifier'); const community = new SteamCommunity(); const client = new SteamUser(); const manager = new TradeOfferManager({ steam: client, domain: 'example.com', language: 'en' }); // Variables var acceptThis = [] //Accept a tradeoffer if the offerID is on the list! var lastLoginAttempt = Date.now(); //Cooldown for refreshing the bot's session var cookie; //Stores the website cookie var caseKeys = []; //Stores the user keys as objects properties are name, price and id var topLimit = 0; //Stores the top limit (max Key amount from the config * keyPrice) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////// WITHDRAW BOT ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// console.log("") console.log(" =====================================================================================================") console.log(" > Script starting...") logInBot(); // The script is being run when the tradebot is logged in and returns the cookies for skinsJar function loadOwnInv() { caseKeys = []; topLimit = 0; console.log(" =====================================================================================================") console.log(" > Requesting player inventory!"); var options = { headers: { 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36", 'Cookie': cookie }, } request.get("https://skinsjar.com/loadInventory?refresh=1&v=1", options, function (error, response, body) { if (error) { console.log(' > Error loading our own inventory!'); console.log("Retrying in 30 seconds!"); console.log(""); setTimeout(function(){ loadOwnInv(); }, 30000); } if (response.statusCode !== 200) { console.log(' > Error loading our own inventory (statuscode)!'); console.log("Retrying in 30 seconds!"); console.log(""); setTimeout(function(){ loadOwnInv(); }, 30000); } var myInv = JSON.parse(body); for (var key in myInv) { //Pushes all keys into the caseKeys array if (myInv[key].category == "Key" && myInv[key].inTrade == false && isInArray(myInv[key].name, config.excludeKeys) == false && myInv[key].priceBuy > 2) { //2$ is just for security if the keys are values at 0.00$! for (i = 0; i < myInv[key].items.length; i++) { caseKeys.push({ "name": myInv[key].name, "price": myInv[key].priceBuy, "id": myInv[key].items[i] }) } } } fs.writeFileSync('keyObject.json', JSON.stringify(caseKeys)); if(caseKeys.length != 0 && caseKeys.length > config.stopAt){ if(config.useKeys > caseKeys.length){ config.useKeys = caseKeys.length }; for (i = 0; i < config.useKeys; i++) { //take amount of keys to use from the config, add up the first x keys in the array to get the max withdraw limit //console.log(caseKeys[i]); topLimit += caseKeys[i].price; } console.log(" > User inventory loaded: " + caseKeys.length + " key(s)! Limit: " + topLimit.toFixed(2) + "$ | " + config.useKeys + " keys!"); loadBotInv() } else { if(config.slowMode){ askInput(); } else { console.log(" > Out of keys! Refreshing the inventory in 60 seconds!"); console.log("") setTimeout(function(){ loadOwnInv(); }, 60000); } } }); } function loadBotInv() { var filteredInv = {}; //Holds the filtered inventory var options = { headers: { 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36", 'Cookie': cookie }, } request.get("http://skinsjar.com/loadBots", options, function (error, response, body) { if (error) { console.log(' > Error loading our own inventory!'); console.log("Retrying in 30 seconds!"); console.log("") setTimeout(function(){ loadOwnInv(); }, 30000); } if (response.statusCode !== 200) { console.log(' > Error loading our own inventory (statuscode)!'); console.log("Retrying in 30 seconds!"); console.log("") setTimeout(function(){ loadOwnInv(); }, 30000); } var botInv = JSON.parse(body); for (var key in botInv) { //Only take items below the limit, that dont have a phrase from the blacklist (config) in their name. Also only take items from the right category if (botInv[key].priceSell > config.minPrice && botInv[key].priceSell < config.maxPrice && notBlackListed(botInv[key].name) && config.takeCategory.indexOf(botInv[key].category) >= 0) { for (i = 0; i < botInv[key].items.length; i++) { if(botInv[key].bot in filteredInv){ var obj = {}; obj[botInv[key].items[i]] = botInv[key].priceSell; filteredInv[botInv[key].bot].push(obj) } else { filteredInv[botInv[key].bot] = [] var obj = {}; obj[botInv[key].items[i]] = botInv[key].priceSell; filteredInv[botInv[key].bot].push(obj) } } } } prepareOffer(longest(filteredInv)) }); } function longest(obj){ var longest = {"bot":0, "count":0} for(var key in obj){ if(obj[key].length > longest.count){ longest.bot = key longest.count = obj[key].length } } var longestBot = obj[longest.bot] var fullPrice = 0; for (i = 0; i < obj[longest.bot].length; i++) { for(var key in obj[longest.bot][i]) { fullPrice += obj[longest.bot][i][key] } } return {"items": obj[longest.bot], "botId": longest.bot, "fullPrice": parseFloat((fullPrice).toFixed(2))}; } function prepareOffer(itemObject) { console.log(" > Bot inventory loaded and filtered! Biggest bot #" + itemObject.botId + " | " + itemObject.items.length + " item(s)!") console.log(" =====================================================================================================") var calculatedObj = {}; for (i = 1; i < config.useKeys; i++) { var varName = i.toString() var keysNow = caseKeys.slice(0,i); var ourPrice = 0; var theirPrice = 0; var theirItems = [] var ourItems = [] for(j = 0; j < keysNow.length; j++){ ourPrice += keysNow[j].price ourItems.push(keysNow[j].id) } var selectedItems = knapsack.resolve(ourPrice, itemObject.items); for(j = 0; j < selectedItems.length; j++){ for(var key in selectedItems[j]) { theirPrice += selectedItems[j][key] theirItems.push(key) } } calculatedObj[varName] = { "ourPrice": parseFloat(ourPrice.toFixed(2)), "theirPrice": parseFloat(theirPrice.toFixed(2)), "botID": itemObject.botId, "items": theirItems, "keys": ourItems, "overpay": parseFloat((ourPrice - theirPrice).toFixed(2)) } } sendOffer(getLowestOverpay(calculatedObj)) } function getLowestOverpay(calculatedObj){ var reversedObj = reverse(calculatedObj); var bestOffer = {"items": []} for(var key in reversedObj){ if(reversedObj[key].overpay < config.overpayTolerance && reversedObj[key].items.length > bestOffer.items.length){ bestOffer = reversedObj[key]; } } if(bestOffer.items.length > 0){ console.log(" > Best calculated offer: ") console.log(" - " + bestOffer.items.length + " items (" + bestOffer.theirPrice + "$)"); console.log(" - " + bestOffer.keys.length + " keys (" + bestOffer.ourPrice + "$)") console.log(" - " + bestOffer.overpay + "$" + " overpay") console.log(" =====================================================================================================") } else { console.log(" > Not able to find an offer that matches our settings!") console.log(" - Try to set 'useKeys' to a higher value") console.log(" - Use a higher 'overpayTolerance'") console.log(" - Lower the number of 'sendIfMore'") console.log(" - Check the item filters") console.log(" =====================================================================================================") return false; } if(bestOffer.overpay < config.overpayTolerance && bestOffer.items.length > 0){ return bestOffer; } else { return false; } } function sendOffer(bestOffer) { if(bestOffer && bestOffer.items.length > config.sendIfMore){ console.log(" > Sending an offer!") var data = {"itemsFromMe": bestOffer.items, "bot": parseInt(bestOffer.botID), "itemsFromThem": bestOffer.keys}; request.post({ headers : { 'Origin': 'http://skinsjar.com', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', 'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, */*', 'Referer': 'http://skinsjar.com/', 'X-Requested-With': 'XMLHttpRequest', 'Connection': 'keep-alive', 'Cookie': cookie }, gzip: true, url: 'https://skinsjar.com/api/items/trade', body: JSON.stringify(data) }, function (error, response, body) { if (error) { console.log(' > Error requesting the offer!'); console.log("Retrying in 30 seconds!"); console.log("") setTimeout(function(){ loadOwnInv(); }, 30000); } if (response.statusCode !== 200) { console.log(' > Error requesting the offer! (statuscode)!'); console.log("Retrying in 30 seconds!"); console.log("") setTimeout(function(){ loadOwnInv(); }, 30000); } var responseBody = JSON.parse(response.body) if (responseBody.status == "0") { // accessing body from response might be bad to do, not totally sure. :) console.log(" > Offer was successfully sent! (" + responseBody.tradeofferid + ")") console.log(" > Waiting " + config.waitTime + " second(s)!") console.log("") if(config.offerNotifications){notifier.notify({'title': 'Requested an offer!', 'message': "> " + bestOffer.items.length + " item(s) for " + bestOffer.keys.length + " key(s)!"})}; acceptThis.push((responseBody.tradeofferid).toString()); if(config.slowMode){ askInput(); } else { setTimeout(function(){ console.log(""); loadOwnInv(); }, config.waitTime * 1000) } } else { console.log(" > Problem: " + responseBody.error + " (Bot won't accept this trade!)"); console.log(" > Waiting " + config.waitTime + " second(s)!") setTimeout(function(){ console.log(""); loadOwnInv(); }, config.waitTime * 1000) } }); } else { console.log(" > No good offers found! (Overpay too high, min. amount of items etc...)") console.log(" > Waiting " + config.waitTime + " second(s)!") console.log("") setTimeout(function(){ console.log(""); loadOwnInv(); }, config.waitTime * 1000) } } function notBlackListed(word) { //Pass the itemName to this function. Returns TRUE if the name doesn't contain a blackListed word ("StatTrak", "Souvenir", "Battle-Scared" etc...) var contains = false; for (i = 0; i < (config.avoid).length; i++) { if (word.indexOf(config.avoid[i]) >= 0) { contains = true; } } return !contains; } function askInput(){ console.log("") setTimeout(function(){ console.log("")}, 100); prompt.message = '>>> Enter "+" and hit return to check for items: '; prompt.get(['userInput'], function (err, result) { if(result.userInput == "+"){ loadOwnInv(); } else { askInput(); } }); } function reverse(items, func){ var reversed = Array(); for( var key in items ){ reversed.unshift(items[key]); } if( func ){ for( var key in reversed ){ func(key, reversed[key]); } } return reversed; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////// TRADEBOT ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* Polling Steam and Logging On */ function logInBot() { if(config.useSecrets){ client.logOn({ accountName: config.username, password: config.password, twoFactorCode: SteamTotp.generateAuthCode(config.sharedsecret) }); } else { console.log(" > 'useSecrets' is set to false - Please enter an auth-code!") client.logOn({ accountName: config.username, password: config.password, twoFactorCode: "" }); } } function isInArray(value, array) { return array.indexOf(value) > -1; } function acceptOffer(offer) { offer.accept((err) => { if(config.useSecrets){ community.acceptConfirmationForObject(config.identitysecret, offer.id, function(){ }); } else { console.log(" > Please confirm this offer!"); } if (err) console.log(` > Unable to accept offer: ${err.message}`); }); } function declineOffer(offer) { console.log(" > Declining offer!") offer.decline((err) => { if (err) return console.log(` > Unable to decline offer: ${err.message}`); }); } manager.on('newOffer', function (offer) { const partnerid = offer.partner.getSteamID64(); offer.getUserDetails((err, me, them) => { if (err) return console.log(err); if (them.escrowDays > 0) { console.log(' > Trade is in escrow. Declining.'); declineOffer(offer); } }); if (!offer.itemsToGive.length && config.acceptDonations) { acceptOffer(offer); console.log(" ============ Received a new offer ==================================================================="); console.log(" > ID: " + offer.id + " | Give: " + offer.itemsToGive.length + " | Receive: " + offer.itemsToReceive.length) console.log(" > Donation! Accepting!"); console.log(" ====================================================================================================="); console.log(""); } else if (acceptThis.indexOf(offer.id) >= 0) { console.log(" ============ Received a new offer ==================================================================="); console.log(" > ID: " + offer.id + " | Give: " + offer.itemsToGive.length + " | Receive: " + offer.itemsToReceive.length) if(config.autoAccept){ console.log(" > Offer was sent from this bot! Accepting!"); console.log(" ====================================================================================================="); console.log(""); acceptOffer(offer); } else { console.log(" > Offer was sent from this bot, but autoAccept is set to 'false' in the config!"); console.log(" ====================================================================================================="); console.log(""); } } }); //Refresh polldata.json manager.on('pollData', function (pollData) { fs.writeFile('polldata.json', JSON.stringify(pollData)); }); if (fs.existsSync('polldata.json')) { try { console.log(" > Loaded polldata!") manager.pollData = JSON.parse(fs.readFileSync('polldata.json')); } catch (Exception) { console.log(" > polldata.json is corrupted! Restoring!"); manager.pollData = {}; } } client.on('loggedOn', function (details) { console.log(` > Logged into Steam as ${client.steamID}!`); client.setPersona(SteamUser.Steam.EPersonaState.Online); }); client.on('webSession', function (sessionID, cookies) { manager.setCookies(cookies, function (err) { if (err) return console.log(err); console.log(" > Steamcookies are set!"); logIntoWebsite() }); community.setCookies(cookies); }); client.on("sessionExpired", function (err) { if (Date.now() - lastLoginAttempt > 30000) { lastLoginAttempt = Date.now(); console.log(" > Session Expired, relogging."); client.webLogOn(); } else { console.log(" > Session Expired, waiting a while before attempting to relogin."); } }); function logIntoWebsite() { console.log(" > Logging into website!") community.httpRequestGet('http://skinsjar.com/login', (err, response, body) => { if (err) { console.log(" > Error authenticating with website: " + err); process.exit(); // add exit code error } var $ = cheerio.load(body); var data = $('#openidForm').serializeArray(); var formData = {}; data.forEach((obj) => { formData[obj.name] = obj.value; }); var options = { url: 'https://steamcommunity.com/openid/login', method: 'POST', formData: formData, followAllRedirects: true }; community.httpRequest(options, (error, response, body) => { if (error) { console.log(" > Error loading websiteCookies: " + err); process.exit(); } cookie = response.request.headers.cookie; console.log(" > Received website cookies!"); if(config.slowMode){ askInput(); } else { loadOwnInv(); } }); }); }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
18 hours ago | 0.16 KB
settings
18 hours ago | 0.10 KB
IT & AI
1 day ago | 1.62 KB
Stationeers - Sign Tags from Power Distributi...
HTML | 1 day ago | 2.00 KB
PM: Shopify Client Edits
1 day ago | 0.19 KB
PM: Shopify Assigning Design Task 2
1 day ago | 0.14 KB
PM: Shopify Assigning Design Task 1
1 day ago | 0.32 KB
Commodore Callback 8020
2 days ago | 0.18 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!