Thanks for the prompt response.
I'm making the withdraw request from a website. When a user clicks on an item it withdraws it from the bot's inventory, which should mean the steam user is logged on. Here's a log:
{"message":"Logged into steam as **********","level":"info"}
{"message":"Currently 0,09€ Steam Wallet credit. ","level":"info"}
{"message":"Is limited: false. Is cBanned false.\n Can Invite Friends: true, Is Locked: false","level":"info"}
{"message":"Client Connected as WEBSITE_USER.","level":"debug"}
{"message":"User WEBSITE_USER has a wallet of 45 eur","level":"info"}
{"message":"Session Initialized.","level":"debug"}
{"message":"Cookies, sessionid=5***,steamLogin=7****,steamLoginSecure=7****","level":"debug"}
{"message":"Trade cookies set. API KEY: 5*****","level":"info"}
{"message":"Updating Inventory collection...","level":"debug"}
{"message":"Length of __BOT__ items: 439","level":"debug"}
{"message":"Updated Inventory for Bot with id: 7****","level":"info"}
WEBSITE_USER wants to withdraw assetid
{"message":"TradeOffer: 3811117774 true","level":"debug"}
Error: Must be logged in before trying to do anything with confirmations
The withdraw happened a while (30sec?) after I started the server.
This is how I set the cookies:
this.client.on('webSession', (sessionid: any, cookies: any) => {
logger.debug('Session Initialized.');
logger.debug(`Cookies, ${cookies}`);
this.manager.setCookies(cookies, (err: any) => {
/* Cannot set cookies on, as it is still limited account */
if (err) {
logger.error(`Unable to set trade cookies: ${err}`);
return;
// process.exit(1);
}
logger.info(`Trade cookies set. API KEY: ${this.manager.apiKey}`);
/* Gets all of the Bot's inventory and stores it into inventory Collection
Momentarily only for the Bot's Dota 2 inventory. */
this.fillInventoryOnInit();
/* Accepts all friend requests. Logs unfriends. */
this.initFriendRequestListener();
/* Listens to a chat message from a user. Currently supports only !help */
this.onFriendMessageListener();
/* Accepts all pending requests and logs all messages
that occured while bot was offline */
this.checkFriendsAndMessagesWhileOffline();
/* Logs all new offers, and accepts only if its a donation
or the trader is the admin*/
this.initNewOfferListener();
});
this.community.setCookies(cookies);
this.community.startConfirmationChecker(10000, process.env.STEAM_IDENTITY_SECRET);
});
and this is the withdraw implementation
public sendWithdrawTrade(partner: any, credits: any, assetid: any, gameid: any, cb: Function) {
console.log(assetid, gameid);
const offer = this.manager.createOffer(partner);
this.manager.getInventoryContents(gameid, RequestConfig.contextid.GAMES, true, (err: any, inv: any) => {
if (err) {
return logger.error(`Failed while fetching inventory with ${err}`);
}
const foundItem = inv.find((item: any) => item.assetid === assetid);
if (foundItem) {
offer.addMyItem(foundItem);
offer.setMessage('Withdraw item.');
offer.send((offerError: any, status: any) => {
cb(offerError, (status === 'sent' || status === 'pending'), offer.id, foundItem);
});
} else {
return cb(new Error('Could not find item'), false);
}
});
}
Maybe it has something to do with the web request not sending the cookies through the socket, but I doubt it...
This also fires (as it appears in the log above):
/* Fires if succesfully logged in */
this.client.on('loggedOn', () => {
logger.info(`Logged into steam as ${this.client.steamID}`);
// Sets the Bot status to 'Looking To Trade'
this.client.setPersona(EPersonaState.LookingToTrade);
// game.id(570) = Dota 2;
// Can set only free games. Or paid games that Bot Owns.
this.client.gamesPlayed(RequestConfig.appid.DOTA2);
});
Sorry for the long reply, don't really know where to go from here.
One thing to mention is that the offers are stuck on `Waiting Mobile Confirmation` or something when I check them manually through Steam. Thanks!