Exaphis / HackQ-Trivia

Yet another HQ Trivia bot. Automatically scrapes HQ Trivia questions without OCR and answers them.
MIT License
89 stars 54 forks source link

the new websocket changes: UnboundLocalError: local variable 'message' referenced before assignment #100

Closed SharpBit closed 6 years ago

SharpBit commented 6 years ago
Traceback (most recent call last):
  File "bot.py", line 79, in get_questions
    await networking.websocket_handler(socket, headers)
  File "/app/networking.py", line 56, in websocket_handler
    message = re.sub(r"[\x00-\x1f\x7f-\x9f]", "", message)
UnboundLocalError: local variable 'message' referenced before assignment

Just got that ^ this is the code:

    for msg in websocket.connect(ping_rate=5):
        if msg.name == "text":
            message = msg.text
        message = re.sub(r"[\x00-\x1f\x7f-\x9f]", "", message)

@Exaphis I'm pretty sure that means msg.name != 'text'. This never happened before.

Exaphis commented 6 years ago

Your file has some weird indentation issues and is different from networking.py on Github. Please clone the repo again or indent everything so that it is under the if statement.

SharpBit commented 6 years ago

whoops, just saw it. Thanks