Comments (26)
I would definitely go with @iNFAM0US's responses, although I would make a few changes and edits for clarity:
//Main ParentBot stuff
const ParentBot = require('steam-parentbot');
var children = [];
var bots = [];
function addBot(options) {
let newestChild = children[children.length];
let newestBot = bots[bots.length]; //should be same number as newestChild
newestChild = function() {
newestChild.super_.apply(this, arguments);
}
require('util').inherits(newestChild, ParentBot);
newestBot = new newestChild(options.username, options.password, options.options);
}
var opt1 = {
username: "username",
password: "password",
options: {
guardCode: "XXXXX"
}
}
var opt2 = {
username: "username",
password: "password",
options: {
guardCode: "XXXXX"
}
}
[opt1, opt2].forEach(opt => {
addBot(opt);
}
//Here you would modify each bot object individually if you like
Please note that I just wrote this on the spot and I have no idea if it works.
Also try to avoid including usernames and passwords in your comments, I've had to edit some posts.
from node-steam-parentbot.
This can happen for 2 reasons:
Probably you've restarted your bot too much/too fast, so steam blocked you for some time. Close your bot and wait.
OR,
Steam is down https://steamstat.us
Little note: Connecting to steam sometimes takes 20~ secs, so be patient :)
from node-steam-parentbot.
well after having ran the bot for a minute now, making it try connect to the socket, not it doesn't just spam with timeouts, not it also spams with 'disconnected from steam, reconnecting..' it also sometimes spams numbers like 017 & 018.
Like this:
2016-03-14T20:43:42.141Z - debug: [tomhillepille] Connecting to Steam...
2016-03-14T20:43:42.316Z - silly: [tomhillepille] connected
2016-03-14T20:43:42.491Z - silly: [tomhillepille] encrypt request
2016-03-14T20:43:42.669Z - verbose: [tomhillepille] Connected to Steam, logging in...
2016-03-14T20:43:42.670Z - debug: [tomhillepille] Logging in...
2016-03-14T20:43:42.930Z - silly: [tomhillepille] socket ended
2016-03-14T20:43:42.930Z - silly: [tomhillepille] socket closed
2016-03-14T20:43:42.930Z - error: [tomhillepille] Disconnected from Steam, reconnecting...
2016-03-14T20:43:42.931Z - silly: [tomhillepille] connecting to 146.66.152.13:27019
edit: the spammed numbers are parts of the IP, sorry. but I never ran the bot before, so how could it block me?
-- I aint even allowed to ping it:
bots@server1:/bots$ ping 72.165.61.176
ping: icmp open socket: Operation not permitted
from node-steam-parentbot.
Ah, my answer is far away from solution, haha!
You should try running your bot with sudo. And also, be sure about your server is allowing tcp/udp socket connections with various ports
from node-steam-parentbot.
mind telling me which ports overall?
Well, IPtables is literally empty, and allows all incomming traffic, and got nothing blocked, and the app is ran with sudo, still aint working.
Besides when I did an manual bot with just node-steam itself, it worked fine.
edit:
Incase if it matters, I'll put my code here:
var util = require('util');
var ParentBot = require('steam-parentbot'); //change to 'steam-parentbot' if not running from examples directory
var Steam = ParentBot.Steam; //instance of the Steam object
var admins = ['76561198071993792'];
var ChildBot = function () {
ChildBot.super_.apply(this, arguments);
}
util.inherits(ChildBot, ParentBot);
var Bot = new ChildBot('username', 'pass');
ChildBot.prototype._onFriend = function(steamID, relationship) {
if(relationship === 2) {
if(admins.indexOf(steamID) !== -1) {
Bot.steamFriends.addFriend(steamID);
}
else {
Bot.logger.warn('Someone who isn\'t an admin tried to add me, denying...');
Bot.steamFriends.removeFriend(steamID);
}
}
}
ChildBot.prototype._onLogOnResponse = function(response) {
if (response.eresult === Steam.EResult.OK) {
Bot.logger.info('Logged into Steam!');
Bot.steamFriends.setPersonaState(Steam.EPersonaState == 1);
Bot.steamFriends.setPersonaName('Hewwo');
Bot.steamFriends.joinChat('103582791442169035');
}
}
Bot.steamTrading.on('tradeProposed', function (tradeID, steamID) { //create your own listeners
Bot.steamTrading.respondToTrade(tradeID, false);
Bot.logger.verbose('Trade request from ' + steamID);
});
Bot.connect(); //connect to steam
from node-steam-parentbot.
Try commenting out your onlogonresponset and see what the response is. Since you are only testing one value, there is no way to see what it is if it isn't OK.
from node-steam-parentbot.
Same response, and I commented it out like so:
/*ChildBot.prototype._onLogOnResponse = function(response) {
if (response.eresult === Steam.EResult.OK) {
Bot.logger.info('Logged into Steam!');
Bot.steamFriends.setPersonaState(Steam.EPersonaState == 1);
Bot.steamFriends.setPersonaName('Hewwo');
Bot.steamFriends.joinChat('103582791442169035');
}
}*/
from node-steam-parentbot.
It shouldn't be giving the same response. Try running it longer to see if you get anything different, since the socket stuff just means there are connection problems.
from node-steam-parentbot.
Alright now it works, but when I uncomment my 'custom' response I get this:
/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:1769
throw Error("Illegal value for "+this.toString(true)+" of type "+this.type.name+": "+val+" ("+msg+")");
^
Error: Illegal value for [object Object] of type uint32: boolean (not an integer)
at Error (native)
at null.<anonymous> (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:1769:23)
at ProtoBuf.Reflect.ElementPrototype.verifyValue (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:1785:25)
at ProtoBuf.Reflect.FieldPrototype.verifyValue (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:3436:33)
at MessagePrototype.set (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:2443:59)
at MessagePrototype.set (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:2434:38)
at Message (/bots/node_modules/steam/node_modules/steam-resources/node_modules/protobufjs/dist/ProtoBuf.js:2363:34)
at SteamFriends.setPersonaState (/bots/node_modules/steam/lib/handlers/friends/index.js:53:6)
at ChildBot._onLogOnResponse (/bots/bot.js:31:22)
at SteamClient.<anonymous> (/bots/node_modules/steam-parentbot/parentbot.js:76:56)
Edit: Its a typo in your example, you have to set == 1 to .Online :x
from node-steam-parentbot.
the problem now is, when I do a substring on a command, it works if I just type the command, but when I do like an argument, it wont work, any ideas on making like, arguments?
from node-steam-parentbot.
Are you talking about args for commands, like !add 5 will add 5 items? Search up string.split
from node-steam-parentbot.
yea I tried string.split, but when doing like
if(msg[1] == "message"){}
it wont run the code. and ontop I did like:
msg = msg.split(" ");
also, how would I make multiple bot instances within one file? Would I only have to copy Bot = new... and rename it to Bot2?
from node-steam-parentbot.
For multiple bots, you can use this:
var botMain = require('steam-parentbot');
var botMains = [], Bots = []
function addBot(usern, passw, other) {
bml = botMains.length;
botMains[bml] = function () {
botMains[bml].super_.apply(this, arguments);
};
util.inherits(botMains[bml], botMain);
Bots.push(new botMains[bml](usern, passw, other));
return bml;
}
example usage of addBot:
addBot('user', 'pass', {
sharedSecret : 'XXXXXXXXXXXXXXXXXXXXX',
identitySecret : 'XXXX/XXXXXXXXXXXXXXXXX=',
confirmationInterval : 2000
});
Bots.forEach(function (bot) {
console.log('Bot name:' + bot.username);
bot.connect();
});
from node-steam-parentbot.
Would all my listeners work on every of those bots though?(Sorry, didn't work THAT much with jscript yet) If yes, how would I use it/How would I make bot specific listeners? Would I do like
var Bot = addBot(blahblahblah);?
from node-steam-parentbot.
It will work with default listeners but if you want to change, you should use somehing like this (my parentbot is heavily edited, so your event names and object names can be different)
Bots.forEach(function (bot) {
bot.offerManager.on('newOffer', function (offer) {
handleOffers(bot, offer);
});
bot.connect();
})
Edit:
Another example (not tested but you'll get the idea)
Bots.forEach(function (bot) {
bot.steamTrading.on('tradeProposed', function (tradeID, steamID) { //create your own listeners
bot.steamTrading.respondToTrade(tradeID, false);
bot.logger.verbose('Trade request from ' + steamID);
});
bot.connect();
})
from node-steam-parentbot.
How would I use the returned value though? I got something like this..
function addBot(usern, passw, other) {
bml = botMains.length;
botMains[bml] = function () {
botMains[bml].super_.apply(this, arguments);
};
util.inherits(botMains[bml], botMain);
Bots.push(new botMains[bml](usern, passw, other));
return bml;
}
var Bot = addBot('nah', 'nah', {
guardCode: 'nah!!'
});
/*var ChildBot = function () {
ChildBot.super_.apply(this, arguments);
}
util.inherits(ChildBot, ParentBot);
var Bot = new ChildBot('username', 'password', {
guardCode: 'XXXXX',
});*/
function isAdmin(sid) {
if(admins.indexOf(sid) !== -1) {
return true;
}
return false;
}
/*--------------------------------------------------
Function overwrides
--------------------------------------------------*/
botMains[Bot].prototype._onFriend = function(steamID, relationship) {
if(relationship === 2) {
if(admins.indexOf(steamID) !== -1) {
Bot.steamFriends.addFriend(steamID);
}
else {
Bot.logger.warn('Someone who isn\'t an admin tried to add me, denying...');
Bot.steamFriends.removeFriend(steamID);
}
}
}
[...]
Bot.steamTrading.on('tradeProposed', function (tradeID, steamID) { //create your own listeners
Bot.steamTrading.respondToTrade(tradeID, false);
Bot.logger.verbose('Trade request from ' + steamID);
});
My problem is, now the default overwrides seem to work(dont error anymore), but now it errors on the Bot.steamTrading.on part
Bot.steamTrading.on('tradeProposed', function (tradeID, steamID) { //create your own listeners
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (/bots/bot.js:108:17)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
from node-steam-parentbot.
Please check my last answer. You should not add your listeners like that
from node-steam-parentbot.
sigh that'd mean I would have to recode the whole file, since I actually fully coded it for one bot already :/
from node-steam-parentbot.
Yeah, but my solution is not the only solution. Wait for other people's answer or think about your own solution :)
from node-steam-parentbot.
Can the bots also be used to post And/Or read comments? (Since I saw such), and the same with announcements?
I mean I tried Bot.steamCommunity etc, but it always failed (Even with the ParentBot method, as shown in the docs).
from node-steam-parentbot.
@originalwhitestar yes, you can do all of those. For posting comments you should see this. For reading comments, you should look up HTML scrapping, since I am not sure if there is another way to do it. For posting announcements, check out this.
This are all within the SteamCommunity module, which can be accessed by Bot.steamCommunity
.
from node-steam-parentbot.
I tried
Bot.steamCommunity.comment();
and
Bot.steamCommunity.postUserComment();
both failing.
from node-steam-parentbot.
Could you show your code please?
from node-steam-parentbot.
if (msg.substring(0, 8) == '/comment' && isAdmin(sid) && msg.substring(8) != '') {
//Bot.steamCommunity.comment('ID', msg.substring(8));
Bot.steamCommunity.postUserComment('ID', msg.substring(8));
};
from node-steam-parentbot.
The 'ID' needs to be a SteamID
object, so you should do it like this:
const ParentBot = require('steam-parentbot');
const SteamCommunity = ParentBot.SteamCommunity;
const SteamID = SteamCommunity.SteamID;
if(msg.Substring(0, 8) === '/comment' && isAdmin(sid) && msg.substring(8) !== '') {
Bot.steamCommunity.postUserComment(new SteamID('ID'), msg.substring(8));
}
from node-steam-parentbot.
Closing after 7 days of inactivity.
from node-steam-parentbot.
Related Issues (20)
- How to generate HOT 6
- Handling sended offers :) HOT 2
- What is an identity secret? HOT 27
- Why steam is not working HOT 2
- How to get .2fa_info files. HOT 3
- Cannot Automatically Accept Trade Offers HOT 28
- Offer sending failure HOT 4
- Problem with hold duration! HOT 3
- I'm getting unexpected disconnection all the time HOT 6
- IS IT INCLUDE MANAGER? HOT 2
- How to get data on weblogon? HOT 1
- How can I reconnect from steamweblogon programmatically? HOT 3
- Handling Offers HOT 2
- Recent issue with NodeJS reinstall HOT 10
- [Q] Worth changing to ES6 version? HOT 1
- steamCommunity instance is 'community'? HOT 9
- Limit numbers of cSteamGroup.getGroupMembers() returns HOT 4
- smsCode HOT 30
- Array of bots and handlers HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-steam-parentbot.