diff --git a/config.json b/config.json index 83e9b383..ea448976 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "disableautoupdate": false, - "status": 1, + "childaccsplaygames": false, "commentdelay": 5000, "logindelay": 2500, "allowcommentcmdusage": true, diff --git a/src/bot.js b/src/bot.js index 89ff02d0..72d89a70 100644 --- a/src/bot.js +++ b/src/bot.js @@ -10,11 +10,12 @@ module.exports.run = async (logOnOptions, loginindex) => { const xml2js = require('xml2js'); const https = require('https') - var updater = require('../updater.js') - var controller = require("./controller.js") + var updater = require('../updater.js'); + var controller = require("./controller.js"); var config = require('../config.json'); var extdata = require('./data.json'); - var lastcomment = require("./lastcomment.json") + var cachefile = require('./cache.json'); + var lastcomment = require("./lastcomment.json"); var logger = controller.logger @@ -27,32 +28,42 @@ module.exports.run = async (logOnOptions, loginindex) => { else var thisbot = `Bot ${loginindex}` if (loginindex == 0) { //group64id only needed by main bot -> remove unnecessary load from other bots - configgroup64id = "" //define to avoid not defined errors - if (config.yourgroup.length < 1) { - logger('Skipping group64id request of yourgroup because config.yourgroup is empty.', false, true); //log to output for debugging - configgroup64id = "" + if (cachefile.configgroup == config.yourgroup) { //id is stored in cache file, no need to get it again + logger(`group64id of yourgroup is stored in cache.json...`, false, true) + configgroup64id = cachefile.configgroup64id } else { + logger(`group64id of yourgroup not in cache.json...`, false, true) + configgroup64id = "" //define to avoid not defined errors + if (config.yourgroup.length < 1) { + logger('Skipping group64id request of yourgroup because config.yourgroup is empty.', false, true); //log to output for debugging + configgroup64id = "" + } else { - logger(`Getting group64id of yourgroup...`, false, true) - output = "" - https.get(`${config.yourgroup}/memberslistxml/?xml=1`, function(yourgroupres) { //get group64id from code to simplify config - yourgroupres.on('data', function (chunk) { - output += chunk }); - - yourgroupres.on('end', () => { - new xml2js.Parser().parseString(output, function(err, yourgroupResult) { - if (err) return logger("error parsing yourgroup xml: " + err, true) - if (yourgroupResult.response && yourgroupResult.response.error) { - logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your group (yourgroup in config) doesn't seem to be valid!\n Error: " + yourgroupResult.response.error, true); - configgroup64id = "" - return; } + logger(`Getting group64id of yourgroup...`, false, true) + yourgroupoutput = "" + https.get(`${config.yourgroup}/memberslistxml/?xml=1`, function(yourgroupres) { //get group64id from code to simplify config + yourgroupres.on('data', function (chunk) { + yourgroupoutput += chunk }); - configgroup64id = yourgroupResult.memberList.groupID64 - }) }) - }).on("error", function(err) { - logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get yourgroup 64id. Either Steam is down or your internet isn't working.\n Error: " + err, true) - configgroup64id = "" - }) } } + yourgroupres.on('end', () => { + if (!String(yourgroupoutput).includes("")) { //Check if botsgroupoutput is steam group xml data before parsing it + logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your group (yourgroup in config) doesn't seem to be valid!", true); + configgroup64id = "" + } else { + new xml2js.Parser().parseString(yourgroupoutput, function(err, yourgroupResult) { + if (err) return logger("error parsing yourgroup xml: " + err, true) + + configgroup64id = yourgroupResult.memberList.groupID64 + + cachefile.configgroup = config.yourgroup + cachefile.configgroup64id = String(yourgroupResult.memberList.groupID64) + fs.writeFile("./src/cache.json", JSON.stringify(cachefile, null, 4), err => { + if (err) logger(`[${thisbot}] error writing configgroup64id to cache.json: ${err}`) }) + }) } }) + }).on("error", function(err) { + logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get yourgroup 64id. Either Steam is down or your internet isn't working.\n Error: " + err, true) + configgroup64id = "" + }) } } } /* ------------ Login & Events: ------------ */ @@ -61,67 +72,82 @@ module.exports.run = async (logOnOptions, loginindex) => { clearInterval(loggedininterval) //stop interval controller.accisloggedin = false; //set to false again logger(`[${thisbot}] Trying to log in...`, false, true) - try { - bot.logOn(logOnOptions) - } catch (err) { - logger("Error: " + err, true) - controller.accisloggedin = true; //set to true to log next account in - updater.skippedaccounts.push(loginindex) - } + bot.logOn(logOnOptions) } }, 250); - bot.on('steamGuard', function(domain, callback, lastCodeWrong) { - function askforcode() { + bot.on('error', (err) => { //Handle errors that were caused during logOn + logger(`Error while trying to log in bot${loginindex}: ${err}`, true) + + if (loginindex == 0) { + logger("\nAborting because the first bot account always needs to be logged in!\nPlease correct what caused the error and try again.", true) + process.exit(0) + } else { + logger(`Failed account is not bot0. Skipping account...`, true) + controller.accisloggedin = true; //set to true to log next account in + updater.skippedaccounts.push(loginindex) + controller.skippednow.push(loginindex) } + }) + + bot.on('steamGuard', function(domain, callback, lastCodeWrong) { //fired when steamGuard code is requested when trying to log in + function askforcode() { //function to handle code input, manual skipping with empty input and automatic skipping with skipSteamGuard logger(`[${thisbot}] Steam Guard code requested...`, false, true) - - if (config.skipSteamGuard) { - if (loginindex > 0) { - logger(`[${thisbot}] Skipping account because skipSteamGuard is enabled...`, false, true) - controller.accisloggedin = true; //set to true to log next account in - updater.skippedaccounts.push(loginindex) - return; - } else { - logger("Even with skipSteamGuard enabled, the first account always has to be logged in.", true) - } } - - var steamGuardInputStart = Date.now(); + logger('Code Input', true, true) //extra line with info for output.txt because otherwise the text from above get's halfway stuck in the steamGuard input field + + var steamGuardInputStart = Date.now(); //measure time to subtract it later from readyafter time if (loginindex == 0) { process.stdout.write(`[${logOnOptions.accountName}] Steam Guard Code: `) } else { - process.stdout.write(`[${logOnOptions.accountName}] Steam Guard Code (leave empty and press ENTER to skip account): `) - } - var stdin = process.openStdin(); + process.stdout.write(`[${logOnOptions.accountName}] Steam Guard Code (leave empty and press ENTER to skip account): `) } - stdin.addListener('data', text => { + var stdin = process.openStdin(); //start reading input in terminal + + stdin.resume() + stdin.addListener('data', text => { //fired when input was submitted var code = text.toString().trim() stdin.pause() //stop reading + stdin.removeAllListeners('data') + + if (code == "") { //manual skip initated - if (code == "") { //skip initated - if (loginindex == 0) { + if (loginindex == 0) { //first account can't be skipped logger("The first account always has to be logged in!", true) setTimeout(() => { - askforcode(); + askforcode(); //run function again }, 500); } else { logger(`[${thisbot}] steamGuard input empty, skipping account...`, false, true) + bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds controller.accisloggedin = true; //set to true to log next account in - updater.skippedaccounts.push(loginindex) } + updater.skippedaccounts.push(loginindex) + controller.skippednow.push(loginindex) } } else { //code provided logger(`[${thisbot}] Accepting steamGuard code...`, false, true) - callback(code) - } + callback(code) } //give code back to node-steam-user - controller.steamGuardInputTimeFunc(Date.now() - steamGuardInputStart) + controller.steamGuardInputTimeFunc(Date.now() - steamGuardInputStart) //measure time and subtract it from readyafter time }) } //function end + //check if skipSteamGuard is on so we don't need to prompt the user for a code + if (config.skipSteamGuard) { + if (loginindex > 0) { + logger(`[${thisbot}] Skipping account because skipSteamGuard is enabled...`, false, true) + bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds + controller.accisloggedin = true; //set to true to log next account in + updater.skippedaccounts.push(loginindex) + controller.skippednow.push(loginindex) + return; + } else { + logger("Even with skipSteamGuard enabled, the first account always has to be logged in.", true) + } } + //calling the function: - if (lastCodeWrong) { //last code seems to be wrong - logger("", true, true) - logger(`Your code seems to be wrong, please try again!`, true) + if (lastCodeWrong && !controller.skippednow.includes(loginindex)) { //last submitted code seems to be wrong and the loginindex wasn't already skipped (just to make sure) + logger('', true, true) + logger('Your code seems to be wrong, please try again!', true) setTimeout(() => { askforcode(); //code seems to be wrong! ask again... }, 500); @@ -132,8 +158,9 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.on('loggedOn', () => { //this account is now logged on logger(`[${thisbot}] Account logged in! Waiting for websession...`, false, true) - bot.setPersona(config.status); //set online status + bot.setPersona(1); //set online status if (loginindex == 0) bot.gamesPlayed(config.playinggames); //set game only for the "leader" bot + else if (config.childaccsplaygames) { config.playinggames.shift(); bot.gamesPlayed(config.playinggames); } controller.communityobject[loginindex] = community //export this community instance to the communityobject to access it from controller.js controller.botobject[loginindex] = bot //export this bot instance to the botobject to access it from controller.js @@ -164,8 +191,8 @@ module.exports.run = async (logOnOptions, loginindex) => { if (configgroup64id.length > 1 && Object.keys(bot.myGroups).includes(configgroup64id)) { bot.inviteToGroup(Object.keys(bot.myFriends)[i], new SteamID(configgroup64id)); - if (configgroup64id !== "https://steamcommunity.com/groups/3urobeatGroup") { - bot.inviteToGroup(Object.keys(bot.myFriends)[i], new SteamID("https://steamcommunity.com/groups/3urobeatGroup")); }} //invite the user to your group + if (configgroup64id !== "103582791464712227") { //https://steamcommunity.com/groups/3urobeatGroup + bot.inviteToGroup(Object.keys(bot.myFriends)[i], new SteamID("103582791464712227")); }} //invite the user to your group } if (i + 1 === Object.keys(bot.myFriends).length) { //check for last iteration @@ -193,10 +220,10 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.chatMessage(steamID, 'Hello there! Thanks for adding me!\nRequest a free comment with !comment\nType !help for more commands or !about for more information!') } if (configgroup64id.length > 1 && Object.keys(bot.myGroups).includes(configgroup64id)) { - bot.inviteToGroup(steamID, new SteamID(configgroup64id)); + bot.inviteToGroup(steamID, new SteamID(configgroup64id)); //invite the user to your group - if (configgroup64id != "https://steamcommunity.com/groups/3urobeatGroup") { - bot.inviteToGroup(steamID, new SteamID("https://steamcommunity.com/groups/3urobeatGroup")); }} //invite the user to your group + if (configgroup64id != "103582791464712227") { //https://steamcommunity.com/groups/3urobeatGroup + bot.inviteToGroup(steamID, new SteamID("103582791464712227")); }} lastcomment[new SteamID(String(steamID)).getSteamID64() + loginindex] = { //add user to lastcomment file in order to also unfriend him when he never used !comment time: Date.now() - (config.commentcooldown * 60000), //subtract unfriendtime to enable comment usage immediately @@ -249,6 +276,7 @@ module.exports.run = async (logOnOptions, loginindex) => { else var commenttext = `'!comment' - Request a comment on your profile!` } if (ownercheck) var resetcooldowntext = `\n'!resetcooldown [profileid]'                 - Clear your or the profileid's comment cooldown.`; else var resetcooldowntext = ""; + if (ownercheck) var addfriendtext = `\n'!addfriend (profileid)'                          - Add friend with all bot accounts.`; else var addfriendtext = ""; if (ownercheck) var unfriendtext = `\n'!unfriend (profileid)'                            - Unfriend the user from all bot accounts.`; else var unfriendtext = ""; if (ownercheck) var leavegrouptext = `\n'!leavegroup (groupid64/group url)' - Leave this group with all bot accounts.`; else var leavegrouptext = ""; if (ownercheck) var evaltext = `\n'!eval (javascript code)'                       - Run javascript code from the steam chat.`; else var evaltext = ""; @@ -258,7 +286,7 @@ module.exports.run = async (logOnOptions, loginindex) => { () <-- needed argument\n[] <-- optional argument\n\nCommand list:\n ${commenttext} '!ping'                                                       - Get a pong and heartbeat in ms. - '!info'                                                        - Get useful information about the bot and you.${resetcooldowntext}${unfriendtext}${leavegrouptext} + '!info'                                                        - Get useful information about the bot and you.${resetcooldowntext}${addfriendtext}${unfriendtext}${leavegrouptext} '!failed'                                                     - See the exact errors of your last comment request. '!about'                                                    - Returns information what this is about. '!owner'                                                   - Get a link to the profile of the operator of this bot instance.${evaltext}${restarttext} @@ -295,7 +323,7 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.chatMessage(steamID, `You requested a comment in the last ${config.commentcooldown} minutes. Please wait the remaining ${controller.round(remainingcooldown, 2)} ${remainingcooldownunit}.`) //send error message return; } } else { - if (controller.activecommentprocess.indexOf(String(steam64id)) !== -1) { //is the user already getting comments? + if (controller.activecommentprocess.indexOf(String(steam64id)) !== -1) { //is the user already getting comments? (-1 means not included) return bot.chatMessage(steamID, "You are currently recieving previously requested comments. Please wait for them to be completed.") }} if (config.globalcommentcooldown !== 0) { //check for global cooldown @@ -367,7 +395,7 @@ module.exports.run = async (logOnOptions, loginindex) => { community.postUserComment(steamID, comment, (error) => { //post comment if(error) { - bot.chatMessage(requesterSteamID, `Oops, an error occured! Details: \n[${thisbot}] postUserComment error: ${error}\nPlease try again in a moment!`); + bot.chatMessage(requesterSteamID, `Oops, an error occurred! Details: \n[${thisbot}] postUserComment error: ${error}\nPlease try again in a moment!`); logger(`[${thisbot}] postUserComment error: ${error}`); return; } @@ -422,13 +450,12 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.chatMessage(steamID, "Check out my owner's profile: (for more information about the bot type !about)\n" + config.owner) break; case '!group': - if (config.yourgroup.length < 1 && configgroup64id.length < 1) return bot.chatMessage(steamID, "I don't know that command. Type !help for more info.") //no group info at all? stop. + if (config.yourgroup.length < 1 || configgroup64id.length < 1) return bot.chatMessage(steamID, "The botowner of this instance hasn't provided any group or the group doesn't exist.") //no group info at all? stop. if (configgroup64id.length > 1 && Object.keys(bot.myGroups).includes(configgroup64id)) { bot.inviteToGroup(steamID, configgroup64id); bot.chatMessage(steamID, "I send you an invite! Thanks for joining!"); - if (configgroup64id != "https://steamcommunity.com/groups/3urobeatGroup") { - logger("check") - bot.inviteToGroup(steamID, new SteamID("https://steamcommunity.com/groups/3urobeatGroup")); } + if (configgroup64id != "103582791464712227") { //https://steamcommunity.com/groups/3urobeatGroup + bot.inviteToGroup(steamID, new SteamID("103582791464712227")); } return; } //id? send invite and stop bot.chatMessage(steamID, "Join my group here: " + config.yourgroup) //seems like no id has been saved but an url. Send the user the url @@ -456,6 +483,33 @@ module.exports.run = async (logOnOptions, loginindex) => { case '!about': //Please don't change this message as it gives credit to me; the person who put really much of his free time into this project. The bot will still refer to you - the operator of this instance. bot.chatMessage(steamID, controller.aboutstr) break; + case '!addfriend': + if (!config.ownerid.includes(steam64id)) return bot.chatMessage(steamID, "This command is only available for the botowner.\nIf you are the botowner, make sure you added your ownerid to the config.json.") + if (isNaN(args[0])) return bot.chatMessage(steamID, "This is not a valid profileid! A profile id must look like this: 76561198260031749") + if (new SteamID(args[0]).isValid() === false) return bot.chatMessage(steamID, "This is not a valid profileid! A profile id must look like this: 76561198260031749") + if (controller.botobject[0].limitations.limited == true) { + bot.chatMessage(steamID, `Can't add friend ${args[0]} with bot0 because the bot account is limited.`) + return; } + + bot.chatMessage(steamID, `Adding friend ${args[0]} with all bots... This will take ~${5 * Object.keys(controller.botobject).length} seconds. Please check the terminal for potential errors.`) + logger(`Adding friend ${args[0]} with all bots. This will take ~${5 * Object.keys(controller.botobject).length} seconds.`) + + Object.keys(controller.botobject).forEach((i) => { + if (controller.botobject[i].limitations.limited == true) { + logger(`Can't add friend ${args[0]} with bot${i} because the bot account is limited.`) + return; } + + if (controller.botobject[i].myFriends[new SteamID(args[0])] != 3 && controller.botobject[i].myFriends[new SteamID(args[0])] != 1) { //check if provided user is not friend and not blocked + setTimeout(() => { + controller.communityobject[i].addFriend(new SteamID(args[0]).getSteam3RenderedID(), (err) => { + if (err) logger(`error adding ${args[0]} with bot${i}: ${err}`) + else logger(`Added ${args[0]} with bot${i} as friend.`) + }) + }, 5000 * i); + } else { + logger(`bot${i} is already friend with ${args[0]} or the account was blocked/blocked you.`) //somehow logs steamIDs in seperate row?! + } }) + break; case '!unfriend': if (!config.ownerid.includes(steam64id)) return bot.chatMessage(steamID, "This command is only available for the botowner.\nIf you are the botowner, make sure you added your ownerid to the config.json.") if (isNaN(args[0])) return bot.chatMessage(steamID, "This is not a valid profileid! A profile id must look like this: 76561198260031749") @@ -472,22 +526,22 @@ module.exports.run = async (logOnOptions, loginindex) => { if (isNaN(args[0]) && !String(args[0]).startsWith('https://steamcommunity.com/groups/')) return bot.chatMessage(steamID, "This is not a valid group id or group url! \nA groupid must look like this: '103582791464712227' \n...or a group url like this: 'https://steamcommunity.com/groups/3urobeatGroup'") if (String(args[0]).startsWith('https://steamcommunity.com/groups/')) { - output = "" + leavegroupoutput = "" https.get(`${args[0]}/memberslistxml/?xml=1`, function(leavegroupres) { //get group64id from code to simplify config leavegroupres.on('data', function (chunk) { - output += chunk }); + leavegroupoutput += chunk }); leavegroupres.on('end', () => { - new xml2js.Parser().parseString(output, function(err, leavegroupResult) { - if (err) return logger("error parsing leavegroup xml: " + err, true) - if (leavegroupResult.response && leavegroupResult.response.error) { - logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your leave group link doesn't seem to be valid!\n Error: " + leavegroupResult.response.error, true); - bot.chatMessage("\x1b[0m[\x1b[31mNotice\x1b[0m] Your leave group link doesn't seem to be valid!\n Error: " + leavegroupResult.response.error) - return; } - - args[0] = leavegroupResult.memberList.groupID64 - startleavegroup() - }) }) + if (!String(leavegroupoutput).includes("")) { //Check if botsgroupoutput is steam group xml data before parsing it + logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your leave group link doesn't seem to be valid!", true); + bot.chatMessage("\x1b[0m[\x1b[31mNotice\x1b[0m] Your leave group link doesn't seem to be valid!\n") + } else { + new xml2js.Parser().parseString(leavegroupoutput, function(err, leavegroupResult) { + if (err) return logger("error parsing leavegroup xml: " + err, true) + + args[0] = leavegroupResult.memberList.groupID64 + startleavegroup() + }) } }) }).on("error", function(err) { logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get leavegroup information. Either Steam is down or your internet isn't working.\n Error: " + err) bot.chatMessage(steamID, "\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get leavegroup information. Either Steam is down or your internet isn't working.\n Error: " + err) @@ -544,9 +598,12 @@ module.exports.run = async (logOnOptions, loginindex) => { } }); + bot.on("disconnected", (eresult, msg) => { + logger(`[${thisbot}] Lost connection to Steam. EResult: ${eresult} | Message: ${msg}`) }) + module.exports={ bot } } -//Code by: https://github.com/HerrEurobeat/ +//Code by: https://github.com/HerrEurobeat/ \ No newline at end of file diff --git a/src/controller.js b/src/controller.js index 1e131549..708546e3 100644 --- a/src/controller.js +++ b/src/controller.js @@ -4,6 +4,7 @@ const SteamID = require('steamid'); const fs = require('fs'); const https = require('https') +const readline = require("readline") const xml2js = require('xml2js') var updater = require('../updater.js') @@ -22,6 +23,7 @@ var bootstart = new Date(); var steamGuardInputTime = 0; var readyafter = 0 var activecommentprocess = new Array(); +skippednow = [] //array to track which accounts have been skipped stoplogin = false; process.title = `${extdata.mestr}'s Steam Comment Service Bot v${extdata.version} | ${process.platform}` //set node process name to find it in task manager etc. @@ -38,10 +40,10 @@ var logger = (str, nodate, remove) => { //Custom logger if (readyafter == 0 && !str.toLowerCase().includes("error") && !str.includes('Logging in... Estimated wait time') && !str.includes("What's new:") && remove !== true) { readyafterlogs.push(string); return; }} if (remove) { - process.stdout.clearLine() - process.stdout.write(`${string}\r`) //probably dirty solution but these spaces clear up previous lines that were longer + readline.clearLine(process.stdout, 0) //0 clears entire line + process.stdout.write(`${string}\r`) } else { - process.stdout.clearLine() + readline.clearLine(process.stdout, 0) console.log(`${string}`) } fs.appendFileSync('./output.txt', string.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/g, '') + '\n', err => { //Regex Credit: https://github.com/Filirom1/stripcolorcodes @@ -180,6 +182,31 @@ if (config.repeatedComments < 1) { config.repeatedComments = 1 } if (config.repeatedComments > 2 && config.commentdelay == 5000) { logger("\x1b[0m[\x1b[31mWarning\x1b[0m]: \x1b[31mYou have raised repeatedComments but haven't increased the commentdelay. This can cause cooldown errors from Steam.\x1b[0m", true) } +if (logininfo.bot0 == undefined) { //check real quick if logininfo is empty + logger("\x1b[31mYour logininfo doesn't contain a bot0 or is empty! Aborting...\x1b[0m", true); process.exit(0) } + +//Check cache.json +logger("Checking if cache.json is valid...", false, true) //file can get broken regularly when exiting while the bot was writing etc +fs.readFile('./src/cache.json', function (err, data) { + if (err) logger("error reading cache.json to check if it is valid: " + err, true) + if (stoplogin == true) return; + + try { + JSON.parse(data) + cachefile = require("./cache.json") + } catch (err) { + if (err) { + logger("Your cache.json is broken. No worries I will apply duct tape.\nError: " + err + "\n", true) + + fs.writeFile('./src/cache.json', "{}", (err) => { //write empty valid json + if (err) { + logger("Error writing {} to cache.json.\nPlease do this manually: Go into 'src' folder, open 'cache.json', write '{}' and save.\nOtherwise the bot will always crash.\nError: " + err + "\n\nAborting...", true); + process.exit(0) //abort since writeFile was unable to write and any further execution would crash + } else { + logger("Successfully cleared cache.json.", false, true) + cachefile = require("./cache.json") + } }) + }} }) //Check lastcomment.json logger("Checking if lastcomment.json is valid...", false, true) //file can get broken regularly when exiting while the bot was writing etc @@ -238,62 +265,16 @@ module.exports={ accisloggedin, aboutstr, round, - isSteamOnline } + isSteamOnline, + skippednow } /* ------------ Startup & Login: ------------ */ -module.exports.ascii = ascii = [` - ______ ______ __ __ __ __ ______ __ __ ______ ______ ______ ______ -/\\ ___\\\ /\\ __ \\ /\\ "-./ \\ /\\ "-./ \\ /\\ ___\\ /\\ "-.\\ \\ /\\\__ _\\ /\\ == \\ /\\ __ \\ /\\\__ _\\ -\\ \\ \\____ \\ \\ \\/\\ \\ \\ \\ \\-./\\ \\ \\ \\ \\-./\\ \\ \\ \\ __\\ \\ \\ \\-. \\ \\/_/\\ \\/ \\ \\ __< \\ \\ \\/\\ \\ \\/_/\\ \\/ - \\ \\_____\\\ \\ \\_____\\ \\ \\_\\ \\ \\_\\ \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\ \\_\\\\"\\_\\ \\ \\_\\ \\ \\_____\\ \\ \\_____\\ \\ \\_\\ - \\\/_____/ \\/_____/ \\/_/ \\/_/ \\/_/ \\/_/ \\/_____/ \\/_/ \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ `, -` -_________ __ __________ __ -\\_ ___ \\ ____ _____ _____ ____ _____/ |_ \\______ \\ _____/ |_ -/ \\ \\/ / _ \\ / \\ / \\_/ __ \\ / \\ __\\ | | _// _ \\ __\\ -\\ \\___( <_> ) Y Y \\ Y Y \\ ___/| | \\ | | | ( <_> ) | - \\______ /\\\____/|__|_| /__|_| /\\\___ >___| /__| |______ /\\\____/|__| - \\/ \\/ \\/ \\/ \\/ \\/ `, -` - ___ _____ __ __ __ __ ____ _ _ ____ ____ _____ ____ - / __)( _ )( \\/ )( \\/ )( ___)( \\( )(_ _) ( _ \\( _ )(_ _) -( (__ )(_)( ) ( ) ( )__) ) ( )( ) _ < )(_)( )( - \\___)(_____)(_/\\\/\\\_)(_/\\\/\\\_)(____)(_)\\_) (__) (____/(_____) (__) `, -` - ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ - /\\ \\ /\\ \\ /\\\__\\ /\\\__\\ /\\ \\ /\\\__\\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ - /::\\ \\ /::\\ \\ /::| | /::| | /::\\ \\ /::| | \\:\\\ \\ /::\\ \\ /::\\ \\ \\:\\\ \\ - /:/\\\:\\\ \\ /:/\\\:\\\ \\ /:|:| | /:|:| | /:/\\\:\\\ \\ /:|:| | \\:\\\ \\ /:/\\\:\\\ \\ /:/\\\:\\\ \\ \\:\\\ \\ - /:/ \\:\\\ \\ /:/ \\:\\\ \\ /:/|:|__|__ /:/|:|__|__ /::\\~\\:\\\ \\ /:/|:| |__ /::\\ \\ /::\\~\\:\\\__\\ /:/ \\:\\\ \\ /::\\ \\ -/:/__/ \\:\\\__\\ /:/__/ \\:\\\__\\ /:/ |::::\\\__\\ /:/ |::::\\\__\\ /:/\\\:\\\ \\:\\\__\\ /:/ |:| /\\\__\\ /:/\\\:\\\__\\ /:/\\\:\\\ \\:|__| /:/__/ \\:\\\__\\ /:/\\\:\\\__\\ -\\:\\\ \\ \\/__/ \\:\\\ \\ /:/ / \\/__/~~/:/ / \\/__/~~/:/ / \\:\\\~\\:\\\ \\/__/ \\/__|:|/:/ / /:/ \\/__/ \\:\\\~\\:\\\/:/ / \\:\\\ \\ /:/ / /:/ \\/__/ - \\:\\\ \\ \\:\\\ /:/ / /:/ / /:/ / \\:\\\ \\:\\\__\\ |:/:/ / /:/ / \\:\\\ \\::/ / \\:\\\ /:/ / /:/ / - \\:\\\ \\ \\:\\\/:/ / /:/ / /:/ / \\:\\\ \\/__/ |::/ / \\/__/ \\:\\\/:/ / \\:\\\/:/ / \\/__/ - \\:\\\__\\ \\::/ / /:/ / /:/ / \\:\\\__\\ /:/ / \\::/__/ \\::/ / - \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ ~~ \\/__/ `, -` - ______ __ ____ __ - / ____/___ ____ ___ ____ ___ ___ ____ / /_ / __ )____ / /_ - / / / __ \\/ __ __ \\/ __ __ \\/ _ \\/ __ \\/ __/ / __ / __ \\/ __/ -/ /___/ /_/ / / / / / / / / / / / __/ / / / /_ / /_/ / /_/ / /_ -\\____/\\\____/_/ /_/ /_/_/ /_/ /_/\\\___/_/ /_/\\\__/ /_____/\\\____/\\\__/ `, -` -▄████▄ ▒█████ ███▄ ▄███▓ ███▄ ▄███▓▓█████ ███▄ █ ▄▄▄█████▓ ▄▄▄▄ ▒█████ ▄▄▄█████▓ -▒██▀ ▀█ ▒██▒ ██▒▓██▒▀█▀ ██▒▓██▒▀█▀ ██▒▓█ ▀ ██ ▀█ █ ▓ ██▒ ▓▒ ▓█████▄ ▒██▒ ██▒▓ ██▒ ▓▒ -▒▓█ ▄ ▒██░ ██▒▓██ ▓██░▓██ ▓██░▒███ ▓██ ▀█ ██▒▒ ▓██░ ▒░ ▒██▒ ▄██▒██░ ██▒▒ ▓██░ ▒░ -▒▓▓▄ ▄██▒▒██ ██░▒██ ▒██ ▒██ ▒██ ▒▓█ ▄ ▓██▒ ▐▌██▒░ ▓██▓ ░ ▒██░█▀ ▒██ ██░░ ▓██▓ ░ -▒ ▓███▀ ░░ ████▓▒░▒██▒ ░██▒▒██▒ ░██▒░▒████▒▒██░ ▓██░ ▒██▒ ░ ░▓█ ▀█▓░ ████▓▒░ ▒██▒ ░ -░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ░ ░░ ▒░ ░ ░░░ ▒░ ░░ ▒░ ▒ ▒ ▒ ░░ ░▒▓███▀▒░ ▒░▒░▒░ ▒ ░░ - ░ ▒ ░ ▒ ▒░ ░ ░ ░░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ ░ ▒░▒ ░ ░ ▒ ▒░ ░ -░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ -░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ -░ ░ ` -] - function startlogin() { //function will be called when steamcommunity status check is done logger("", true) - logger(ascii[Math.floor(Math.random() * ascii.length)] + "\n", true) + if (Math.floor(Math.random() * 100) <= 2) logger(hellothereascii + "\n", true) + else if (Math.floor(Math.random() * 100) <= 10) logger(binaryascii + "\n", true) + else logger(ascii[Math.floor(Math.random() * ascii.length)] + "\n", true) logger("", true) //put one line above everything that will come to make the output cleaner if (extdata.firststart) logger("\x1b[0mWhat's new: " + extdata.whatsnew + "\n") @@ -312,12 +293,11 @@ function startlogin() { //function will be called when steamcommunity status che if(checkm8!="b754jfJNgZWGnzogvl { //log all accounts in with the logindelay setTimeout(() => { //wait before interval to reduce ram usage on startup var startnextinterval = setInterval(() => { //check if previous account is logged in - if (module.exports.accisloggedin == true && i == Object.keys(botobject).length || module.exports.accisloggedin == true && skippednow.includes(i - 1)) { //i is being counted from 0, length from 1 -> checks if last iteration is as long as botobject + if (module.exports.accisloggedin == true && i == Object.keys(botobject).length + skippednow.length || module.exports.accisloggedin == true && skippednow.includes(i - 1)) { //i is being counted from 0, length from 1 -> checks if last iteration is as long as botobject clearInterval(startnextinterval) if (updater.skippedaccounts.includes(i)) { logger(`[skippedaccounts] Automatically skipped ${k}!`, false, true); skippednow.push(i); return; } //if this iteration exists in the skippedaccounts array, automatically skip acc again @@ -342,30 +322,37 @@ function startlogin() { //function will be called when steamcommunity status che /* ------------ Everything logged in: ------------ */ var readyinterval = setInterval(() => { //log startup to console - if (Object.keys(communityobject).length == (Object.keys(logininfo).length - updater.skippedaccounts.length) && botobject[Object.keys(botobject).length - 1].limitations != undefined && module.exports.accisloggedin == true) { + if (Object.keys(communityobject).length + skippednow.length == Object.keys(logininfo).length && module.exports.accisloggedin == true) { clearInterval(readyinterval) logger(' ', true) logger('*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*', true) - logger(`> \x1b[96m${logininfo.bot0[0]}\x1b[0m version \x1b[96m${extdata.version}\x1b[0m by ${extdata.mestr} logged in.`, true) + logger(`\x1b[95m>\x1b[0m \x1b[96m${logininfo.bot0[0]}\x1b[0m version \x1b[96m${extdata.version}\x1b[0m by ${extdata.mestr} logged in.`, true) if (config.repeatedComments > 3) { var repeatedComments = `\x1b[4m\x1b[31m${config.repeatedComments}\x1b[0m` } else { var repeatedComments = config.repeatedComments } - logger(`> ${Object.keys(communityobject).length - 1} child accounts | User can request ${repeatedComments} comments per Acc`, true) + logger(`\x1b[94m>\x1b[0m ${Object.keys(communityobject).length - 1} child accounts | User can request ${repeatedComments} comments per Acc`, true) //display amount of limited accounts and if automatic updates are turned off limitedaccs = 0 - for (i = 0; i < Object.keys(botobject).length; i++) { - if (botobject[Object.keys(botobject)[i]].limitations != undefined && botobject[Object.keys(botobject)[i]].limitations.limited != undefined) { //if it should be undefined for what ever reason then rather don't check instead of crash the bot - if (botobject[Object.keys(botobject)[i]] != undefined && botobject[Object.keys(botobject)[i]].limitations.limited == true) limitedaccs++ //yes, this way to get the botobject key by iteration looks stupid and is probably stupid but it works and is "compact" (not really but idk) - } else { logger(`failed to check if bot${i} is limited. Showing account in startup message as unlimited...`, false, true) } - - if (Number(i) + 1 == Object.keys(botobject).length && limitedaccs > 0) - logger(`> ${limitedaccs}/${Object.keys(botobject).length} account(s) are \x1b[31mlimited\x1b[0m`, true) } + failedtocheck = 0 + try { + for (i = 0; i < Object.keys(botobject).length; i++) { + if (botobject[Object.keys(botobject)[i]].limitations != undefined && botobject[Object.keys(botobject)[i]].limitations.limited != undefined) { //if it should be undefined for what ever reason then rather don't check instead of crash the bot + if (botobject[Object.keys(botobject)[i]] != undefined && botobject[Object.keys(botobject)[i]].limitations.limited == true) limitedaccs++ //yes, this way to get the botobject key by iteration looks stupid and is probably stupid but it works and is "compact" (not really but idk) + } else { logger(`failed to check if bot${i} is limited. Showing account in startup message as unlimited...`, false, true); failedtocheck++ } + + if (Number(i) + 1 == Object.keys(botobject).length && limitedaccs > 0) { + if (failedtocheck > 0) { var failedtocheckmsg = `(Couldn't check ${failedtocheck} account(s))`; } + else { var failedtocheckmsg = ""; } + logger(`\x1b[92m>\x1b[0m ${limitedaccs}/${Object.keys(botobject).length} account(s) are \x1b[31mlimited\x1b[0m ${failedtocheckmsg}`, true) }} + } catch (err) { + logger(`Error in limited checker: ${err}`) + } - if (config.disableautoupdate) logger("> Automatic updating is \x1b[31mturned off\x1b[0m!", true) + if (config.disableautoupdate) logger("\x1b[41m\x1b[30m>\x1b[0m Automatic updating is \x1b[4m\x1b[31mturned off\x1b[0m!", true) var playinggames = "" if (config.playinggames[1]) var playinggames = `(${config.playinggames.slice(1, config.playinggames.length)})` - logger(`> Playing status: \x1b[32m${config.playinggames[0]}\x1b[0m ${playinggames}`, true) + logger(`\x1b[93m>\x1b[0m Playing status: \x1b[32m${config.playinggames[0]}\x1b[0m ${playinggames}`, true) const bootend = (new Date() - bootstart) - steamGuardInputTime readyafter = bootend / 1000 @@ -374,12 +361,13 @@ var readyinterval = setInterval(() => { //log startup to console if (readyafter > 60) { readyafter = readyafter / 60; var readyafterunit = "minutes" } if (readyafter > 60) { readyafter = readyafter / 60; var readyafterunit = "hours" } - logger(`> Ready after ${round(readyafter, 2)} ${readyafterunit}!`, true) + logger(`\x1b[91m>\x1b[0m Ready after ${round(readyafter, 2)} ${readyafterunit}!`, true) extdata.timesloggedin++ extdata.totallogintime += readyafter / Object.keys(communityobject).length //get rough logintime of only one account logger('*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*', true) logger(' ', true) - if (updater.skippedaccounts.length > 0) logger(`Skipped Accounts: ${updater.skippedaccounts.length}/${Object.keys(logininfo).length}`, true) + if (updater.skippedaccounts.length > 0) logger(`Skipped Accounts: ${updater.skippedaccounts.length}/${Object.keys(logininfo).length}\n`, true) + if (extdata.firststart) logger(`If you like my work please consider giving my repository a star! I would really appreciate it!\nhttps://github.com/HerrEurobeat/steam-comment-service-bot`, true) //Check if ownerids are correct: logger(`Checking for invalid ownerids...`, false, true) @@ -424,29 +412,37 @@ var readyinterval = setInterval(() => { //log startup to console communityobject[e].joinGroup(`${botsgroupid}`) logger(`[Bot ${e}] Joined/Requested to join steam group that has been set in the config (botsgroup).`) } }) } else { - https.get(`${config.botsgroup}/memberslistxml/?xml=1`, function(botsgroupres) { //get group64id from code to simplify config - botsgroupres.on('data', function (chunk) { - botsgroupoutput += chunk }); - - botsgroupres.on('end', () => { - if (!String(botsgroupoutput).includes("")) { //Check if botsgroupoutput is steam group xml data before parsing it - logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your bots group (botsgroup in config) doesn't seem to be valid!\n Error: " + config.botsgroup + " contains no xml or groupID64 data", true); - botsgroupid = "" - } else { - new xml2js.Parser().parseString(botsgroupoutput, function(botsgrouperr, botsgroupResult) { - if (botsgrouperr) return logger("error parsing botsgroup xml: " + botsgrouperr, true) - - botsgroupid = botsgroupResult.memberList.groupID64 - - Object.keys(botobject).forEach((e) => { - if (!Object.keys(botobject[e].myGroups).includes(String(botsgroupid))) { - communityobject[e].joinGroup(`${botsgroupid}`) - logger(`[Bot ${e}] Joined/Requested to join steam group that has been set in the config (botsgroup).`) } - }) }) } }) - }).on("error", function(err) { - logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get botsgroup 64id. Either Steam is down or your internet isn't working.\n Error: " + err, true) - botsgroupid = "" - }) } } + if (cachefile.botsgroup == config.botsgroup) { + + } else { + https.get(`${config.botsgroup}/memberslistxml/?xml=1`, function(botsgroupres) { //get group64id from code to simplify config + botsgroupres.on('data', function (chunk) { + botsgroupoutput += chunk }); + + botsgroupres.on('end', () => { + if (!String(botsgroupoutput).includes("")) { //Check if botsgroupoutput is steam group xml data before parsing it + logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your bots group (botsgroup in config) doesn't seem to be valid!\n Error: " + config.botsgroup + " contains no xml or groupID64 data", true); + botsgroupid = "" + } else { + new xml2js.Parser().parseString(botsgroupoutput, function(botsgrouperr, botsgroupResult) { + if (botsgrouperr) return logger("error parsing botsgroup xml: " + botsgrouperr, true) + + botsgroupid = botsgroupResult.memberList.groupID64 + + cachefile.botsgroup = config.botsgroup + cachefile.botsgroupid = String(botsgroupResult.memberList.groupID64) + fs.writeFile("./src/cache.json", JSON.stringify(cachefile, null, 4), err => { + if (err) logger(`[${thisbot}] error writing configgroup64id to cache.json: ${err}`) }) + + Object.keys(botobject).forEach((e) => { + if (!Object.keys(botobject[e].myGroups).includes(String(botsgroupid))) { + communityobject[e].joinGroup(`${botsgroupid}`) + logger(`[Bot ${e}] Joined/Requested to join steam group that has been set in the config (botsgroup).`) } + }) }) } }) + }).on("error", function(err) { + logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't get botsgroup 64id. Either Steam is down or your internet isn't working.\n Error: " + err, true) + botsgroupid = "" + }) }} } } catch (err) { if (err) return logger("error getting botsgroup xml info: " + err, true) } @@ -504,14 +500,142 @@ var readyinterval = setInterval(() => { //log startup to console fs.writeFile("./src/data.json", JSON.stringify(extdata, null, 4), err => { //write changes if (err) logger("change extdata to false error: " + err) - //Startup is done, clean up - delete readyafterlogs; //delete var as the logs got logged by now - delete skippednow; logger('Startup complete!', false, true) }) setTimeout(() => { + //Startup is done, clean up + delete readyafterlogs; //delete var as the logs got logged by now + delete skippednow; logger(` `, true, true) //clear out last remove message }, 5000); } }, 500); -//Code by: https://github.com/HerrEurobeat/ \ No newline at end of file +//Code by: https://github.com/HerrEurobeat/ + +hellothereascii = +` _ _ _ _ _ _ +| | | | | | | | | | | +| |_| | ___| | | ___ | |_| |__ ___ _ __ ___ +| _ |/ _ | | |/ _ \\ | __| '_ \\ / _ | '__/ _ \\ +| | | | __| | | (_) | | |_| | | | __| | | __/ +\\_| |_/\\___|_|_|\\___/ \\__|_| |_|\\___|_| \\___| + +General Kenobi ` + +binaryascii = "01000011 01101111 01101101 01101101 01100101 01101110 01110100 01000010 01101111 01110100" + +ascii = ascii = [` + ______ ______ __ __ __ __ ______ __ __ ______ ______ ______ ______ +/\\ ___\\\ /\\ __ \\ /\\ "-./ \\ /\\ "-./ \\ /\\ ___\\ /\\ "-.\\ \\ /\\\__ _\\ /\\ == \\ /\\ __ \\ /\\\__ _\\ +\\ \\ \\____ \\ \\ \\/\\ \\ \\ \\ \\-./\\ \\ \\ \\ \\-./\\ \\ \\ \\ __\\ \\ \\ \\-. \\ \\/_/\\ \\/ \\ \\ __< \\ \\ \\/\\ \\ \\/_/\\ \\/ + \\ \\_____\\\ \\ \\_____\\ \\ \\_\\ \\ \\_\\ \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\ \\_\\\\"\\_\\ \\ \\_\\ \\ \\_____\\ \\ \\_____\\ \\ \\_\\ + \\\/_____/ \\/_____/ \\/_/ \\/_/ \\/_/ \\/_/ \\/_____/ \\/_/ \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ `, +` +_________ __ __________ __ +\\_ ___ \\ ____ _____ _____ ____ _____/ |_ \\______ \\ _____/ |_ +/ \\ \\/ / _ \\ / \\ / \\_/ __ \\ / \\ __\\ | | _// _ \\ __\\ +\\ \\___( <_> ) Y Y \\ Y Y \\ ___/| | \\ | | | ( <_> ) | + \\______ /\\\____/|__|_| /__|_| /\\\___ >___| /__| |______ /\\\____/|__| + \\/ \\/ \\/ \\/ \\/ \\/ `, +` + ___ _____ __ __ __ __ ____ _ _ ____ ____ _____ ____ + / __)( _ )( \\/ )( \\/ )( ___)( \\( )(_ _) ( _ \\( _ )(_ _) +( (__ )(_)( ) ( ) ( )__) ) ( )( ) _ < )(_)( )( + \\___)(_____)(_/\\\/\\\_)(_/\\\/\\\_)(____)(_)\\_) (__) (____/(_____) (__) `, +` + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + /\\ \\ /\\ \\ /\\\__\\ /\\\__\\ /\\ \\ /\\\__\\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ + /::\\ \\ /::\\ \\ /::| | /::| | /::\\ \\ /::| | \\:\\\ \\ /::\\ \\ /::\\ \\ \\:\\\ \\ + /:/\\\:\\\ \\ /:/\\\:\\\ \\ /:|:| | /:|:| | /:/\\\:\\\ \\ /:|:| | \\:\\\ \\ /:/\\\:\\\ \\ /:/\\\:\\\ \\ \\:\\\ \\ + /:/ \\:\\\ \\ /:/ \\:\\\ \\ /:/|:|__|__ /:/|:|__|__ /::\\~\\:\\\ \\ /:/|:| |__ /::\\ \\ /::\\~\\:\\\__\\ /:/ \\:\\\ \\ /::\\ \\ +/:/__/ \\:\\\__\\ /:/__/ \\:\\\__\\ /:/ |::::\\\__\\ /:/ |::::\\\__\\ /:/\\\:\\\ \\:\\\__\\ /:/ |:| /\\\__\\ /:/\\\:\\\__\\ /:/\\\:\\\ \\:|__| /:/__/ \\:\\\__\\ /:/\\\:\\\__\\ +\\:\\\ \\ \\/__/ \\:\\\ \\ /:/ / \\/__/~~/:/ / \\/__/~~/:/ / \\:\\\~\\:\\\ \\/__/ \\/__|:|/:/ / /:/ \\/__/ \\:\\\~\\:\\\/:/ / \\:\\\ \\ /:/ / /:/ \\/__/ + \\:\\\ \\ \\:\\\ /:/ / /:/ / /:/ / \\:\\\ \\:\\\__\\ |:/:/ / /:/ / \\:\\\ \\::/ / \\:\\\ /:/ / /:/ / + \\:\\\ \\ \\:\\\/:/ / /:/ / /:/ / \\:\\\ \\/__/ |::/ / \\/__/ \\:\\\/:/ / \\:\\\/:/ / \\/__/ + \\:\\\__\\ \\::/ / /:/ / /:/ / \\:\\\__\\ /:/ / \\::/__/ \\::/ / + \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ \\/__/ ~~ \\/__/ `, +` + ______ __ ____ __ + / ____/___ ____ ___ ____ ___ ___ ____ / /_ / __ )____ / /_ + / / / __ \\/ __ __ \\/ __ __ \\/ _ \\/ __ \\/ __/ / __ / __ \\/ __/ +/ /___/ /_/ / / / / / / / / / / / __/ / / / /_ / /_/ / /_/ / /_ +\\____/\\\____/_/ /_/ /_/_/ /_/ /_/\\\___/_/ /_/\\\__/ /_____/\\\____/\\\__/ `, +` +▄████▄ ▒█████ ███▄ ▄███▓ ███▄ ▄███▓▓█████ ███▄ █ ▄▄▄█████▓ ▄▄▄▄ ▒█████ ▄▄▄█████▓ +▒██▀ ▀█ ▒██▒ ██▒▓██▒▀█▀ ██▒▓██▒▀█▀ ██▒▓█ ▀ ██ ▀█ █ ▓ ██▒ ▓▒ ▓█████▄ ▒██▒ ██▒▓ ██▒ ▓▒ +▒▓█ ▄ ▒██░ ██▒▓██ ▓██░▓██ ▓██░▒███ ▓██ ▀█ ██▒▒ ▓██░ ▒░ ▒██▒ ▄██▒██░ ██▒▒ ▓██░ ▒░ +▒▓▓▄ ▄██▒▒██ ██░▒██ ▒██ ▒██ ▒██ ▒▓█ ▄ ▓██▒ ▐▌██▒░ ▓██▓ ░ ▒██░█▀ ▒██ ██░░ ▓██▓ ░ +▒ ▓███▀ ░░ ████▓▒░▒██▒ ░██▒▒██▒ ░██▒░▒████▒▒██░ ▓██░ ▒██▒ ░ ░▓█ ▀█▓░ ████▓▒░ ▒██▒ ░ +░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ░ ░░ ▒░ ░ ░░░ ▒░ ░░ ▒░ ▒ ▒ ▒ ░░ ░▒▓███▀▒░ ▒░▒░▒░ ▒ ░░ + ░ ▒ ░ ▒ ▒░ ░ ░ ░░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ ░ ▒░▒ ░ ░ ▒ ▒░ ░ +░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ +░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ +░ ░ `, + +` ██████╗ ██████╗ ███╗ ███╗███╗ ███╗███████╗███╗ ██╗████████╗ ██████╗ ██████╗ ████████╗ + ██╔════╝██╔═══██╗████╗ ████║████╗ ████║██╔════╝████╗ ██║╚══██╔══╝ ██╔══██╗██╔═══██╗╚══██╔══╝ + ██║ ██║ ██║██╔████╔██║██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ██████╔╝██║ ██║ ██║ + ██║ ██║ ██║██║╚██╔╝██║██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ██╔══██╗██║ ██║ ██║ + ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ██████╔╝╚██████╔╝ ██║ + ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ `, + +` ( ) ( ) + )\\ ) ) ( ( /( ( )\\ ( /( + (((_) ( ( ( ))\\ ( )\\()) )((_) ( )\\()) + )\\___ )\\ )\\ ' )\\ ' /((_) )\\ ) (_))/ ((_)_ )\\ (_))/ + ((/ __| ((_) _((_)) _((_)) (_)) _(_/( | |_ | _ ) ((_)| |_ + | (__ / _ \\| ' \\()| ' \\()/ -_)| ' \\))| _| | _ \\/ _ \\| _| + \\___|\\___/|_|_|_| |_|_|_| \\___||_||_| \\__| |___/\\___/ \\__| `, + +` _____ _____ ______ _______ ______ _______ ______ _____ ______ _________________ _____ _____ _________________ + ___|\\ \\ ____|\\ \\ | \\/ \\ | \\/ \\ ___|\\ \\|\\ \\ |\\ \\ / \\ ___|\\ \\ ____|\\ \\ / \\ +/ /\\ \\ / /\\ \\ / /\\ \\ / /\\ \\ | \\ \\\\\\ \\| \\ \\\\______ ______/ | |\\ \\ / /\\ \\\\______ ______/ +| | | | / / \\ \\ / /\\ / /\\ | / /\\ / /\\ || ,_____/|\\| \\ \\ | \\( / / )/ | | | |/ / \\ \\ \\( / / )/ +| | |____|| | | | / /\\ \\_/ / / /| / /\\ \\_/ / / /|| \\--'\\_|/ | \\ | | ' | | ' | | /_ _ /| | | | ' | | ' +| | ____ | | | || | \\|_|/ / / || | \\|_|/ / / || /___/| | \\ | | | | | |\\ \\ | | | | | | +| | | ||\\ \\ / /|| | | | || | | | || \\____|\\ | |\\ \\| | / // | | | ||\\ \\ / /| / // +|\\ ___\\/ /|| \\_____\\/____/ ||\\____\\ |____| /|\\____\\ |____| /|____ ' /| |____||\\_____/| /___// |____|/____/|| \\_____\\/____/ | /___// +| | /____/ | \\ | || | /| | | | | / | | | | | / | /_____/ | | |/ \\| || |\` | | / || \\ | || | / |\` | +\\|___| | / \\|____||____|/ \\|____| |____|/ \\|____| |____|/ |____| | / |____| |___|/ |____| |____|_____|/ \\|____||____|/ |____| + \\( |____|/ \\( )/ \\( )/ \\( )/ \\( |_____|/ \\( )/ \\( \\( )/ \\( )/ \\( + ' )/ ' ' ' ' ' ' ' )/ ' ' ' ' ' ' ' ' + ' ' `, + +` .d8888b. 888 888888b. 888 +d88P Y88b 888 888 "88b 888 +888 888 888 888 .88P 888 +888 .d88b. 88888b.d88b. 88888b.d88b. .d88b. 88888b. 888888 8888888K. .d88b. 888888 +888 d88""88b 888 "888 "88b 888 "888 "88b d8P Y8b 888 "88b 888 888 "Y88b d88""88b 888 +888 888 888 888 888 888 888 888 888 888 88888888 888 888 888 888 888 888 888 888 +Y88b d88P Y88..88P 888 888 888 888 888 888 Y8b. 888 888 Y88b. 888 d88P Y88..88P Y88b. + "Y8888P" "Y88P" 888 888 888 888 888 888 "Y8888 888 888 "Y888 8888888P" "Y88P" "Y888 `, + +` /$$$$$$ /$$ /$$$$$$$ /$$ + /$$__ $$ | $$ | $$__ $$ | $$ + | $$ \\__/ /$$$$$$ /$$$$$$/$$$$ /$$$$$$/$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ | $$ \\ $$ /$$$$$$ /$$$$$$ + | $$ /$$__ $$| $$_ $$_ $$| $$_ $$_ $$ /$$__ $$| $$__ $$|_ $$_/ | $$$$$$$ /$$__ $$|_ $$_/ + | $$ | $$ \\ $$| $$ \\ $$ \\ $$| $$ \\ $$ \\ $$| $$$$$$$$| $$ \\ $$ | $$ | $$__ $$| $$ \\ $$ | $$ + | $$ $$| $$ | $$| $$ | $$ | $$| $$ | $$ | $$| $$_____/| $$ | $$ | $$ /$$ | $$ \\ $$| $$ | $$ | $$ /$$ + | $$$$$$/| $$$$$$/| $$ | $$ | $$| $$ | $$ | $$| $$$$$$$| $$ | $$ | $$$$/ | $$$$$$$/| $$$$$$/ | $$$$/ + \\______/ \\______/ |__/ |__/ |__/|__/ |__/ |__/ \\_______/|__/ |__/ \\___/ |_______/ \\______/ \\___/ `, + + ` :::::::: :::::::: ::: ::: ::: ::: :::::::::: :::: ::: ::::::::::: ::::::::: :::::::: ::::::::::: + :+: :+: :+: :+: :+:+: :+:+: :+:+: :+:+: :+: :+:+: :+: :+: :+: :+: :+: :+: :+: + +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ + +#+ +#+ +:+ +#+ +:+ +#+ +#+ +:+ +#+ +#++:++# +#+ +:+ +#+ +#+ +#++:++#+ +#+ +:+ +#+ + +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ +#+ +#+ +#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# #+# +######## ######## ### ### ### ### ########## ### #### ### ######### ######## ### `, + +` _____ _ ____ _ +/ ____| | | | _ \\ | | +| | ___ _ __ ___ _ __ ___ ___ _ __ | |_ | |_) | ___ | |_ +| | / _ \\| '_ \` _ \\| '_ \` _ \\ / _ \\ '_ \\| __| | _ < / _ \\| __| +| |___| (_) | | | | | | | | | | | __/ | | | |_ | |_) | (_) | |_ +\\_____\\___/|_| |_| |_|_| |_| |_|\\___|_| |_|\\__| |____/ \\___/ \\__|`, + +` _|_|_| _| _|_|_| _| +_| _|_| _|_|_| _|_| _|_|_| _|_| _|_| _|_|_| _|_|_|_| _| _| _|_| _|_|_|_| +_| _| _| _| _| _| _| _| _| _|_|_|_| _| _| _| _|_|_| _| _| _| +_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| + _|_|_| _|_| _| _| _| _| _| _| _|_|_| _| _| _|_| _|_|_| _|_| _|_| `] \ No newline at end of file diff --git a/src/data.json b/src/data.json index 89d4c27d..309f1386 100644 --- a/src/data.json +++ b/src/data.json @@ -1,5 +1,5 @@ { - "version": "2.7.1", + "version": "2.7.2", "branch": "master", "filetostart": "./updater.js", "filetostarturl": "https://raw.githubusercontent.com/HerrEurobeat/steam-comment-service-bot/master/updater.js", @@ -7,7 +7,7 @@ "mestr": "3urobeat", "aboutstr": "This bot was created by 3urobeat.\nGitHub: https://github.com/HerrEurobeat/steam-comment-service-bot \nSteam: https://steamcommunity.com/id/3urobeat \nIf you like my work, any donation would be appreciated! https://paypal.me/3urobeat", "firststart": true, - "whatsnew": "Fixed crash when child bot recieved message. Fixed limited check crash when skipping account. Fixed comment limited & not friend check. Fixed auto skipSteamGuard.", + "whatsnew": "New !addfriend command. Added cache.json file. Fixed group invite crash. Fixed steam guard code issues. Added more ascii arts. Fixed limitedaccs crashes. Added childaccsplaygames in config.", "timesloggedin": 0, "totallogintime": 0 } \ No newline at end of file diff --git a/updater.js b/updater.js index 035e9467..0f1ce3b2 100644 --- a/updater.js +++ b/updater.js @@ -1,11 +1,12 @@ //Code by: https://github.com/HerrEurobeat/ //If you are here, you are wrong. Open config.json and configure everything there! -var fs = require('fs') -var https = require("https") +const fs = require('fs') +const https = require("https") +const readline = require("readline") var config = require("./config.json") var extdata = require('./src/data.json') -var skippedaccounts = [] +var skippedaccounts = [] //array to save which accounts have been skipped to skip them automatically when restarting var botisloggedin = false var activeupdate = false var lastupdatecheckinterval = Date.now() @@ -20,10 +21,10 @@ var logger = (str, nodate, remove) => { //Custom logger var string = `\x1b[96m[${(new Date(Date.now() - (new Date().getTimezoneOffset() * 60000))).toISOString().replace(/T/, ' ').replace(/\..+/, '')}]\x1b[0m ${str}` } if (remove) { - process.stdout.clearLine() - process.stdout.write(`${string}\r`) //probably dirty solution but these spaces clear up previous lines that were longer + readline.clearLine(process.stdout, 0) //0 clears entire line + process.stdout.write(`${string}\r`) } else { - process.stdout.clearLine() + readline.clearLine(process.stdout, 0) console.log(`${string}`) } fs.appendFileSync('./output.txt', string.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/g, '') + '\n', err => { //Credit: https://github.com/Filirom1/stripcolorcodes @@ -35,13 +36,14 @@ var restartdata = (data) => { var checkforupdate = (forceupdate) => { try { /* ------------------ Check for new version ------------------ */ + logger(`Checking for update in ${releasemode} branch...`, false, true) var httpsrequest = https.get(`https://raw.githubusercontent.com/HerrEurobeat/steam-comment-service-bot/${releasemode}/src/data.json`, function(res) { res.setEncoding('utf8'); res.on('data', function(chunk) { var onlineversion = JSON.parse(chunk).version //parse version number from get request module.exports.onlinemestr = JSON.parse(chunk).mestr //get mestr and aboutstr from GitHub to check for modification module.exports.onlineaboutstr = JSON.parse(chunk).aboutstr - if (onlineversion > extdata.version || forceupdate == true || releasemode == "beta-testing" && !onlineversion.includes("BETA") && extdata.version.includes("BETA")) { //version number greater or forceupdate is true? + if (onlineversion > extdata.version || forceupdate == true || releasemode == "beta-testing" && !onlineversion.includes("BETA") && extdata.version.includes("BETA") || releasemode == "beta-testing" && onlineversion.includes("BETA") && !extdata.version.includes("BETA")) { //version number greater or forceupdate is true? logger("", true) logger(`\x1b[32mUpdate available!\x1b[0m Your version: \x1b[31m${extdata.version}\x1b[0m | New version: \x1b[32m${onlineversion}\x1b[0m`, true) logger("", true) @@ -265,10 +267,10 @@ var checkforupdate = (forceupdate) => { }, 5000); })}) }); //restart the bot } catch (err) { logger('get data.json function Error: ' + err, true) }} } else { + logger(`No available update found. (online: ${onlineversion} | local: ${extdata.version})`, false, true) if (botisloggedin == false) require('./src/controller.js'); botisloggedin = true //no update, start bot } - }) }).on("error", function(err) { - logger("\x1b[0m[\x1b[31mNotice\x1b[0m]: Couldn't check the newest version on GitHub. You can ignore this error.\n Error: " + err, true) }) + }) }) lastupdatecheckinterval = Date.now() + 43200000 //12 hours in ms @@ -348,8 +350,7 @@ if (!fs.existsSync('./src')){ //this has to trigger if user was on version <2.6 checkforupdate(true) } } else { - logger("Checking for update...", false, true) - if (releasemode == "beta-testing") logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your updater is running in beta mode. These versions could be more unstable than master versions.\nIf you find an error or bug please report it: https://github.com/HerrEurobeat/steam-comment-service-bot/issues/new/choose\n", true) + if (releasemode == "beta-testing") logger("\x1b[0m[\x1b[31mNotice\x1b[0m] Your updater and bot is running in beta mode. These versions are often unfinished and can be unstable.\n If you would like to switch, open data.json and change 'beta-testing' to 'master'.\n If you find an error or bug please report it: https://github.com/HerrEurobeat/steam-comment-service-bot/issues/new/choose\n", true) checkforupdate() //check will start the bot afterwards }