Jump to content
McKay Development

anonimus16

Member
  • Posts

    1
  • Joined

  • Last visited

anonimus16's Achievements

  1. Hello In 2018 I used your steam bot written in nodejs. I found this bot somewhere on the internet and customized it as much as possible for my needs. The bot worked quite well, although it had one defect, because after some time of the bot's operation, when someone sent him an offer then this offer was not accepted, an unspecified error appeared in the logs. I blamed it on errors in the libraries and after some time I stopped using the bot. Today in 2021 I decided to run the bot again, I downloaded the latest versions of libraries but there were many problems to run it. It seems to me that during this time the commands that were used by the bot at that time have changed, because a common problem was that nodejs some command was not recognized, although once everything worked. I have no programming knowledge, but I was able to get it working again, although not everything works as it used to so I ask you for help. Bot functions: -Accepting automatically users who add him to friends -Accept automatically offers that contain any item or items from the steam inventory of the user who sent the offer and reject those that contain any item that is in the steam bot's inventory. This seems to work and did work in 2018, but as I mentioned, after it had been running for a while an error would pop up and the bot wouldn't accept offers it should. Maybe something like steam session refresh was missing? -Simple chat with commands which will explain how bot works -Recording logs of what the bot does. Here I had to cut practically everything, because as I mentioned earlier, it seems that old commands do not work on current libraries. I would like this functionality to be fully restored. I am not a programmer, my knowledge is very elementary, and I would really like someone to help me rebuild the code so that everything works as before. var SteamTotp = require('steam-totp'); var Winston = require('winston'); // For logging var SteamUser = require('steam-user'); // The heart of the bot. We'll write the soul ourselves. var TradeOfferManager = require('steam-tradeoffer-manager'); // Only required if you're using trade offers var config = require('./config.js'); var fs = require('fs'); // For writing a dope-ass file for TradeOfferManager var SteamTrade = require('steam-trade'); var steamcommunity = require('steamcommunity'); var trade = new SteamTrade(); var steamcommunity = new steamcommunity(); // We have to use application IDs in our requests--this is just a helper var appid = { TF2: 440, DOTA2: 570, CSGO: 730, Steam: 753 }; // We also have to know context IDs which are a bit tricker since they're undocumented. // For Steam, ID 1 is gifts and 6 is trading cards/emoticons/backgrounds // For all current Valve games the context ID is 2. var contextid = { TF2: 2, DOTA2: 2, CSGO: 2, Steam: 6 } // Setup logging to file and console var logger = new (Winston.createLogger)({ transports: [ new (Winston.transports.Console)({ colorize: true, level: 'debug' }), new (Winston.transports.File)({ level: 'info', timestamp: true, filename: 'cratedump.log', json: false }) ] }); // Initialize the Steam client and our trading library var client = new SteamUser(); var offers = new TradeOfferManager({ steam: client, domain: config.domain, language: "pl", // English item descriptions // (Poll every 10 seconds (10,000 ms) cancelTime: 864000000 // Expire any outgoing trade offers that have been up for 5+ minutes (300,000 ms) }); // If we've run this before, we should have a saved copy of our poll data. // We can load this up to gracefully resume polling as if we never crashed/quit fs.readFile('polldata.json', function (err, data) { if (err) { logger.warn('Error reading polldata.json. If this is the first run, this is expected behavior: '+err); } else { logger.debug("Found previous trade offer poll data. Importing it to keep things running smoothly."); offers.pollData = JSON.parse(data); } }); // Sign into Steam client.logOn({ accountName: 'xxx', password: 'xxx', twoFactorCode: SteamTotp.generateAuthCode('xxx'), rememberPassword: true, autoRelogin: true }); client.on('loggedOn', function (details) { logger.info("Logged into Steam as " + client.steamID.getSteam3RenderedID()); // If you wanted to go in-game after logging in (for crafting or whatever), you can do the following client.gamesPlayed(["xxx", 570]); }); client.on('error', function (e) { // Some error occurred during logon. ENums found here: // https://github.com/SteamRE/SteamKit/blob/SteamKit_1.6.3/Resources/SteamLanguage/eresult.steamd logger.error(e); process.exit(1); }); client.on('webSession', function (sessionID, cookies) { logger.debug("Got web session"); // Set our status to "Online" (otherwise we always appear offline) client.setPersona(SteamUser.EPersonaState.Online); offers.setCookies(cookies, function (err){ if (err) { logger.error('Unable to set trade offer cookies: '+err); process.exit(1); // No point in staying up if we can't use trade offers } logger.debug("Trade offer cookies set. Got API Key: "+offers.apiKey); }); }); client.on('friendRelationship', function(sid, relationship) { if(relationship == 2) { client.addFriend(sid); client.chatMessage(sid, 'xxx'); } }); // Emitted when Steam sends a notification of new items. // Not important in our case, but kind of neat. client.on('newItems', function (count) { logger.info(count + " new items in our inventory"); }); // Emitted on login and when email info changes // Not important in our case, but kind of neat. client.on('emailInfo', function (address, validated) { logger.info("Our email address is " + address + " and it's " + (validated ? "validated" : "not validated")); }); // Emitted on login and when wallet balance changes // Not important in our case, but kind of neat. client.on('wallet', function (hasWallet, currency, balance) { if (hasWallet) { logger.info("We have "+ SteamUser.formatCurrency(balance, currency) +" Steam wallet credit remaining"); } else { logger.info("We do not have a Steam wallet."); } }); // Looking at your account limitations can be very useful depending on what you're doing client.on('accountLimitations', function (limited, communityBanned, locked, canInviteFriends) { if (limited) { // More info: https://support.steampowered.com/kb_article.php?ref=3330-IAGK-7663 logger.warn("Our account is limited. We cannot send friend invites, use the market, open group chat, or access the web API."); } if (communityBanned){ // More info: https://support.steampowered.com/kb_article.php?ref=4312-UOJL-0835 // http://forums.steampowered.com/forums/showpost.php?p=17054612&postcount=3 logger.warn("Our account is banned from Steam Community"); // I don't know if this alone means you can't trade or not. } if (locked){ // Either self-locked or locked by a Valve employee: http://forums.steampowered.com/forums/showpost.php?p=17054612&postcount=3 logger.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){ // This could be important if you need to add users. In our case, they add us or just use a direct tradeoffer link. logger.warn("Our account is unable to send friend requests."); } }); // Steam Friends documentation: https://github.com/seishun/node-steam/tree/master/lib/handlers/friends // Note: Steam-User initializes this for us by default as of v1.2.0 client.on('friendMessage', function (steamID, message, type) { // Only on complete regular messages if (message == ("!pomoc")) { client.chatMessage(steamID, "xxx"); } else if (message == ("!komendy")) { client.chatMessage(steamID, "xxx"); } else if (message == ("!info")) { client.chatMessage(steamID, "xxx"); } else if (message == ("!cennik")) { client.chatMessage(steamID, "xxx"); } else if (message == ("!PSC")) { client.chatMessage(steamID, "xxx"); } else { client.chatMessage(steamID, "xxx"); } }); // If you wanted to use regular trading, you can respond to requests via: client.trading.on('tradeProposed', function(tradeID, steamID){...}); // Docs here: https://github.com/seishun/node-steam/tree/master/lib/handlers/trading // But we're not going to do that! // When we get a new offer... offers.on('newOffer', function (offer) { logger.info("New offer #"+ offer.id +" from "+ offer.partner.getSteam3RenderedID()); // Accept any trade offer from the bot administrator, or where we're getting free stuff. if (offer.partner.getSteamID64() === config.admin || offer.itemsToGive.length === 0) { logger.info("User "+ offer.partner.getSteam3RenderedID() +" offered a valid trade. Trying to accept offer."); trade.open(trade.tradePartnerSteamID); offer.accept(function (err) { if (err) { logger.error("Unable to accept offer "+ offer.id +": " + err.message); } else { logger.info("Offer accepted"); client.chatMessage(offer.partner.getSteamID64(), "xxx"); } }); } else { // Otherwise deny it and message the user logger.info("User "+ offer.partner.getSteam3RenderedID() +" offered an invalid trade. Declining offer."); offer.decline(function (err) { if (err) { logger.error("Unable to decline offer "+ offer.id +": " + err.message); } else { logger.debug("Offer declined"); // Message the user client.chatMessage(offer.partner.getSteamID64(), "xxx "); } }); } }); // When one of our offers changes states offers.on('sentOfferChanged', function (offer, oldState) { // Alert us when one of our offers is accepted if (offer.state == TradeOfferManager.ETradeOfferState.Accepted) { logger.info("Our sent offer #"+ offer.id + " has been accepted."); } }); // Steam is down or the API is having issues offers.on('pollFailure', function (err) { logger.error("Error polling for trade offers: "+err); });
×
×
  • Create New...