python Twitch-chatbot MONKALOT encounters json error on startup

Question:

Presently I’m trying to make MONKALOT run on a PythonAnywhere account (customized Web Developer). I have basic knowledge of Linux but unfortunately no knowledge of dev’oping python scripts but advanced knowledge of dev’oping Java (hope that helps).

My success log so far:
After upgrading my account to Web Developer level I finally made pip download the (requirements)[https://github.com/NMisko/monkalot/blob/master/requirements.txt] and half the internet (2 of 5GB used). All modules and dependencies seem to be successfully installed.

I configured my own monkalot-channel including OAuth which serves as a staging instance for now. The next challenge was how to get monkalot starting up. Using python3.7 instead of python or any other python3 environment did the trick.

But now I’m stuck. After "completing the training stage" the monkalot-script prematurely ends with the following message:

[22:14] ...chat bot finished training.
Traceback (most recent call last):
  File "monkalot.py", line 72, in <module>
    bots.append(TwitchBot(path))
  File "/home/Chessalot/monkalot/bot/bot.py", line 56, in __init__
    self.users = self.twitch.get_chatters()
  File "/home/Chessalot/monkalot/bot/data_sources/twitch.py", line 25, in get_chatters
    data = requests.get(USERLIST_API.format(self.channel)).json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

By now I figured out that monkalot tries to load the chatters list and expects at least an empty json array as result but actually seems to receive an empty string.

So my question is: What can I do to make the monkalot-script work? Is monkalot’s current version incompatible to the current Twitch-API? Are there any outdated python libraries which may cause the incompatibility? Or is there an unrecognized configuration issue preventing the script from running successfully?

Thank you all in advance. Any ideas provided by you are highly appreciated.

Asked By: actc

||

Answers:

The most likely cause of that is that you are using a free PythonAnywhere account and have not configured monkalot to use the proxy. Check the documentation of monkalot to determine how you can configure it to use a proxy. See https://help.pythonanywhere.com/pages/403ForbiddenError/ for the proxy details.

Answered By: Glenn

Only a quick thought, might not be the problem you are encountering, but it may be due to the project name. E.g.:

From github:

… I believed that the issue was something other than the project name, since I get a different error if I use a project name that doesn’t exist. However, I just tried using ben-heil/saged instead of just saged for the project name and that seems to have fixed it.

EDIT: your HTTP 404 error was caused by this:

  File "monkalot.py", line 72, in <module>
    bots.append(TwitchBot(path))

Now this points out that the function called with path is giving an error. Especially since you see a lot of decode in the traceback error, you can deduce it has something to with your characters you inputted.

Other errors in your traceback that point this out:

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

JSONDecodeError: Expecting value: line 1 column 1 (char 0) occurs when we try to parse something that is not valid JSON as if it were. To solve the error, make sure the response or the file is not empty or conditionally check for the content type before parsing.

In most cases your json.loads- JSONDecodeError: Expecting value: line 1 column 1 (char 0) error is due to :

  • non-JSON conforming quoting
  • XML/HTML output (that is, a string starting with <), or
  • incompatible character encoding

In this case, the case caused the error (content type!).

Related sources:

Answered By: DialFrost

After I expected the response, I found out that I received a HTTP 400, Bad Request error. This was due to the fact that in the channel configuration I used an uppercase letter whereas Twitch expects all letters lowercase.

Answered By: actc