Skip to content

Commit

Permalink
Version 2.11 (read commit description)
Browse files Browse the repository at this point in the history
The majority of the application has been restructured and rewritten. The whole bot is now being started in a child_process. Added !groupcomment command to be able to comment in groups. Added !sessions and !mysessions commands (#103). Improved logs by adding my output-logger library, added more log messages and improved many existing log messages. Improved automatic error handling. Fixed node-steamcommunity not using proxies and improved proxy support a lot in general. Improved response of !settings, !log & !failed commands. !failed and !abort now use the reciever steamid as parameter instead of the requester steamid. Only certain commands are now blocked during startup (#105). Probably fixed and improved a lot more stuff passively and without noticing. Updated dependencies. If you are interested in more detail check out the 131 commits between 2.10.7 and 2.11. *At least node.js v14.15.0 is now required!*
  • Loading branch information
3urobeat authored Oct 17, 2021
2 parents 7b174a2 + 274ee79 commit dfdec1e
Show file tree
Hide file tree
Showing 59 changed files with 8,643 additions and 3,371 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

                                        
[![YouTube](https://img.shields.io/badge/YouTube-Tutorial-red)](https://youtu.be/gmA-ccD05g4)
[![nodejs](https://img.shields.io/badge/node.js-v12-brightgreen)](https://nodejs.org/)
[![nodejs](https://img.shields.io/badge/node.js-v14-brightgreen)](https://nodejs.org/)
[![Star](https://img.shields.io/badge/-Give%20this%20repo%20a%20star!-yellow)](https://github.com/HerrEurobeat/steam-comment-service-bot)
[![Steam Group](https://img.shields.io/badge/Steam%20Group-Join!-blue)](https://steamcommunity.com/groups/3urobeatGroup)
[![Donate](https://img.shields.io/badge/donate-%241-orange)](https://paypal.me/3urobeat)
Expand Down Expand Up @@ -47,7 +47,7 @@ This is a basic setup guide. Visit the [Wiki](https://github.com/HerrEurobeat/st
Click here: [Download](https://github.com/HerrEurobeat/steam-comment-service-bot/archive/master.zip)
Extract the zip and open the `steam-comment-service-bot` folder.

Have at least node.js version 12 installed: [Download](https://nodejs.org)
You need to have at least node.js version 14.15.0 installed: [Download](https://nodejs.org)
To get your version number type `node --version` in your console or terminal.
If you need a tutorial for this specific node part, [click here.](https://youtu.be/gmA-ccD05g4?t=35)

Expand Down Expand Up @@ -131,3 +131,4 @@ Thanks [mikelobam](https://github.com/mikelobam) for contributing to this projec
Thanks [dunderzutt](https://steamcommunity.com/id/Dunderzutt/) for donating 25€! Really appreciate it!
Thanks [Lujza](https://steamcommunity.com/id/7656119829563751) for donating ~4€ in TF2 keys!
Thanks [Orel](https://steamcommunity.com/id/ReloBOT/) for donating 4€!
Thanks [Ecstasyyy](https://steamcommunity.com/id/elrondnetwork/) for donating ~10€ in TF2 keys!
2,592 changes: 2,288 additions & 304 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"description": "Request multiple steam profile comments by texting a bot network!",
"main": "start.js",
"dependencies": {
"@yetzt/nedb": "^1.8.0",
"@seald-io/nedb": "^2.0.4",
"download": "^8.0.0",
"express": "^4.17.1",
"htmlparser2": "^4.1.0",
"https": "^1.0.0",
"steam-user": "^4.19.10",
"steamcommunity": "^3.42.0"
"output-logger": "^1.3.3",
"request": "^2.88.2",
"steam-user": "^4.19.12",
"steamcommunity": "^3.43.1",
"steamid": "^2.0.0",
"steamid-resolver": "^1.2.1"
},
"scripts": {
"start": "node start.js"
Expand Down
1,031 changes: 0 additions & 1,031 deletions src/bot.js

This file was deleted.

170 changes: 170 additions & 0 deletions src/bot/bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* File: bot.js
* Project: steam-comment-service-bot
* Created Date: 09.07.2021 16:26:00
* Author: 3urobeat
*
* Last Modified: 16.10.2021 12:06:00
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/HerrEurobeat>
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/



/**
* Starts & Controls a bot account
* @param {Object} logOnOptions The steam-user logOnOptions object
* @param {Number} loginindex The index of this account in the logininfo object
*/
module.exports.run = (logOnOptions, loginindex) => {
var SteamUser = require('steam-user');
var SteamCommunity = require('steamcommunity');
var request = require("request"); //yes I know, the library is deprecated but steamcommunity uses it aswell so it is used anyway

var login = require("../controller/login.js")
var mainfile = require("./main.js")

//var botdebugmsgs = false //not implemented yet (maybe put these 3 into advancedconfig.json)
var steamuserdebug = false
var steamuserdebugverbose = false
var maxLogOnRetries = 1 //How often a failed logOn will be retried

module.exports.maxLogOnRetries = maxLogOnRetries


//Define the log message prefix of this account in order to
if (loginindex == 0) var thisbot = "Main"
else var thisbot = `Bot ${loginindex}`


//Get proxy of this bot account
if (login.proxyShift >= login.proxies.length) login.proxyShift = 0; //reset proxy counter if we used all proxies to start over again

var thisproxy = login.proxies[login.proxyShift] //define the proxy that will be used for this account

if (!login.additionalaccinfo[loginindex]) login.additionalaccinfo[loginindex] = {};
login.additionalaccinfo[loginindex].thisproxyindex = login.proxyShift //add the proxyindex that is used for this account to the additionalaccinfo obj

login.proxyShift++ //switch to next proxy


//Create bot & community instance
const bot = new SteamUser({ autoRelogin: false, httpProxy: thisproxy });
const community = new SteamCommunity({ request: request.defaults({ "proxy": thisproxy }) }) //pass proxy to community library aswell


//Attach debug log events
if (steamuserdebug) {
bot.on("debug", (msg) => {
logger("debug", `[${thisbot}] debug: ${msg}`, false, true)
})
}

if (steamuserdebugverbose) {
bot.on("debug-verbose", (msg) => {
logger("debug", `[${thisbot}] debug-verbose: ${msg}`, false, true)
})
}


//Run main.js if this is bot0
if (loginindex == 0) mainfile.run()


/* ------------ Group stuff: ------------ */
require("./helpers/steamgroup.js").botsgroupID64(loginindex, thisbot, (botsgroupid) => { //Check if this account is not in botsgroup yet
if (!Object.keys(bot.myGroups).includes(String(botsgroupid))) {
community.joinGroup(`${botsgroupid}`)

logger("info", `[${thisbot}] Joined/Requested to join steam group that has been set in the config (botsgroup).`)
}
})


/* ------------ Login: ------------ */
login.additionalaccinfo[loginindex].logOnTries = 0;
if(global.checkm8!="b754jfJNgZWGnzogvl<rsHGTR4e368essegs9<")process.send("stop()");

/**
* Logs in all accounts
*/
module.exports.logOnAccount = () => { //make it a function in order to be able to retry a login from error.js

var loggedininterval = setInterval(() => { //set an interval to check if previous acc is logged on

if (login.accisloggedin || login.additionalaccinfo[loginindex].logOnTries > 0) { //start attempt if previous account is logged on or if this call is a retry
clearInterval(loggedininterval) //stop interval

login.accisloggedin = false; //set to false again

login.additionalaccinfo[loginindex].logOnTries++

if (thisproxy == null) logger("info", `[${thisbot}] Trying to log in without proxy... (Attempt ${login.additionalaccinfo[loginindex].logOnTries}/${maxLogOnRetries + 1})`, false, true, logger.animation("loading"))
else logger("info", `[${thisbot}] Trying to log in with proxy ${login.proxyShift - 1}... (Attempt ${login.additionalaccinfo[loginindex].logOnTries}/${maxLogOnRetries + 1})`, false, true, logger.animation("loading"))

bot.logOn(logOnOptions)
}

}, 250);
}

this.logOnAccount(); //login now


/* ------------ Events: ------------ */
bot.on('error', (err) => { //Handle errors that were caused during logOn
require("./events/error.js").run(err, loginindex, thisbot, thisproxy, logOnOptions, bot)
})

bot.on('steamGuard', function(domain, callback, lastCodeWrong) { //fired when steamGuard code is requested when trying to log in
require("./events/steamguard.js").run(loginindex, thisbot, bot, logOnOptions, lastCodeWrong, (code) => {
if (code) callback(code)
})
});

bot.on('loggedOn', () => { //this account is now logged on
require("./events/loggedOn.js").run(loginindex, thisbot, bot, community)
});

bot.on("webSession", (sessionID, cookies) => { //get websession (log in to chat)
require("./events/webSession.js").run(loginindex, thisbot, bot, community, cookies)
});

//Accept Friend & Group requests/invites
bot.on('friendRelationship', (steamID, relationship) => {
require("./events/relationship.js").friendRelationship(loginindex, thisbot, bot, steamID, relationship)
});

bot.on('groupRelationship', (steamID, relationship) => {
require("./events/relationship.js").groupRelationship(loginindex, bot, steamID, relationship)
});


/* ------------ Message interactions: ------------ */
bot.on('friendMessage', function(steamID, message) {
require("./events/friendMessage.js").run(loginindex, thisbot, bot, community, steamID, message)
});

//Display message when connection was lost to Steam
bot.on("disconnected", (eresult, msg) => {
require("./events/disconnected.js").run(loginindex, thisbot, logOnOptions, bot, thisproxy, msg)
})

//Get new websession as sometimes the bot would relog after a lost connection but wouldn't get a websession. Read more about cookies & expiration: https://dev.doctormckay.com/topic/365-cookies/
var lastWebSessionRefresh = Date.now(); //Track when the last refresh was to avoid spamming webLogOn() on sessionExpired

community.on("sessionExpired", () => {
if (Date.now() - lastWebSessionRefresh < 15000) return; //last refresh was 15 seconds ago so ignore this call

logger("info", `[${thisbot}] Session seems to be expired. Trying to get new websession...`)
lastWebSessionRefresh = Date.now() //update time
bot.webLogOn()
})
}

//Code by: https://github.com/HerrEurobeat/
64 changes: 64 additions & 0 deletions src/bot/commands/block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* File: block.js
* Project: steam-comment-service-bot
* Created Date: 09.07.2021 16:26:00
* Author: 3urobeat
*
* Last Modified: 29.09.2021 17:53:35
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/HerrEurobeat>
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/



/**
* Runs the block command
* @param {Function} chatmsg The chatmsg function
* @param {Object} steamID The steamID object from steam-use
* @param {Object} lang The language object
* @param {Array} args The args array
*/
module.exports.block = (chatmsg, steamID, lang, args) => {
var SteamID = require("steamid")
var controller = require("../../controller/controller.js")

if (isNaN(args[0])) return chatmsg(steamID, lang.invalidprofileid)
if (new SteamID(args[0]).isValid() === false) return chatmsg(steamID, lang.invalidprofileid)

Object.keys(controller.botobject).forEach((i) => {
controller.botobject[i].blockUser(new SteamID(args[0]), err => { if (err) logger("error", `[Bot ${i}] error blocking user ${args[0]}: ${err}`) })
})

chatmsg(steamID, lang.blockcmdsuccess.replace("profileid", args[0]))
logger("info", `Blocked ${args[0]} with all bot accounts.`)
}


/**
* Runs the unblock command
* @param {Function} chatmsg The chatmsg function
* @param {Object} steamID The steamID object from steam-use
* @param {Object} lang The language object
* @param {Array} args The args array
*/
module.exports.unblock = (chatmsg, steamID, lang, args) => {
var SteamID = require("steamid")
var controller = require("../../controller/controller.js")

if (isNaN(args[0])) return chatmsg(steamID, lang.invalidprofileid)
if (new SteamID(args[0]).isValid() === false) return chatmsg(steamID, lang.invalidprofileid)

Object.keys(controller.botobject).forEach((i) => {
if (controller.botobject[i].myFriends[new SteamID(args[0])] === 1) {
controller.botobject[i].unblockUser(new SteamID(args[0]), err => { if (err) logger("error", `[Bot ${i}] error blocking user ${args[0]}: ${err}`) })
}
})

chatmsg(steamID, lang.unblockcmdsuccess.replace("profileid", args[0]))
logger("info", `Unblocked ${args[0]} with all bot accounts.`)
}
Loading

0 comments on commit dfdec1e

Please sign in to comment.