webex-bot 0.6.1__py2.py3-none-any.whl → 0.6.2__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webex_bot/__init__.py +1 -1
- webex_bot/webex_bot.py +2 -4
- webex_bot/websockets/webex_websocket_client.py +22 -4
- {webex_bot-0.6.1.dist-info → webex_bot-0.6.2.dist-info}/METADATA +6 -1
- {webex_bot-0.6.1.dist-info → webex_bot-0.6.2.dist-info}/RECORD +8 -8
- {webex_bot-0.6.1.dist-info → webex_bot-0.6.2.dist-info}/WHEEL +1 -1
- {webex_bot-0.6.1.dist-info → webex_bot-0.6.2.dist-info}/licenses/LICENSE +0 -0
- {webex_bot-0.6.1.dist-info → webex_bot-0.6.2.dist-info}/top_level.txt +0 -0
webex_bot/__init__.py
CHANGED
webex_bot/webex_bot.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Main module."""
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
|
-
|
|
5
4
|
import types
|
|
5
|
+
|
|
6
6
|
import backoff
|
|
7
7
|
import coloredlogs
|
|
8
8
|
import requests
|
|
@@ -14,7 +14,7 @@ from webex_bot.exceptions import BotException
|
|
|
14
14
|
from webex_bot.formatting import quote_info
|
|
15
15
|
from webex_bot.models.command import CALLBACK_KEYWORD_KEY, Command, COMMAND_KEYWORD_KEY
|
|
16
16
|
from webex_bot.models.response import Response
|
|
17
|
-
from webex_bot.websockets.webex_websocket_client import WebexWebsocketClient
|
|
17
|
+
from webex_bot.websockets.webex_websocket_client import WebexWebsocketClient
|
|
18
18
|
|
|
19
19
|
log = logging.getLogger(__name__)
|
|
20
20
|
|
|
@@ -26,7 +26,6 @@ class WebexBot(WebexWebsocketClient):
|
|
|
26
26
|
approved_users=[],
|
|
27
27
|
approved_domains=[],
|
|
28
28
|
approved_rooms=[],
|
|
29
|
-
device_url=DEFAULT_DEVICE_URL,
|
|
30
29
|
include_demo_commands=False,
|
|
31
30
|
bot_name="Webex Bot",
|
|
32
31
|
bot_help_subtitle="Here are my available commands. Click one to begin.",
|
|
@@ -60,7 +59,6 @@ class WebexBot(WebexWebsocketClient):
|
|
|
60
59
|
teams_bot_token,
|
|
61
60
|
on_message=self.process_incoming_message,
|
|
62
61
|
on_card_action=self.process_incoming_card_action,
|
|
63
|
-
device_url=device_url,
|
|
64
62
|
proxies=proxies)
|
|
65
63
|
|
|
66
64
|
if help_command is None:
|
|
@@ -20,7 +20,7 @@ except ImportError:
|
|
|
20
20
|
|
|
21
21
|
logger = logging.getLogger(__name__)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
DEFAULT_U2C_URL = "https://u2c.wbx2.com/u2c/api/v1/catalog"
|
|
24
24
|
|
|
25
25
|
DEVICE_DATA = {
|
|
26
26
|
"deviceName": "pywebsocket-client",
|
|
@@ -41,14 +41,13 @@ MAX_BACKOFF_TIME = 240
|
|
|
41
41
|
class WebexWebsocketClient(object):
|
|
42
42
|
def __init__(self,
|
|
43
43
|
access_token,
|
|
44
|
-
device_url=DEFAULT_DEVICE_URL,
|
|
45
44
|
on_message=None,
|
|
46
45
|
on_card_action=None,
|
|
47
46
|
proxies=None):
|
|
48
47
|
self.access_token = access_token
|
|
49
48
|
self.teams = WebexAPI(access_token=access_token, proxies=proxies)
|
|
50
|
-
self.device_url = device_url
|
|
51
49
|
self.device_info = None
|
|
50
|
+
self.device_url = self._get_device_url()
|
|
52
51
|
self.on_message = on_message
|
|
53
52
|
self.on_card_action = on_card_action
|
|
54
53
|
self.proxies = proxies
|
|
@@ -155,6 +154,25 @@ class WebexWebsocketClient(object):
|
|
|
155
154
|
asyncio.run(self.websocket.send(json.dumps(ack_message)))
|
|
156
155
|
logger.info(f"WebSocket ack message with id={message_id}. Complete.")
|
|
157
156
|
|
|
157
|
+
def _get_device_url(self):
|
|
158
|
+
headers = {}
|
|
159
|
+
headers["Authorization"] = 'Bearer ' + self.access_token
|
|
160
|
+
|
|
161
|
+
params = {"format": "hostmap"}
|
|
162
|
+
response = requests.get(DEFAULT_U2C_URL, headers=headers, params=params)
|
|
163
|
+
|
|
164
|
+
# check for 401 Unauthorized
|
|
165
|
+
if response.status_code == 401:
|
|
166
|
+
logger.error("Unauthorized access. Please check your access token.")
|
|
167
|
+
raise Exception("Unauthorized access. Please check your access token.")
|
|
168
|
+
|
|
169
|
+
data = response.json()
|
|
170
|
+
|
|
171
|
+
wdm_url = data["serviceLinks"].get("wdm") # or whatever key your hostmap uses
|
|
172
|
+
logging.info(f"wdm url: {wdm_url}")
|
|
173
|
+
return wdm_url
|
|
174
|
+
|
|
175
|
+
|
|
158
176
|
def _get_device_info(self, check_existing=True):
|
|
159
177
|
"""
|
|
160
178
|
Get device info from Webex Cloud.
|
|
@@ -264,4 +282,4 @@ class WebexWebsocketClient(object):
|
|
|
264
282
|
logger.error('could not create device info')
|
|
265
283
|
raise Exception("No WDM device info")
|
|
266
284
|
# trigger re-connect
|
|
267
|
-
asyncio.get_event_loop().run_until_complete(_connect_and_listen())
|
|
285
|
+
asyncio.get_event_loop().run_until_complete(_connect_and_listen())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Python package for a Webex Bot based on websockets.
|
|
5
5
|
Home-page: https://github.com/fbradyirl/webex_bot
|
|
6
6
|
Author: Finbarr Brady
|
|
@@ -443,6 +443,9 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
443
443
|
|
|
444
444
|
* Handle and retry on InvalidStatusCode in Websocket loop
|
|
445
445
|
|
|
446
|
+
### 0.6.2 (2025-May-23)
|
|
447
|
+
|
|
448
|
+
* Fix for [issue #48][i48] - Fix for `Commands not being received` issue.
|
|
446
449
|
|
|
447
450
|
[1]: https://github.com/aaugustin/websockets
|
|
448
451
|
|
|
@@ -489,3 +492,5 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
489
492
|
[i13]: https://github.com/fbradyirl/webex_bot/issues/13
|
|
490
493
|
|
|
491
494
|
[i20]: https://github.com/fbradyirl/webex_bot/issues/20
|
|
495
|
+
|
|
496
|
+
[i48]: https://github.com/fbradyirl/webex_bot/issues/48
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
webex_bot/__init__.py,sha256=
|
|
1
|
+
webex_bot/__init__.py,sha256=EP4VtizaH3ugEVwSp88ObjRczYV5ZlL4rNJ1vMC9BkA,95
|
|
2
2
|
webex_bot/exceptions.py,sha256=qs9yVitfJtvxwBMC8uCvTDOxUQ_oZjWFf1dU8Oaue14,740
|
|
3
3
|
webex_bot/formatting.py,sha256=jvPKym-z8CIJygpPVTVbt6vFXQo9_HQHpRDJB-nh-SI,382
|
|
4
|
-
webex_bot/webex_bot.py,sha256=
|
|
4
|
+
webex_bot/webex_bot.py,sha256=np5uGnVJc-l9jrbD9UPeoZU5JeuD8THLWd6Ml9HTlJ4,21153
|
|
5
5
|
webex_bot/cards/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
webex_bot/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
webex_bot/commands/echo.py,sha256=STY-MikBRjUteDK-g8G4GPB0V-Yi7siPN1DRMXrT-QU,3399
|
|
@@ -10,9 +10,9 @@ webex_bot/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
10
10
|
webex_bot/models/command.py,sha256=MyThlDaEkGlj1fDE_i_wr79O3QboakimRme8yI744yo,5327
|
|
11
11
|
webex_bot/models/response.py,sha256=d4k2ohR5SUVzvuQzcnm7jQQVTMB0gH9Kz9y09vkoAaU,2545
|
|
12
12
|
webex_bot/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
webex_bot/websockets/webex_websocket_client.py,sha256=
|
|
14
|
-
webex_bot-0.6.
|
|
15
|
-
webex_bot-0.6.
|
|
16
|
-
webex_bot-0.6.
|
|
17
|
-
webex_bot-0.6.
|
|
18
|
-
webex_bot-0.6.
|
|
13
|
+
webex_bot/websockets/webex_websocket_client.py,sha256=byESKbgWa4x-tGX0DboWGfB3cpCAmPVyiL19V4FGVAc,11903
|
|
14
|
+
webex_bot-0.6.2.dist-info/licenses/LICENSE,sha256=93eGb10xmgkBP2Fh_n0E9YDXe0c0oz-FsnAimXG0S4Y,1072
|
|
15
|
+
webex_bot-0.6.2.dist-info/METADATA,sha256=HjomyzkjM0IFLrU7KD-eOCudzO2RtSLATk_9xcWjtgM,14590
|
|
16
|
+
webex_bot-0.6.2.dist-info/WHEEL,sha256=egKm5cKfE6OqlHwodY8Jjp4yqZDBXgsj09UsV5ojd_U,109
|
|
17
|
+
webex_bot-0.6.2.dist-info/top_level.txt,sha256=q1Y0RtYYinR7oXSwL93cK59c2KN_CbMVca8MLWeF63M,10
|
|
18
|
+
webex_bot-0.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|