!r added to tokebot

This commit is contained in:
rainbow napkin 2025-04-27 10:26:35 -04:00
parent 6639cee8ca
commit 7d3c31f0aa

View file

@ -56,6 +56,21 @@ module.exports = class tokebot{
if(this.tokeCommands.indexOf(commandObj.argumentArray[0].toLowerCase()) != -1){ 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 //Seems lame to set a bool in an if statement but this would've made a really ugly turinary
var foundToke = true; 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{ }else{
//Find the users active channel //Find the users active channel
const activeChan = this.server.activeChannels.get(commandObj.socket.chan); 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) //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{ }else{
//No toke found, send it down the line, because shaming the user is funny //No toke found, send it down the line, because shaming the user is funny
return true; return true;