Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const SteamUser = require('steam-user');
- const SteamTotp = require('steam-totp');
- const SteamCommunity = require('steamcommunity');
- const TradeOfferManager = require('steam-tradeoffer-manager');
- const fs = require('fs');
- const client = new SteamUser();
- const community = new SteamCommunity();
- const manager = new TradeOfferManager({
- steam: client,
- community: community,
- language: 'en'
- });
- const logOnOptions = {
- accountName: 'accountname', //put your steam username here within the quotes
- password: 'password', //put your steam password here within the quotes
- twoFactorCode: SteamTotp.generateAuthCode('sharedsecret') //put your steam shared secret here within the quotes
- };
- client.logOn(logOnOptions);
- client.on('loggedOn', () => {
- console.log('Logged into Steam with the account name of : ' + logOnOptions.accountName);
- let tf2 = 440;
- let csgo = 730;
- client.setPersona(SteamUser.Steam.EPersonaState.Online);
- client.gamesPlayed(csgo); //here you can put csgo or tf2
- });
- client.on('webSession', (sessionid, cookies) => {
- manager.setCookies(cookies);
- community.setCookies(cookies);
- community.startConfirmationChecker(10000, 'identitysecret');
- console.log('Connected with the api key');
- });
- manager.on('newOffer', (offer) => {
- console.log("New offer #" + offer.id + " from " + offer.partner);
- if (offer.itemsToGive.length === 0) {
- let donation = {
- keys: 0,
- scrap: 0,
- ref: 0,
- rec: 0,
- tot: 0
- }
- for (var i = 0; i < offer.itemsToReceive.length; i++) {
- let item = offer.itemsToReceive[i];
- if(item.name.indexOf('Supply Crate Key')){
- donation.keys++;
- } else if (item.name.indexOf('Refined Metal')){
- donation.ref++;
- } else if (item.name.indexOf('Reclaimed Metal')){
- donation.rec++;
- } else if (item.name.indexOf('Scrap Metal')){
- donation.scrap++;
- }
- }
- donation.tot = (donation.keys * 3) + (donation.scrap * 2) + (donation.ref * 3) + (donation.rec * 4);
- fs.writeFile('donations.txt', 'User: ' + offer.partner.getSteamID64() + ' has a total of : ' + donation.tot + ' tickets', (err) => {
- if(err) {
- console.log(err);
- } else {
- console.log('The donation file was updated');
- offer.accept((err, status) => {
- if (err) {
- console.log(err);
- } else {
- console.log(`Donation accepted. Status: ${status}.`)
- }
- });
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement