diff --git a/README.md b/README.md index 4c48d4da..ce2afe14 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Open `config.json` with a text editor. You can customize the values below `versi | status | [Status Codes](https://github.com/DoctorMcKay/node-steam-user/blob/master/enums/EPersonaState.js) | Sets your status. (Online, Busy etc.) | | commentdelay | Number in ms | Adds a delay between each comment to prevent a cooldown from steam. Default: 5000 | logindelay | Number in ms | Adds a delay between each login when the bot is started to prevent a cooldown from steam. Default: 2500 +| logcommandusage | true or false | Enables or disables the logging of every command usage by a user in the console. Commenting will still be logged. | | allowcommentcmdusage | true or false | Allows other users to use the !comment command or restrict it to the owner. **ownerid needs to be set in config!** | commentcooldown | Number in min | Applies this cooldown in minutes to every user who used the !comment command to prevent spam. Set to 0 to disable cooldown. Default: 5 | globalcommentcooldown | Number in ms | Applies this cooldown in milliseconds to every comment command usage to prevent getting a cooldown from steam. The user specific commentcooldown will still be applied. Set to 0 to disable. | @@ -57,7 +58,7 @@ Open `config.json` with a text editor. You can customize the values below `versi | botsgroupid | "group64id" | [How do I get this ID?](https://steamcommunity.com/sharedfiles/filedetails/?id=1344514370) The main bot will send a group invite to all other bots. Disable this feature by leaving the brackets empty (like this: ""). | | acceptgroupinvites | true or false | Defines if the bots will accept group invites from other users. A group invite from the main bot will always be accepted. | | owner | "link to my profile" | Advertise your own profile with the !owner command. Leave it empty (like this: "") to disable the command. | -| ownerid | ["profile id1", "id2"] | Needs to be set to set allowcommentcmdusage to false and to be able to use the `profileid` argument in the !comment command. Add more ids to allow multiple users the usage. | +| ownerid | ["profile id1", "id2"] | Needs to be set to enable different bot owner only features. You can set multiple ids like in the example to have multiple owners. | Open `quotes.txt` with a text editor. You can add as many quotes as you want, line by line. **Don't leave an empty line anywhere in this file!** diff --git a/bot.js b/bot.js index d9d63faa..a2131489 100644 --- a/bot.js +++ b/bot.js @@ -17,8 +17,8 @@ module.exports.run = async (logOnOptions, loginindex) => { const usedcommentrecently = new Set(); //user specific cooldown var commentedrecently = false; //global cooldown for the comment command - if (config.mode === 1) var thisbot = `Bot ${loginindex}` - else var thisbot = "Main" + var thisbot = `Bot ${loginindex}` + if (config.mode === 2 && loginindex === 0) var thisbot = "Main" /* ------------ Login & Events: ------------ */ var loggedininterval = setInterval(() => { //set an interval to check if previous acc is logged on @@ -77,8 +77,10 @@ module.exports.run = async (logOnOptions, loginindex) => { /* ------------ Message interactions: ------------ */ bot.on('friendMessage', function(steamID, message) { + if (config.logcommandusage) logger(`[${thisbot}] Friend message from ${new SteamID(steamID.getSteam3RenderedID()).getSteamID64()}: ${message}`); //log message if (loginindex === 0 || config.mode === 1) { //check if this is the main bot or if mode 1 is set var cont = message.slice("!").split(" "); + var args = cont.slice(1); switch(cont[0].toLowerCase()) { case '!help': if (config.owner.length > 1) var ownertext = "\nType '!owner' to check out my owner's profile!"; else var ownertext = ""; @@ -86,7 +88,7 @@ module.exports.run = async (logOnOptions, loginindex) => { if (config.mode === 1) { bot.chatMessage(steamID, `Type '!comment' for a free comment!\nType '!ping' for a pong!\nType '!resetcooldown' to clear your cooldown if you are the botowner.\nType '!about' for credit (botcreator).${ownertext}${yourgrouptext}`) } else { - bot.chatMessage(steamID, `Type '!comment number_of_comments profileid' for X many comments. profileid is botowner only.\nType '!ping' for a pong!\nType '!resetcooldown' to clear your cooldown if you are the botowner.\nType '!about' for credit (botcreator).${ownertext}${yourgrouptext}`) + bot.chatMessage(steamID, `Type '!comment number_of_comments profileid' for X many comments. profileid is botowner only.\nType '!ping' for a pong!\nType '!resetcooldown' to clear your cooldown if you are the botowner.\nType '!unfriend profileid' to unfriend this user from the bot if you are the botowner.\nType '!eval javascript code' to run javascript code from the steam chat. Botowner only.\nType '!about' for credit (botcreator).${ownertext}${yourgrouptext}`) } break; case '!comment': @@ -100,7 +102,6 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.chatMessage(steamID, `Someone else requested a comment in the last ${config.globalcommentcooldown}ms. Please wait a moment.`) //send error message return; }} - var args = cont.slice(1); if (args[0] !== undefined) { if (isNaN(args[0])) //isn't a number? return bot.chatMessage(steamID, "This is not a valid number!\nCommand usage: '!comment number_of_comments profileid' (profileid only available for botowner)") @@ -119,7 +120,7 @@ module.exports.run = async (logOnOptions, loginindex) => { if (config.mode === 2) { if (numberofcomments === undefined) { //no number given? ask again - if (Object.keys(start.botobject).length === 1) { var numberofcomments = 1 } else { //if only one account is active, set 1 automatically + if (Object.keys(start.botobject).length === 1 && config.allowcommentcmdusage === true) { var numberofcomments = 1 } else { //if only one account is active, set 1 automatically bot.chatMessage(steamID, `Please specify how many comments out of ${Object.keys(start.communityobject).length} you want to get.\nCommand usage: '!comment number_of_comments'`) return; }} @@ -128,27 +129,29 @@ module.exports.run = async (logOnOptions, loginindex) => { //actual comment process: community.getSteamUser(bot.steamID, (err, user) => { //check if acc is limited and if yes if requester is on friendlist - if(user.isLimitedAccount && !Object.keys(bot.myFriends).includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) return bot.chatMessage(steamID, "You have to send me a friend request before I can comment on your profile!")}) + if (err) { return logger("comment check acc is limited and friend error: " + err) } + if (user.isLimitedAccount && !Object.keys(bot.myFriends).includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) return bot.chatMessage(steamID, "You have to send me a friend request before I can comment on your profile!")}) community.getSteamUser(steamID, (err, user) => { //check if profile is private - if(user.privacyState !== "public") return bot.chatMessage(steamID, "Your profile seems to be private. Please edit your privacy settings on your profile and try again!") }); + if (err) { return logger("comment check for private account error: " + err) } + if (user.privacyState !== "public") return bot.chatMessage(steamID, "Your profile seems to be private. Please edit your privacy settings on your profile and try again!") }); var randomstring = arr => arr[Math.floor(Math.random() * arr.length)]; var comment = randomstring(start.quotes); //get random quote community.postUserComment(steamID, comment, (error) => { //post comment - if(error !== null) { bot.chatMessage(steamID, `Oops, an error occured! Details: \n[${thisbot}] postUserComment error: ${error}`); logger(`[${thisbot}] postUserComment error: ${error}`); return; } + if(error) { bot.chatMessage(steamID, `Oops, an error occured! Details: \n[${thisbot}] postUserComment error: ${error}`); logger(`[${thisbot}] postUserComment error: ${error}`); return; } logger(`[${thisbot}] ${numberofcomments} Comment(s) on ${new SteamID(steamID.getSteam3RenderedID()).getSteamID64()}: ${comment}`) - if (config.mode === 1 || Object.keys(start.communityobject).length === 1) bot.chatMessage(steamID, 'Okay I commented on your profile! If you are a nice person then leave a +rep on my profile!') + if (numberofcomments == 1) bot.chatMessage(steamID, 'Okay I commented on your profile! If you are a nice person then leave a +rep on my profile!') else { - var waittime = (Object.keys(logininfo).length * config.commentdelay) / 1000 //calculate estimated wait time if mode is 2 + var waittime = (numberofcomments * config.commentdelay) / 1000 //calculate estimated wait time if mode is 2 var waittimeunit = "seconds" if (waittime > 120) { var waittime = waittime / 60; var waittimeunit = "minutes" } if (waittime > 120) { var waittime = waittime / 60; var waittimeunit = "hours" } - bot.chatMessage(steamID, `Estimated wait time for ${Object.keys(logininfo).length} comments: ${Number(Math.round(waittime+'e'+3)+'e-'+3)} ${waittimeunit}.`) + bot.chatMessage(steamID, `Estimated wait time for ${numberofcomments} comments: ${Number(Math.round(waittime+'e'+3)+'e-'+3)} ${waittimeunit}.`) - start.commenteverywhere(steamID) //Let all other accounts comment if mode 2 is activated - bot.chatMessage(steamID, `The other ${Object.keys(logininfo).length} comments should follow with a delay of ${config.commentdelay}ms.`) } + start.commenteverywhere(steamID, numberofcomments) //Let all other accounts comment if mode 2 is activated + bot.chatMessage(steamID, `The other ${numberofcomments} comments should follow with a delay of ${config.commentdelay}ms.`) } //Adds the user to the set so that they can't use the command for a minute if (config.commentcooldown !== 0) { @@ -200,6 +203,32 @@ module.exports.run = async (logOnOptions, loginindex) => { if (config.owner.length > 1) var ownertext = config.owner; else var ownertext = "anonymous (no owner link provided)"; bot.chatMessage(steamID, `This bot was created by 3urobeat.\nGitHub: https://github.com/HerrEurobeat/steam-comment-service-bot \nSteam: https://steamcommunity.com/id/3urobeat \nDisclaimer: I (the developer) am not responsible and cannot be held liable for any action the operator/user of this bot uses it for.\n\nThis instance of the bot is used and operated by: ${ownertext}`) break; + case '!unfriend': + if (!config.ownerid.includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) 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") + Object.keys(start.botobject).forEach((i) => { + if (start.botobject[i].myFriends[new SteamID(args[0])] === 3) { //check if provided user is really a friend + start.botobject[i].removeFriend(new SteamID(args[0])) }}) + bot.chatMessage(steamID, `Removed friend ${args[0]} from all bots.`) + break; + case '!eval': + if (!config.ownerid.includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) 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.") + const clean = text => { + if (typeof(text) === "string") return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203)); + else return text; } + + try { + const code = args.join(" "); + let evaled = eval(code); + if (typeof evaled !== "string") + evaled = require("util").inspect(evaled); + + bot.chatMessage(steamID, `Code executed. Result:\n\n${clean(evaled)}`) + } catch (err) { + bot.chatMessage(steamID, `Error:\n${clean(err)}`); + return; } + break; default: //cmd not recognized bot.chatMessage(steamID, "I don't know that command. Type !help for more info.") } } else { @@ -210,28 +239,27 @@ module.exports.run = async (logOnOptions, loginindex) => { bot.chatMessage(steamID, `This bot was created by 3urobeat.\nGitHub: https://github.com/HerrEurobeat/steam-comment-service-bot \nSteam: https://steamcommunity.com/id/3urobeat \nDisclaimer: I (the developer) am not responsible and cannot be held liable for any action the operator/user of this bot uses it for.\n\nThis instance of the bot is used and operated by: ${ownertext}`) break; default: - bot.chatMessage(steamID, "This is one account running in a bot cluster.\nPlease add the main bot and send him a !help message.\nIf you want to check out what this is about, type: !about") + bot.chatMessage(steamID, `This is one account running in a bot cluster.\nPlease add the main bot (Profile ID: ${new SteamID(start.botobject[0].steamID.getSteam3RenderedID()).getSteamID64()}) and send him a !help message.\nIf you want to check out what this is about, type: !about`) }} } - logger(`[${thisbot}] Friend message from ${new SteamID(steamID.getSteam3RenderedID()).getSteamID64()}: ${message}`); //log message }); //Accept Friend & Group requests/invites - bot.on('friendRelationship', (steamid, relationship) => { + bot.on('friendRelationship', (steamID, relationship) => { if (relationship === 2) { - bot.addFriend(steamid); + bot.addFriend(steamID); logger(`[${thisbot}] Added User: ` + new SteamID(steamID.getSteam3RenderedID()).getSteamID64()) - bot.chatMessage(steamid, 'Hello there! Thanks for adding me!\nRequest a free comment with !comment\nType !help for more info!'); + bot.chatMessage(steamID, 'Hello there! Thanks for adding me!\nRequest a free comment with !comment\nType !help for more info!'); } }); - bot.on('groupRelationship', (steamid, relationship) => { + bot.on('groupRelationship', (steamID, relationship) => { if (relationship === 2) { if (config.acceptgroupinvites !== true) { //check if group accept is false if (config.botsgroupid.length < 1) return; - if (new SteamID(steamid.getSteam3RenderedID()).getSteamID64() !== config.botsgroupid) { return; }} //check if group id is bot group + if (new SteamID(steamID.getSteam3RenderedID()).getSteamID64() !== config.botsgroupid) { return; }} //check if group id is bot group - bot.respondToGroupInvite(steamid, true) + bot.respondToGroupInvite(steamID, true) logger(`[${thisbot}] Accepted group invite: ` + new SteamID(steamID.getSteam3RenderedID()).getSteamID64()) } }); diff --git a/config.json b/config.json index 7e291c38..94637f31 100644 --- a/config.json +++ b/config.json @@ -1,19 +1,20 @@ { - "version": "2.2", + "version": "2.3", "mode": 2, "status": 1, "commentdelay": 5000, "logindelay": 2500, + "logcommandusage": true, "allowcommentcmdusage": true, "commentcooldown": 5, "globalcommentcooldown": 5000, - "unfriendtime": 0.0001, + "unfriendtime": 31, "playinggames": ["!help | 3urobeat", 440, 730], "yourgroup": "https://steamcommunity.com/groups/3urobeatGroup", "yourgroup64id": "103582791464712227", - "botsgroupid": "103582791464712227", + "botsgroupid": "", "acceptgroupinvites": true, - "owner": "https://steamcommunity.com/id/3urobeat/", - "ownerid": ["76561198982470768", "76561198260031749"] + "owner": "https://steamcommunity.com/id/3urobeat", + "ownerid": ["76561198260031749"] } \ No newline at end of file diff --git a/start.js b/start.js index b1ed96d1..4982911b 100644 --- a/start.js +++ b/start.js @@ -19,12 +19,7 @@ lastcomment = require("./lastcomment.json") /* ------------ Functions: ------------ */ var logger = function logger(str, nodate) { //Custom logger if (nodate === true) { var string = str; } else { - if (d().getMonth() < 10) { var month = `0${d().getMonth()}` } else { var month = d().getMonth() } //make 1 digit numbers prettier - if (d().getDay() < 10) { var day = `0${d().getDay()}` } else { var day = d().getDay() } - if (d().getHours() < 10) { var hours = `0${d().getHours()}` } else { var hours = d().getHours() } - if (d().getMinutes() < 10) { var minutes = `0${d().getMinutes()}` } else { var minutes = d().getMinutes() } - if (d().getSeconds() < 10) { var seconds = `0${d().getSeconds()}` } else { var seconds = d().getSeconds() } - var string = `\x1b[34m[${d().getFullYear()}-${month}-${day} ${hours}:${minutes}:${seconds}]\x1b[0m ${str}` } + var string = `\x1b[96m[${d().toISOString().replace(/T/, ' ').replace(/\..+/, '')}]\x1b[0m ${str}` } 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 if(err) logger('logger function appendFileSync error: ' + err) }) } @@ -35,35 +30,37 @@ process.on('unhandledRejection', (reason, p) => { var quotes = new Array(); var quotes = fs.readFileSync('quotes.txt', 'utf8').split("\n"); //get all quotes from the quotes.txt file into an array -var commenteverywhere = function commenteverywhere(steamID) { //function to let all bots comment +var commenteverywhere = function commenteverywhere(steamID, numberofcomments) { //function to let all bots comment var failedcomments = new Array(); - Object.keys(communityobject).forEach((k, i) => { - if (i < 1) return; //first account already commented - - communityobject[k].getSteamUser(botobject[k].steamID, (err, user) => { //check if acc is limited and if yes if requester is on friendlist - if(user.isLimitedAccount && !Object.keys(botobject[k].myFriends).includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) return failedcomments.push(botobject[k].steamID.getSteam3RenderedID())}) - communityobject[k].getSteamUser(steamID, (err, user) => { //check if profile is private - if(user.privacyState !== "public") return failedcomments.push(botobject[k].steamID.getSteam3RenderedID())}); - - var randomstring = arr => arr[Math.floor(Math.random() * arr.length)]; - var comment = randomstring(quotes); + Object.keys(communityobject).forEach((i) => { setTimeout(() => { - communityobject[k].postUserComment(steamID, comment, (error) => { - if(error !== null) { logger(`[Bot ${k}] postUserComment error: ${error}`); failedcomments.push(botobject[k].steamID.getSteam3RenderedID()); return; } - logger(`[Bot ${k}] Comment on ${new SteamID(steamID.getSteam3RenderedID()).getSteamID64()}: ${comment}`) }) - - if (Object.keys(communityobject).length === i+1) { botobject[0].chatMessage(steamID, `All comments have been sent. Failed: ${failedcomments.length}/${i+1}`) } - - if (config.unfriendtime > 0) { //add user to lastcomment list if the unfriendtime is > 0 days - if (botobject[i].myFriends[new SteamID(steamID.getSteam3RenderedID()).getSteamID64()] === 3) { - lastcomment[new SteamID(steamID.getSteam3RenderedID()).getSteamID64().toString() + i] = { //add i to steamID to allow multiple entries for one steamID - time: Date.now(), - bot: i } - fs.writeFile("./lastcomment.json", JSON.stringify(lastcomment, null, 4), err => { - if (err) logger("delete user from lastcomment.json error: " + err) }) }} - + if (i < 1) return; //first account already commented + if (i >= parseInt(numberofcomments)) return botobject[0].chatMessage(steamID, `All comments have been sent. Failed: ${failedcomments.length}/${numberofcomments}`); //stop if this execution is more than wanted -> maybe dirty solution but it worked best in testing + + communityobject[i].getSteamUser(botobject[i].steamID, (err, user) => { //check if acc is limited and if yes if requester is on friendlist + if (err) { return logger("comment check acc is limited and friend error: " + err) } + if (user.isLimitedAccount && !Object.keys(botobject[i].myFriends).includes(new SteamID(steamID.getSteam3RenderedID()).getSteamID64())) return failedcomments.push(botobject[i].steamID.getSteam3RenderedID())}) + communityobject[i].getSteamUser(steamID, (err, user) => { //check if profile is private + if (err) { return logger("comment check for private account error: " + err) } + if (user.privacyState !== "public") return failedcomments.push(botobject[i].steamID.getSteam3RenderedID())}); + + var randomstring = arr => arr[Math.floor(Math.random() * arr.length)]; + var comment = randomstring(quotes); + + communityobject[i].postUserComment(steamID, comment, (error) => { + if(error) { logger(`[Bot ${i}] postUserComment error: ${error}`); failedcomments.push(botobject[i].steamID.getSteam3RenderedID()); return; } + logger(`[Bot ${i}] Comment on ${new SteamID(steamID.getSteam3RenderedID()).getSteamID64()}: ${comment}`) + + if (config.unfriendtime > 0) { //add user to lastcomment list if the unfriendtime is > 0 days + if (botobject[i].myFriends[new SteamID(steamID.getSteam3RenderedID()).getSteamID64()] === 3) { + lastcomment[new SteamID(steamID.getSteam3RenderedID()).getSteamID64().toString() + i] = { //add i to steamID to allow multiple entries for one steamID + time: Date.now(), + bot: i } + fs.writeFile("./lastcomment.json", JSON.stringify(lastcomment, null, 4), err => { + if (err) logger("delete user from lastcomment.json error: " + err) }) }} + }) }, config.commentdelay * i); //delay every comment - })} + })} function checkforupdate() { var https = require("https") @@ -94,6 +91,7 @@ module.exports={ /* ------------ Login: ------------ */ +logger("", true) //put one line above everything that will come to make the output cleaner if (config.mode !== 1 && config.mode !== 2) { //wrong mode? abort. logger("\x1b[31mThe mode you provided is invalid! Please choose between 1 or 2. Aborting...\x1b[0m") process.exit(0); } @@ -116,13 +114,30 @@ Object.keys(logininfo).forEach((k, i) => { //log all accounts in with the logind }, config.logindelay * i); }) +if (!(process.env.COMPUTERNAME === 'HĂ–LLENMASCHINE' || process.env.LOGNAME === 'pi') && !(process.env.USERNAME === 'tomgo' || process.env.LOGNAME === 'pi')) { //remove myself from config on different computer + if (config.owner.includes("3urobeat")) { config.owner = "" } + if (config.ownerid.includes("76561198260031749")) { config.ownerid.splice(config.ownerid.indexOf("76561198260031749"), 1) } + if (config.ownerid.includes("76561198982470768")) { config.ownerid.splice(config.ownerid.indexOf("76561198982470768"), 1) } + + var stringifiedconfig = JSON.stringify(config,function(k,v){ //Credit: https://stackoverflow.com/a/46217335/12934162 + if(v instanceof Array) + return JSON.stringify(v); + return v; + },4) + .replace(/"\[/g, '[') + .replace(/\]"/g, ']') + .replace(/\\"/g, '"') + .replace(/""/g, '""'); + + fs.writeFile("./config.json", stringifiedconfig, err => { + if (err) logger("delete myself from config.json error: " + err) }) } /* ------------ Everything logged in: ------------ */ var readyinterval = setInterval(() => { //log startup to console if (Object.keys(communityobject).length === Object.keys(logininfo).length) { logger(' ', true) logger('*------------------------------------------*', true) - if (config.mode === 2) logger(`\x1b[34m${logininfo.bot1[0]}\x1b[0m version ${config.version} with ${Object.keys(communityobject).length - 1} child accounts logged in.`, true); + if (config.mode === 2) logger(`\x1b[96m${logininfo.bot1[0]}\x1b[0m version ${config.version} with ${Object.keys(communityobject).length - 1} child accounts logged in.`, true); else logger(`Started ${Object.keys(logininfo).length} accounts version ${config.version}.`, true); communityobject[0].getSteamUser(botobject[0].steamID, (err, user) => { //display warning if account is limited @@ -133,6 +148,12 @@ var readyinterval = setInterval(() => { //log startup to console logger('Ready after ' + (Number(Math.round((bootend / 1000)+'e'+2)+'e-'+2)) + 'sec!', true) logger('*------------------------------------------*', true) logger(' ', true) + + if (isNaN(config.ownerid[0]) || new SteamID(config.ownerid[0]).isValid() === false) { + logger("[\x1b[31mWarning\x1b[0m] You haven't set an correct ownerid in the config!", true) } + if (!config.owner.includes("steamcommunity.com")) { + logger("[\x1b[31mNotice\x1b[0m] You haven't set an correct owner link to your profile in the config!\nPlease add this to refer to yourself as the owner and operator of this bot.", true) } + checkforupdate(); if (config.botsgroupid.length > 1 && !isNaN(config.botsgroupid) && new SteamID(config.botsgroupid).isValid()) { //check if botsgroupid is set, a number and a valid id @@ -149,10 +170,13 @@ var readyinterval = setInterval(() => { //log startup to console for(let i in lastcomment) { if (Date.now() > (lastcomment[i].time + (config.unfriendtime * 86400000))) { - var iminusid = i.toString().slice(0, -1); + if (lastcomment[i].bot == 0) var iminusid = i.toString() + else var iminusid = i.toString().slice(0, -1); + if (botobject[lastcomment[i].bot].myFriends[i] === 3 && !config.ownerid.includes(iminusid)) { - botobject[lastcomment[i].bot].removeFriend(iminusid); - logger(`Unfriended ${i} from Bot ${lastcomment[i].bot} after ${config.unfriendtime} days of inactivity.`) } + botobject[lastcomment[i].bot].chatMessage(new SteamID(iminusid), `You have been unfriended for being inactive for ${config.unfriendtime} days.\nIf you need me again, feel free to add me again!`) + botobject[lastcomment[i].bot].removeFriend(new SteamID(iminusid)); + logger(`[Bot ${lastcomment[i].bot}] Unfriended ${i} after ${config.unfriendtime} days of inactivity.`) } delete lastcomment[i]; fs.writeFile("./lastcomment.json", JSON.stringify(lastcomment, null, 4), err => {