fbradyirl / webex_bot

Python package for a Webex Bot based on websockets.
MIT License
68 stars 44 forks source link

`AttributeError: 'WebexBot' object has no attribute 'command'` #18

Closed muhammad-rafi closed 2 years ago

muhammad-rafi commented 2 years ago

Description

I was writing a basic script as below which is same as https://github.com/fbradyirl/webex_bot/blob/main/example.py

and seeing the following error

AttributeError: 'WebexBot' object has no attribute 'command'

Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Copy the example.py from your https://github.com/fbradyirl/webex_bot/blob/main/example.py and changed the secret token

import os
from webex_bot.commands.echo import EchoCommand
from webex_bot.webex_bot import WebexBot

# Create a Bot Object
bot = WebexBot(teams_bot_token= 'my secret token')

# Add new commands for the bot to listen out for.
bot.add_command(EchoCommand())

# Call `run` for the bot to wait for incoming messages.
bot.run()

When I try to run the script, I am getting following traceback

(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ python chattybot.py 
2022-03-13 23:49:07  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-03-13 23:49:07  [INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.8.12"}, "distro": {"name": "macOS", "version": "12.2.1"}, "system": {"name": "Darwin", "release": "21.3.0"}, "cpu": "x86_64"}
Traceback (most recent call last):
  File "chattybot.py", line 44, in <module>
    bot = WebexBot(teams_bot_token= 'NTE2OGI2NzQtZTcxYi00MzZmLThhNTItZGQzNTQ2ZjdjNDkxMDE2Y2ZmOGMtZGE4_PF84_1eb65fdf-9643-417f-9974-ad72cae0e10f')
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 65, in __init__
    self.command.add(EchoCommand())
AttributeError: 'WebexBot' object has no attribute 'command'
(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ 

It seems like a bug as there are couple of typos and I am going to create a pull request to fix unless you guys created this like on purpose ? and I am missing something