Hello everyone,
I’m experiencing an issue integrating my Google Apps Script API with Nightbot. The script is designed to manage a queue for playing with viewers across multiple Twitch channels. It functions well when tested directly in the browser, but when I try to use the !list command in Nightbot, I encounter this error:
[Response must be less than 400 characters]
Script Details:
The script handles various actions, including join, leave, list, tipupdate, and next, to efficiently manage the viewer queue across multiple channels. Here’s the full code for reference: https://pastebin.com/2sDTwhWM
Nightbot Commands:
Below are the Nightbot commands I’m using, with the API URL replaced by YOUR_CODE:
Join Command:
!join $(urlfetch https://script.google.com/macros/s/YOUR_CODE/exec?action=join&user=$(user)&channel=$(channel)&userlevel=$(userlevel)&tip=0)
Leave Command:
!leave $(urlfetch https://script.google.com/macros/s/YOUR_CODE/exec?action=leave&user=$(user)&channel=$(channel))
List Command:
!list $(urlfetch https://script.google.com/macros/s/YOUR_CODE/exec?action=list)
Tip Update Command (Moderators Only):
!tipupdate $(urlfetch https://script.google.com/macros/s/YOUR_CODE/exec?action=tipupdate&user=$(user)&tip=$(query))
Next Command (Moderators Only):
!next $(urlfetch https://script.google.com/macros/s/YOUR_CODE/exec?action=next&userlevel=$(userlevel))
Problem:
When accessing the API URL directly in a browser, the script returns plain text responses as expected, such as:
The queue is currently empty.
However, when I use the !list command in Nightbot, I receive the error “[Response must be less than 400 characters]” even though the response appears to be well within the character limit.
What I’ve Tried:
Ensured the API response is plain text using ContentService.createTextOutput().
Added a truncation function to limit the response length if it exceeds 400 characters.
Tested both the /dev and /exec URLs of the Google Apps Script.
Verified that the API works correctly in the browser without any errors.
Additional Context:
The purpose of the script is to manage a viewer queue across multiple channels for streamers who play games with their viewers. It prioritizes users based on tip amounts and subscriber status, ensuring a fair and efficient queue system.
Request for Help:
I’m seeking assistance on how to resolve this issue. Could it be related to hidden metadata or additional headers being included when Nightbot fetches the response? Is there a way to enforce a simpler response that Nightbot can handle without exceeding the character limit?
Any suggestions or guidance would be greatly appreciated. Thank you in advance!