Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SteamTradeOffers = require('steam-tradeoffers');
- var SteamCommunity = require('steamcommunity');
- var SteamTotp = require('steam-totp');
- var offers = new SteamTradeOffers();
- var community = new SteamCommunity();
- function confirmMobile(userSteamId, callback) {
- var unixTime = SteamTotp.time();
- var confirmationKey = SteamTotp.getConfirmationKey("IDENTITYSECRET", unixTime, "conf");
- community.getConfirmations(unixTime, confirmationKey, (err, confirmations) => {
- if (err) {
- callback(err);
- }
- else {
- console.log(confirmations);
- callback(null);
- }
- });
- }
- function runBot(userSteamId, skinArray, callback) {
- console.log(typeof userSteamId);
- if (!userSteamId || !skinArray) {
- callback(new Error("500error"));
- }
- else if (skinArray.length === 0) {
- callback(new Error("500error"))
- }
- else {
- var sendSkinArray = [];
- console.log("Skin array 8is: " + skinArray);
- for (var i = 0;i<skinArray.length;i++) {
- sendSkinArray.push({
- appid: 730,
- contextid: 2,
- amount: 1,
- assetid: String(skinArray[i])
- });
- if (i === (skinArray.length -1)) {
- offers.makeOffer({
- partnerSteamId: userSteamId,
- itemsFromMe: sendSkinArray,
- itemsFromThem: [],
- message: "Hey! This is the CSGO ACORN bot"
- },(err, response) => {
- if (err) { //If cookies have expired, then get new cookies from steamcommunity.com
- community.login({
- "accountName":"USERNAME",
- "password":"PASSWORD",
- "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
- },(loginError, sessionID, cookies, steamguard) => {
- if (loginError) {
- console.log("err when trying to log inHELLOWO");
- console.log("err is: " + loginError);
- console.log("sessionID is: " + sessionID);
- console.log("cookies is: " + cookies);
- console.log("steamguard is: " + steamguard);
- callback(new Error("500error"));
- }
- else {
- community.loggedIn((communityError, loggedIn) => {
- if (communityError) {
- console.log("err2 was: " + communityError);
- callback(new Error("loginFailed"));
- }
- else {
- if (loggedIn) {
- console.log(util.inspect(cookies, false, null));
- console.log("err is: " + communityError);
- console.log("sessionID is: " + sessionID);
- console.log("cookies is: " + cookies);
- console.log("steamguard is: " + steamguard);
- offers.setup({
- sessionID:sessionID,
- //webCookie: cookiesCache,
- webCookie:cookies,
- APIKey: "APIKEY",
- });
- runBot(userSteamId, skinArray, callback);
- }
- else {
- console.log("Logged in is: " + loggedIn);
- console.log("could not log in");
- console.log("err is: " + err);
- console.log("sessionID is: " + sessionID);
- console.log("cookies is: " + cookies);
- console.log("steamguard is: " + steamguard);
- callback(new Error("loginFailed"))
- }
- }
- });
- }
- });
- }
- else {
- console.log(response);
- confirmMobile(userSteamId, (err, data) => {
- if (err) {
- callback(err);
- }
- else {
- callback(null);
- }
- });
- }
- });
- }
- }
- }
- }
- community.login({
- "accountName":"USERNAME",
- "password":"PASSWORD",
- "twoFactorCode": SteamTotp.generateAuthCode("SHAREDSECRET")
- },(loginError, sessionID, cookies, steamguard) => {
- if (loginError) {
- console.log(loginError);
- }
- else {
- community.loggedIn((communityError, loggedIn) => {
- if (communityError) {
- console.log("err2 was: " + communityError);
- }
- else {
- if (loggedIn) {
- offers.setup({
- sessionID:sessionID,
- webCookie:cookies,
- APIKey: "APIKEY",
- });
- runBot("STEAMID", ["5794350713"], (err) => {
- if (err) {
- console.log("There was an error");
- }
- else {
- console.log("It worked!");
- }
- });
- }
- else {
- console.log("Could not log in");
- }
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment