Jump to content
McKay Development

Siezek1

Member
  • Posts

    15
  • Joined

  • Last visited

Posts posted by Siezek1

  1.  I have this problem:

     

    root@Siezek:/home/trade# node bot

    Wed Aug 28 2019 10:36:33 GMT+0200 (Central European Summer Time) - Connected...
    events.js:180
          throw er; // Unhandled 'error' event
          ^
     
    Error: Disconnected
        at SteamClient._disconnected (/home/trade/node_modules/steam/lib/steam_client.js:189:24)
        at Connection.emit (events.js:203:13)
        at TCP.<anonymous> (net.js:588:12)
    Emitted 'error' event at:
        at SteamClient._disconnected (/home/trade/node_modules/steam/lib/steam_client.js:189:10)
        at Connection.emit (events.js:203:13)
        at TCP.<anonymous> (net.js:588:12)
     

     

    My bot:

     

    bot.js

     

     

    var Steam = require('steam');
    var SteamUser = require('steam-user');
    var TradeOfferManager = require('steam-tradeoffer-manager');
    var SteamTotp = require('steam-totp');
    var Steamcommunity = require('steamcommunity');
    var SteamWebLogOn = require('steam-weblogon');
     
    var util = require('util');
    var UInt64 = require('cuint').UINT64;
     
    var client = new SteamUser();
     
    var steamClient = new Steam.SteamClient();
    var steamUser = new Steam.SteamUser(steamClient);
    var steamFriends = new Steam.SteamFriends(steamClient);
    var steamWebLogOn = new SteamWebLogOn(steamClient, steamUser);
     
    var community = new Steamcommunity();
    var manager = new TradeOfferManager({
    "steam": client,
    "domain": "siezek.tk",
    "language": "en"
    });
     
    var config = require('./config');
     
    var code = SteamTotp.generateAuthCode(config.bot.shared_secret);
     
    var logOnOptions = {
    account_name: config.bot.username,
    password: config.bot.password,
    two_factor_code: code
    }
     
    function log(message) 
    {
    console.log(new Date().toString() + ' - ' + message);
    steamFriends.sendMessage(config.admin, message.toString());
    }
     
    function steamIdObjectToSteamId64(steamIdObject) {
    return new UInt64(steamIdObject.accountid, (steamIdObject.universe << 24) | (steamIdObject.type << 20) | (steamIdObject.instance)).toString();
    }
     
    function Login(logOnOptions) 
    {
    steamClient.connect();
     
    steamClient.on('connected', function() {
    log('Connected...');
    steamUser.logOn(logOnOptions);
    });
     
    steamClient.on('logOnResponse', function(logonResp) {
    if (logonResp.eresult === Steam.EResult.OK) {
    log('Login Successful!');
    steamFriends.setPersonaState(Steam.EPersonaState.Online);
                            steamUser.gamesPlayed({
                              games_played: [{
                              game_id: '15444025664222527488',
                              game_extra_info:  '1 CS:GO key -> ' + config.sets_per_key + ' sets'
                               }]
                            });
    steamWebLogOn.webLogOn(function(sessionID, cookies) {
    manager.setCookies(cookies, function(err) {
    if(err) {
    log(err);
    process.exit(1);
    return;
    }
    });
     
    community.setCookies(cookies);
    community.startConfirmationChecker(30000, config.bot.identity_secret);
     
    if(community.chatState == 0) {
    community.chatLogon();
    }
     
    community.on('chatMessage', function(sender, text) {
    handleChatMessages(sender, text);
    });
    });
    }
    else { log(logonResp.eresult); }
    });
    }
     
    function handleChatMessages(steamID, message) {
     
    steamID = steamIdObjectToSteamId64(steamID);
     
    message = message.trim();
     
    var friendList = steamFriends.friends;
     
    if(friendList[steamID] && friendList[steamID] == Steam.EFriendRelationship.Friend) {
    if(message.indexOf('!pomoc') > -1) {
    steamFriends.sendMessage(steamID, config.message.help.toString());
    }
    else if(message.indexOf('!kup') > -1) {
     
    numberOfKeys = message.replace ( /[^\d.]/g, '' );
     
    if(isNaN(numberOfKeys) == true) { steamFriends.sendMessage(steamID, config.message.invalid_number_of_keys.toString()); }
    else {
    if(numberOfKeys > config.max_number_of_keys) { steamFriends.sendMessage(steamID, config.message.excess_keys.toString()); }
    else {
    sellSets(steamID, Math.round(numberOfKeys));
    steamFriends.sendMessage(steamID, config.message.buy.toString());
    }
    }
    }
    else { steamFriends.sendMessage(steamID, config.message.invalid_command.toString()); }
    }
    else {
    community.chatMessage(steamID, config.message.not_in_friendlist.toString());
    }
    }
     
    var getSpecificItemFromInventoryByTagName = function(inventory, tagName) {
    var inventoryItems = [];
     
    inventory.forEach(function(inventoryItem) {
    if(inventoryItem.tags) { 
    inventoryItem.tags.forEach(function(tag) {
    if(tag.name && tag.name == tagName) {
    inventoryItems.push(inventoryItem);
    }
    }); 
    }
    });
    return inventoryItems;
    }
     
    var getSpecificNumberOfItemsFromInventory = function(itemInventory, numberOfItems) {
    var items = [];
     
    for(var i =  0; i < numberOfItems; i++) {
    if(i < itemInventory.length) {
    var item = itemInventory;
    items.push({ assetid: item.assetid, appid: item.appid, contextid: item.contextid, amount: 1});
    }
    }
     
    return items;
    }
     
    var getSmallerNumber = function(first, second) {
    return Math.min(first, second);
    }
     
     
    function sellSets(steamID, numberOfKeys) {
    var theirItems = [];
    var myItems = [];
     
    manager.getUserInventoryContents(steamID, config.app_id.csgo, config.context_id.keys, true, function(err, userInventory, userCurrencies) {
     
    userInventory = getSpecificItemFromInventoryByTagName(userInventory, 'Key');
     
    theirItems = getSpecificNumberOfItemsFromInventory(userInventory, numberOfKeys);
     
    if(theirItems.length > 0) {
    manager.getInventoryContents(config.app_id.steam, config.context_id.cards, true, function(err, inventory, currencies) {
     
    numberOfKeys = getSmallerNumber(numberOfKeys, theirItems.length);
    inventory = getSpecificItemFromInventoryByTagName(inventory, 'Trading Card');
     
    var numberOfCardSets = numberOfKeys * config.sets_per_key;
     
    myItems = getSpecificNumberOfItemsFromInventory(inventory, numberOfCardSets);
     
    if(myItems.length > 0) {
    var offer = manager.createOffer(steamID);
     
    offer.addMyItems(myItems);
    offer.addTheirItems(theirItems);
     
    offer.setMessage(config.message.tradeoffer.toString());
     
    offer.send(function(err, status) {
    if(err) { log('Sale of cards failed: ' + err); return; }
     
    if(status == 'pending') { community.checkConfirmations(); log('checkConfirmations executed'); }
     
    steamFriends.sendMessage(steamID, config.message.cards_sold.toString());
    });
    }
    });
    }
     
    });
    }
     
    Login(logOnOptions);
     
    steamFriends.on('friend', function(steamID, relationship) {
    if(relationship == Steam.EFriendRelationship.RequestRecipient) {
    steamFriends.addFriend(steamID);
    steamFriends.sendMessage(steamID, config.message.welcome.toString());
    }
    });
     

     

    Config.js

     

    module.exports = {

     
    admin: '76561198154202739', //id64 admina
     
    bot: {
    name: 'Bot', //nazwa bota
    username: '***', //login
    password: '***', //haslo
    identity_secret: '***', //secret code 
    shared_secret: '***', //secret code
    steam_id: '**', //id64 bota
    apikey: '***', //api key bota
    tradelink: '***' //tradelink bota
    },
     
    message: {
    welcome: 'Witaj', //wiadomosc powitalna
    help: 'pomoc', //wiadomosc informacyjna pod komenda !pomoc
    buy: 'kupno', //wiadomosc ktory sie wyswietli po kupnie od bota
    tradeoffer: 'trade', //wiadomosc ktora sie wyswietli gdy bot bedzie robil trade oferte
    cards_sold: 'dzieki', //wiadomosc po kupnie
    invalid_command: 'nie znana', //nie znana komenda
    invalid_number_of_keys: 'za duzo', //za duza ilosc do kupienia
    excess_keys: 'za duzo', //gdy uzytkownik chce kupic wiecej niz pozwala config bota
    not_in_friendlist: 'ni jestes' //nie jestes na liscie znajmoych
    },
     
    max_number_of_keys: 15, //max ilosc kupna za klucz
     
    sets_per_key: 16, //cena za 1 klucz (1(klucz):16(karty))
     
    app_id: {
    csgo: 730, //steam id sgo
    steam: 753 //steam id
    },
     
    context_id: {
    keys: 2, //klucze csgo
    cards: 6 //karty steam`
    }
    };
     

     

    Help pls

  2. Hi my bot doesnt accept offers, i dont know why.

    My code:

     

    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 config = require('./config.json');
     
    const logOnOptions = {
      accountName: config.username,
      password: config.password,
      twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret),
      rememberPassword: true,
      autoRelogin: true
    };
     
    const client = new SteamUser();
    const community = new SteamCommunity();
    const manager = new TradeOfferManager ({
        steam: client,
        community: community,
        language: 'en'
    });
     
    //Logowanie do Steam
     
    client.logOn(logOnOptions);
     
    client.on('loggedOn', () => {
      console.log('Zalogowano!');
     
      client.setPersona(SteamUser.EPersonaState.Online);
      client.gamesPlayed(["🤙Siezek To Kozak! - !komendy🤙",440,570]);
    });
    //Komendy
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "Siema") {
    client.chatMessage(steamID, "Siema Mordo!");
    });
     
    client.on("friendMessage", function(steamID, message) {
            if (message == "!TwĂłrca") {
                    client.chatMessage(steamID, "MĂłj twĂłrca to Siezek --> https://steamcommunity.com/id/siezekYT");
            }
    });
     
    client.on("friendMessage", function(steamID, message) {
            if (message == "!twĂłrca") {
                    client.chatMessage(steamID, "MĂłj twĂłrca to Siezek --> https://steamcommunity.com/id/siezekYT");
            }
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "!Komendy") {
    client.chatMessage(steamID, "Moje komendy to:");
                    client.chatMessage(steamID, "1. Siema - Przywitanie siÄ™");
                    client.chatMessage(steamID, "2. !TwĂłrca - Pokazuje mojego twĂłrcÄ™");
            client.chatMessage(steamID, "3. !yt - Pokazuje kanaĹ‚ moje twĂłrcy");
                    client.chatMessage(steamID, "4. !donate - Donate dla moje twĂłrcy (WyĹ‚Ä…czone)");
                    client.chatMessage(steamID, "5. !grupa - Grupa mojego Pana na Steam'ie");
                    client.chatMessage(steamID, "6. !rep - Chcesz +rep? ProszÄ™ bardzo!");
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "siema") {
    client.chatMessage(steamID, "Siema Mordo!");
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "!komendy") {
    client.chatMessage(steamID, "Moje komendy to:");
                    client.chatMessage(steamID, "1. Siema - Przywitanie siÄ™");
                    client.chatMessage(steamID, "2. !TwĂłrca - Pokazuje mojego twĂłrcÄ™");
            client.chatMessage(steamID, "3. !yt - Pokazuje kanaĹ‚ moje twĂłrcy");
                    client.chatMessage(steamID, "4. !donate - Donate dla moje twĂłrcy (WyĹ‚Ä…czone)");
                    client.chatMessage(steamID, "5. !grupa - Grupa mojego Pana na Steam'ie");
                    client.chatMessage(steamID, "6. !rep - Chcesz +rep? ProszÄ™ bardzo!");
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "!yt") {
    client.chatMessage(steamID, "Mój kanał na YouTube ->");
            client.chatMessage(steamID, "https://m.youtube.com/c/SiezekGo");
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "!donate") {
          //client.chatMessage(steamID, "JeĹ›li chcesz wysĹ‚ać donate to masz tutaj tradelink");
            client.chatMessage(steamID, "Narazie wyĹ‚Ä…czone");
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
    if (message == "!grupa") {
    client.chatMessage(steamID, "Grupa mojego stwĂłrcy ->");
                    client.chatMessage(steamID, "https://steamcommunity.com/groups/WariatySiezego");
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
            if (message == "!rep") {
                     client.chatMessage(steamID, "PoleciaĹ‚ +repik!");
                     community.postUserComment(steamID, "+rep");
            }
    });
     
    client.on("friendMessage", function(steamID, message) {
            if (message == "!zmien") {
                     client.chatMessage(steamID, "JuĹĽ zmieniam!");
                     community.changeName('siezek');
            } 
    });
     
    client.on("friendMessage", function(steamID, message) {
            if (message == "!twicth") {
                      client.chatMessage(steamID, "Twitch mojego twórcy --> http://twitch.tv/siezek");
            }
    });
     
    //Automatyczne akceptowane do znajomych i grup
     
    client.on('friendRelationship', function(sid, relationship) {
        if (relationship == SteamUser.EFriendRelationship.RequestRecipient) {
            console.log("We recieved a friend request from "+sid);
            client.addFriend(sid, function (err, name) {
                if (err) {
                    console.log(err);
                    return;
                }
                console.log("Accepted user with the name of "+name)
            })
        }
     
    });
     
    client.on('groupRelationship', function(sid, relationship) {
        if (relationship == SteamUser.EClanRelationship.Invited) {
            console.log("We were asked to join steam group #"+sid);
            client.respondToGroupInvite(sid, true);
        }
    });
     
    client.on('friendsList', function() {
        for (var sid in client.myFriends);
            var relationship = client.myFriends[sid]
            if (relationship == SteamUser.EFriendRelationship.RequestRecipient) {
            console.log("(offline) We recieved a friend request from "+sid);
            client.addFriend(sid, function (err, name) {
                if (err) {
                    console.log(err);
                    return;
                }
                console.log("(offline) Accepted user with the name of "+name)
            })
        }
    });
     
    client.on('groupList', function() {
        for (var sid in client.myGroups);
            var relationship = client.myGroups[sid];
            if (relationship == SteamUser.EClanRelationship.Invited) {
            console.log("(offline) We were asked to join steam group #"+sid);
            client.respondToGroupInvite(sid, true);
        }
    })
    //Akceptowanie i odrzucanie ofert
     
    client.on('webSession', (sid, cookies) => {
            manager.setCookies(cookies);
    community.setCookies(cookies);
    community.startConfirmationChecker(20000, config.identitySecret);
    });
     
    function acceptOffer(offer) {
        offer.accept((err) => {
            community.checkConfirmations();
            console.log("We Accepted an offer");
            if (err) console.log("There was an error accepting the offer.");
        });
    }
     
    function declineOffer(offer) {
        offer.decline((err) => {
            console.log("We Declined an offer");
            if (err) console.log("There was an error declining the offer.");
        });
    }
     
    client.setOption("promptSteamGuardCode", true);
     
    manager.on('newOffer', (offer) => {
        if (offer.partner.getSteamID64() === config.ownerID) {
            acceptOffer(offer);
        } else {
        declineOffer(offer);
        }
         
    });
     

     

  3. Hi, if someone can explain to me / help with translating the bot into another language, I mean that the bot was in two languages, eg the command is !Help and so that it can be translated into another language by command, that is, write the command !En I all commands and bot change language to English and vice versa.

  4. Hi, I have a bot problem. I can not idolize a few games at once, I can only go to Tf2, if I want another free game and I can not do it, why?

     

    My code:

    client.logOn(logOnOptions);

     

    client.on('loggedOn', () => {

    console.log('Zalogowano!');

     

    client.setPersona(SteamUser.EPersonaState.Online);

    client.gamesPlayed(["Siezek To Kozak!"],440);

    });

  5. Hi, give me a line of code to let my bot write a comment to friends for adding it to a friend? And if it's possible, it's a line of code with an option, like a bot friend writing a command to him, for example! Rep bot writes him in the comment "+ rep"

    Thank You

     

     

    EDIT:

    Repaired

×
×
  • Create New...