Siezek1 Posted August 28, 2019 Report Posted August 28, 2019 I have this problem: root@Siezek:/home/trade# node botWed 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 botausername: '***', //loginpassword: '***', //hasloidentity_secret: '***', //secret code shared_secret: '***', //secret codesteam_id: '**', //id64 botaapikey: '***', //api key botatradelink: '***' //tradelink bota}, message: {welcome: 'Witaj', //wiadomosc powitalnahelp: 'pomoc', //wiadomosc informacyjna pod komenda !pomocbuy: 'kupno', //wiadomosc ktory sie wyswietli po kupnie od botatradeoffer: 'trade', //wiadomosc ktora sie wyswietli gdy bot bedzie robil trade ofertecards_sold: 'dzieki', //wiadomosc po kupnieinvalid_command: 'nie znana', //nie znana komendainvalid_number_of_keys: 'za duzo', //za duza ilosc do kupieniaexcess_keys: 'za duzo', //gdy uzytkownik chce kupic wiecej niz pozwala config botanot_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 sgosteam: 753 //steam id}, context_id: {keys: 2, //klucze csgocards: 6 //karty steam` }}; Help pls Quote
Recommended Posts
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.