Jump to content
McKay Development

Recommended Posts

Posted

 

Hi,

 

I am trying to use your library for a trade bot. Connexion works but the newOffer never emit. I started the bot, bought an item on opskins and waiting for some logs. Here is my code:

'use strict'

var SteamUser         = require('steam-user');
var TradeOfferManager = require('steam-tradeoffer-manager');

var client = new SteamUser();
var offers = new TradeOfferManager({
    steam:        client,
    domain:       "localhost", 
    language:     "en",
    pollInterval: 10000,
    cancelTime:   300000
});

client.logOn({
    accountName: "**account**",
    password: "**password**"
});

client.on('loggedOn', function (details) {
    console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
});

client.on('error', function (e) {
    console.error(e);
    process.exit(1);
});

client.on('accountLimitations', function (limited, communityBanned, locked, canInviteFriends) {
    if (limited) {
        console.warn("Our account is limited. We cannot send friend invites, use the market, open group chat, or access the web API.");
    }
    if (communityBanned){
        console.warn("Our account is banned from Steam Community");
    }
    if (locked){
        console.error("Our account is locked. We cannot trade/gift/purchase items, play on VAC servers, or access Steam Community.  Shutting down.");
        process.exit(1);
    }
    if (!canInviteFriends){
        console.warn("Our account is unable to send friend requests.");
    }
});

offers.on('newOffer', function (offer) {
    console.log("New offer #"+ offer.id +" from "+ offer.partner.getSteam3RenderedID());
 
    if (offer.itemsToGive.length === 0) {
        console.log("User "+ offer.partner.getSteam3RenderedID() +" offered a valid trade.  Trying to accept offer.");
        offer.accept(function (err) {
            if (err) {
                console.error("Unable to accept offer "+ offer.id +": " + err.message);
            } else {
                console.log("Offer accepted");
            }
        });
    } else {
        console.log("User "+ offer.partner.getSteam3RenderedID() +" offered an invalid trade.  Declining offer.");
        offer.decline(function (err) {
            if (err) {
                console.error("Unable to decline offer "+ offer.id +": " + err.message);
            } else {
                console.debug("Offer declined");
            }
        });
    }
});

offers.on('receivedOfferChanged', function (offer, oldState) {
    console.log(offer.partner.getSteam3RenderedID() +" Offer #" + offer.id + " changed: " + TradeOfferManager.getStateName(oldState) + " -> " + TradeOfferManager.getStateName(offer.state));
 
    if (offer.state == TradeOfferManager.ETradeOfferState.Accepted) {
        offer.getReceivedItems(function (err, items) {
            if (err) {
                console.error("Couldn't get received items: " + err);
            } else {
                var names = items.map(function(item) {
                    return item.name;
                });
                console.log("Received: " + names.join(', '));
            }
        });
    }
});
Posted

Working just fine now. Thank you for you fast response!

 

I was wondering if using steam-user and steam-tradeoffer-manager is bannable by steam and if this is secure (Account thief)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...