From 7d3c31f0aafe612f3408222c20c904ad9754d867 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Sun, 27 Apr 2025 10:26:35 -0400 Subject: [PATCH] !r added to tokebot --- src/app/channel/tokebot.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/channel/tokebot.js b/src/app/channel/tokebot.js index b04d7fe..a40d559 100644 --- a/src/app/channel/tokebot.js +++ b/src/app/channel/tokebot.js @@ -56,6 +56,21 @@ module.exports = class tokebot{ if(this.tokeCommands.indexOf(commandObj.argumentArray[0].toLowerCase()) != -1){ //Seems lame to set a bool in an if statement but this would've made a really ugly turinary var foundToke = true; + }else if(commandObj.argumentArray[0].toLowerCase() == 'r'){ + //Find the users active channel + const activeChan = this.server.activeChannels.get(commandObj.socket.chan); + + //Combile site-wide and channel tokes into one list + const tokeList = this.tokeCommands.concat(activeChan.tokeCommands); + + //Pick a random number between 0 and one less than the number of tokes + const foundIndex = Math.round(Math.random() * (tokeList.length - 1)); + + //Set override command argument 0 w/ the found toke + commandObj.argumentArray[0] = tokeList[foundIndex]; + + //throw toke flag + var foundToke = true; }else{ //Find the users active channel const activeChan = this.server.activeChannels.get(commandObj.socket.chan); @@ -105,7 +120,7 @@ module.exports = class tokebot{ } //Toke command found, and there isn't any extra text, don't send as chat (re-create fore.st tokebot behaviour) - return (commandObj.command != `!${commandObj.argumentArray[0]}`) + return (commandObj.command != `!${commandObj.argumentArray[0]}` && commandObj.command != '!r'); }else{ //No toke found, send it down the line, because shaming the user is funny return true;