Ok, I'm so not proficient with Javascript and barely know enough to stumble my way through a Sheet Worker...but despite that, I figured I'd see what I can figure out. Here's what I did (and it doesn't work...): var Backward = Backward || (function() {
'use strict';
state.backwardapi = {doReverse: false};
var version = 0.1,
HandleInput = function(msg) {
var args, text;
if (msg.type !== "api") {
log("Not an API...");
if(msg.type === "general" && state.backwardapi.doReverse === false) {
log("In the if statement: doReverse is false");
sendChat(msg.who,msg.content + " and I appended this...");
return;
}
else {
log("Made it to the else statement: doReverse is true");
msg.content = msg.content.split("").reverse().join("");
//sendChat(msg.who,msg.content);
return;
}
}
args = msg.content.split(" ");
switch(args[0]) {
case '!backward':
if(args.length !== 2 && (args[1] !== 'on' || args[1] !== 'off')) {
sendChat(msg.who,'Too many, too few, or wrong type of input. !backward should have a declaration of "on" or "off".');
break;
}
else {
if(args[1] === "on") { state.backwardapi.doReverse = true; }
else { state.backwardapi.doReverse = false; }
(state.backwardapi.doReverse === true ? log("Backward enabled...") : log("Backward disabled..."));
//sendChat(msg.who,text);
break;
}
}
},
RegisterEventHandlers = function() {
on('chat:message', HandleInput);
};
return {
RegisterEventHandlers: RegisterEventHandlers
};
}());
on("ready",function() {
'use strict';
Backward.RegisterEventHandlers();
}); It doesn't intercept the message and prevent it from playing, which is why I think it ends up in a loop...it displays the message, the script sees that, takes it and puts it out in chat again, which then sees it, grabs it, puts it out in the chat again, ad infinitum...so, my approach for this is a failure (so far). What I have learned: 1. I know how to use the state to store whether I backward is enabled or disabled. 2. I have no idea what I'm doing...LOL 3. I know there are different types of messages, and if I alter just type === "general" that should be sufficient. Now, I just need to figure out how to get it not get stuck in that inadvertent loop. Any pointers/idea?