fbradyirl / webex_bot

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

Future exception was never retrieved #24

Closed M35a2 closed 2 years ago

M35a2 commented 2 years ago

Description

running the included example.py file, send the bot a message, and I get:

2022-04-05 13:01:36  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=<ApiError [404] Not Found>>

What I Did

virtualenv webexbot
pip install webex_bot
export WEBEX_TEAMS_ACCESS_TOKEN='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
(webexbot) ben@ub-box:~/workingDirectory/webexBot/socketBot$ python3 example.py 
2022-04-05 13:14:47  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-04-05 13:14:47  [INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.8.10"}, "system": {"name": "Linux", "release": "5.13.0-30-generic"}, "cpu": "x86_64"}
2022-04-05 13:14:48  [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-04-05 13:14:48  [INFO]  [webex_bot.webex_bot.webex_bot.get_me_info]:87 Running as bot 'RecurveBot' with email ['RecurveBot@webex.bot']
2022-04-05 13:14:48  [WARNING]  [command.webex_bot.models.command.__init__]:40 no card actions data so no entry for 'callback_keyword' for echo
2022-04-05 13:14:48  [INFO]  [command.webex_bot.models.command.set_default_card_callback_keyword]:54 Added default action for 'echo' callback_keyword=callback___echo
2022-04-05 13:14:48  [INFO]  [webex_websocket_client.root._connect_and_listen]:151 Opening websocket connection to wss://mercury-connection-partition0-a.wbx2.com/v1/apps/wx2/registrations/c471a9c9-958e-48d6-b392-7a115b12b43f/messages
2022-04-05 13:14:49  [INFO]  [webex_websocket_client.root._connect_and_listen]:154 WebSocket Opened.
/home/ben/workingDirectory/webexBot/webexbot/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-04-05 13:15:02  [INFO]  [webex_websocket_client.root._ack_message]:101 WebSocket ack message with id=Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYjBkNjcxZTAtYjUx. Complete.
2022-04-05 13:15:02  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:193 Message from bschuste@cisco.com: Webex Teams Message:
{
  "id": "Y2lzY29zcGFya...",
  "roomId": "Y2lzY29zcGFya....",
  "roomType": "group",
  "text": "RecurveBot test",
  "personId": "Y2lzY29zcGF...",
  "personEmail": "test@test.com",
  "html": "<p><spark-mention data-object-type=\"person\" data-object-id=\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS82ZWMzYWRj\">RecurveBot</spark-mention> test</p>",
  "mentionedPeople": [
    "Y2lzY29zcGFyazovL3VzL1B"
  ],
  "created": "2022-04-05T19:15:01.246Z"
}
2022-04-05 13:15:02  [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-04-05 13:15:02  [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/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ben/workingDirectory/webexBot/webexbot/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 "/home/ben/workingDirectory/webexBot/webexbot/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 "/home/ben/workingDirectory/webexBot/webexbot/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 "/home/ben/workingDirectory/webexBot/webexbot/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 "/home/ben/workingDirectory/webexBot/webexbot/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
^CTraceback (most recent call last):
  File "example.py", line 13, in <module>
    bot.run()
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 164, in run
    asyncio.get_event_loop().run_until_complete(_connect_and_listen())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.8/selectors.py", line 468, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt

issue happens inside and outside a vitrualenv future is installed is there a recommended python version i should be using?

gconklin commented 2 years ago

The current 0.2.19 release has a breaking bug which is fixed by https://github.com/fbradyirl/webex_bot/pull/21 related to the future: <Future finished exception=TypeError("'staticmethod' object is not callable")> error in your output

Either drop back a rev (or more?) or merge the above fix.

See also issue https://github.com/fbradyirl/webex_bot/issues/20

M35a2 commented 2 years ago

perfect thanks! that fixed it.