Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[API] Issue that arises with SendChat's {noarchive: true}

1438039429

Edited 1438152809
When utilizing the new feature for SendChat, I've noticed that on some occasions, it will re-send things that have previously been said in chat by players -- as this also includes API commands, it results in some weird stuff. Restarting sandbox due to script changes... Spinning up new sandbox... "[27/7/2015 18:16:52] 'Sandbox has been loaded.'" "[27/7/2015 18:16:52] 'Systems ready.'" "[27/7/2015 18:16:57] 'New system command by Alan ( Removed ): games,slots,start'" "[27/7/2015 18:17:02] 'New system command by Alan ( Removed ): games,slots,start' Neither of those last two lines were as a result of me typing in the R20 chat -- seem to occur by themselves on("ready", function () { Chatlog("Sandbox has been loaded."); setTimeout(function(){ CheckInstall(); if (myState.ReadyChat) { myState.ReadyChat = false sendChat("System","/w GM "+systemText("The API has been restarted."), null, {noarchive: true}) } // Gives the system its necessary functions. runGameStateFunctions() Chatlog("Systems ready."); },100); setTimeout(function(){ Chatlog("System will now notify GMs of a restart.") myState.ReadyChat = true },300000); }); on("chat:message", function(msg) { if (msg.type == "api") { var isGM = playerIsGM(msg.playerid) var cleanedMsg = msg.content.substr(1,msg.content.length) cleanedMsg = cleanedMsg.split(" -/") var IDPlayer = msg.playerid var PlayerName = getObj("player",msg.playerid).get("_displayname").split(" ")[0] Chatlog("New system command by "+PlayerName+" ("+IDPlayer+"): "+cleanedMsg) ... ... ... } }) Tried commenting out runGameStateFunctions(), but all that happens is it seems to try and call for a function that now doesn't exist. These issues do appear to be resolved resolved, however, upon removing the fourth and third field of this line; sendChat("System","/w GM "+systemText("The API has been restarted."), null, {noarchive: true}) --> sendChat("System","/w GM "+systemText("The API has been restarted.")) EDIT:
I think that this should be fixed now. Can you let us know?
1438960046

Edited 1438960088
I just gave it a shot, made all of the sendChat calls utilize the third and fourth field, and it happened again. I'll cut out the fluff and try and replicate the issue with less code lying around. If I can get any more details regarding the issue, I'll make another post.
1439039389

Edited 1439039432
Did some further testing. While I couldn't peg down the exact conditions, after asking a friend to help me we tried making a bunch of campaigns and utilizing only the following snippet of code in them; on("chat:message", function(msg) {     if (msg.type == "api") {         var Player = getObj("player",msg.playerid)         sendChat("System","<b><span style = 'color:"+Player.get("color")+"'>"+Player.get("_displayname")+"</span></b> sent an API command.", null, {noarchive: true})     } }) By having him occasionally do a combination of sending in an API command and refreshing the game page, (usually alternating back and forth, but sometimes performing one of these two actions twice) it would always eventually (within no more than six or so actions) start to endlessly spam out the message in a loop until the API sandbox was restarted. Hope that helps.