Python: Why is my Slack-Bot not working in CMD?

Viewed 785

I'm trying to code a Slack-Bot which is asking for lunch and is taking orders for lunch.

I'm working with this tutorial.

My problem is: I'm trying to run my script in CMD (yes, windows!) but I receive this error:

C:\Users\Dave\PycharmProjects\lunchbot>python lunchbot.py
    Traceback (most recent call last):
    File "lunchbot.py", line 167, in <module>
    if slack_client.rtm_connect(with_team_state=False):
TypeError: rtm_connect() got an unexpected keyword argument 'with_team_state'

This is the part of the code that's not working correctly:

if __name__ == "__main__":
if slack_client.rtm_connect(with_team_state=False):
    print("Lunchbot is ready to go!")
    starterbot_id = slack_client.api_call("auth.test")["user_id"]
    while True:
        command, channel = parse_bot_commands(slack_client.rtm_read())
        if command:
            handle_command(command, channel)
        time.sleep(RTM_READ_DELAY)
else:
    print("No connection.")

What actually confuses me is every time I'm trying to run this code in my IDE everything is fine. Does anybody have an idea of what could be wrong?

1 Answers

There is a known issue with the websocket-client and Slack. It's buggy and has been a problem for some time now. I wonder if your Pycharm environment is pointing to a different version and hence why it is working.

I would try to force the value of the websocket-client with a known working version. websocket-client==0.40.0 for example:

Related