Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'staticmethod' object is not callable, when run the 'help' command - Bug #20

Closed
muhammad-rafi opened this issue Mar 15, 2022 · 1 comment

Comments

@muhammad-rafi
Copy link
Contributor

muhammad-rafi commented Mar 15, 2022

  • Webex Bot version: 0.2.19
  • Python version: 3.8.12
  • Operating System: macOS Monterey v12.2.1

Description

Getting TypeError: 'staticmethod' object is not callable when I run the 'help' command on webex

What I Did

When running the 'help' command on webex, I am seeing the below Traceback on the terminal , I analyse code again and it seems like method response_from_adaptive_card should be a regular method rather than static method as currently showing up in the response.py

import json

from webexteamssdk.models.cards import AdaptiveCard


@staticmethod   --> should be a regular method 
def response_from_adaptive_card(adaptive_card: AdaptiveCard):
    """
    Convenience method for generating a Response from an AdaptiveCard.

    @param adaptive_card: AdaptiveCard object
    @return: Response object
    """

    response = Response()
    response.text = "This bot requires a client which can render cards."
    response.attachments = {
        "contentType": "application/vnd.microsoft.card.adaptive",
        "content": adaptive_card.to_dict()
    }

    return response


class Response(object):

--------- truncated -----------

Traceback on the terminal

(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ python chattybot.py 
2022-03-14 23:16:01  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-03-14 23:16:01  [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"}
2022-03-14 23:16:01  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['user@company.com'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-03-14 23:16:01  [INFO]  [webex_bot.webex_bot.webex_bot.get_me_info]:87 Running as bot 'ChattyBot' with email ['chattyrobot@webex.bot']
2022-03-14 23:16:01  [WARNING]  [command.webex_bot.models.command.__init__]:40 no card actions data so no entry for 'callback_keyword' for echo
2022-03-14 23:16:01  [INFO]  [command.webex_bot.models.command.set_default_card_callback_keyword]:54 Added default action for 'echo' callback_keyword=callback___echo
2022-03-14 23:16:02  [INFO]  [webex_websocket_client.root._connect_and_listen]:151 Opening websocket connection to wss://mercury-connection-partition0-a.wbx2.com/v1/apps/wx2/registrations/c6792f58-ead1-4aa7-9153-5cfe6c669493/messages
2022-03-14 23:16:02  [INFO]  [webex_websocket_client.root._connect_and_listen]:154 WebSocket Opened.
/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py:100: RuntimeWarning: coroutine 'WebSocketCommonProtocol.send' was never awaited
  self.websocket.send(json.dumps(ack_message))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2022-03-14 23:16:09  [INFO]  [webex_websocket_client.root._ack_message]:101 WebSocket ack message with id=Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYmFmYjY2NTAtYTNlYy0xMWVjLThiMDEtNTdmYjk4YjcwNzM0. Complete.
2022-03-14 23:16:09  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:193 Message from murafi@cisco.com: Webex Teams Message:
{
  "id": "Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYmFmYjY2NTAtYTNlYy0xMWVjLThiMDEtNTdmYjk4YjcwNzM0",
  "roomId": "Y2lzY29zcGFyazovL3VzL1JPT00vYTRiYzMzNjAtNjFmMi0xMWVjLWJkNGUtNTM5NTE1ZDZlYzEz",
  "roomType": "direct",
  "text": "help",
  "personId": "Y2lzY29zcGFyazovL3VzL1BFT1BMRS80MTZkMDE5Mi0yMDQ1LTRhMTktOTM4Yy03YzI0Mjk5MTU1NGY",
  "personEmail": "murafi@cisco.com",
  "created": "2022-03-14T23:16:08.629Z"
}
2022-03-14 23:16:09  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['user@company.com'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-03-14 23:16:09  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=TypeError("'staticmethod' object is not callable")>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.8/3.8.12_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 56, in _process_incoming_websocket_message
    self.on_message(teams_message=webex_message, activity=activity)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 202, in process_incoming_message
    self.process_raw_command(raw_message, teams_message, user_email, activity)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 262, in process_raw_command
    reply, reply_one_to_one = self.run_command_and_handle_bot_exceptions(command=command,
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 341, in run_command_and_handle_bot_exceptions
    return command.card_callback(message, teams_message, activity), False
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/commands/help.py", line 61, in build_card
    return response_from_adaptive_card(adaptive_card=card)
TypeError: 'staticmethod' object is not callable

I am going to raise a pull request, please review it and let me know if you are happy with it.

Thanks,
-Rafi

muhammad-rafi pushed a commit to muhammad-rafi/webex_bot that referenced this issue Mar 15, 2022
fbradyirl added a commit that referenced this issue Apr 7, 2022
* Fix for [#6][i6]
* Fix for [#20][i20]
* Use system SSL context when connecting websocket.
@fbradyirl
Copy link
Owner

Fixed in v0.2.20

gconklin pushed a commit to gconklin/webex_bot that referenced this issue Sep 13, 2023
* Fix for [fbradyirl#6][i6]
* Fix for [fbradyirl#20][i20]
* Use system SSL context when connecting websocket.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants