webex-bot 1.0.4__tar.gz → 1.0.5__tar.gz
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-1.0.4/webex_bot.egg-info → webex_bot-1.0.5}/PKG-INFO +6 -2
- {webex_bot-1.0.4 → webex_bot-1.0.5}/README.md +5 -1
- {webex_bot-1.0.4 → webex_bot-1.0.5}/setup.cfg +1 -1
- {webex_bot-1.0.4 → webex_bot-1.0.5}/setup.py +1 -1
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/__init__.py +1 -1
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/webex_bot.py +1 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/websockets/webex_websocket_client.py +13 -11
- {webex_bot-1.0.4 → webex_bot-1.0.5/webex_bot.egg-info}/PKG-INFO +6 -2
- {webex_bot-1.0.4 → webex_bot-1.0.5}/CONTRIBUTING.rst +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/LICENSE +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/MANIFEST.in +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/Makefile +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/conf.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/contributing.rst +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/index.rst +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/installation.rst +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/make.bat +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/docs/usage.rst +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/tests/__init__.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/tests/test_webex_bot.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/cards/__init__.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/commands/__init__.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/commands/echo.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/commands/help.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/exceptions.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/formatting.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/models/__init__.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/models/command.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/models/response.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot/websockets/__init__.py +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot.egg-info/SOURCES.txt +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot.egg-info/dependency_links.txt +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot.egg-info/not-zip-safe +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot.egg-info/requires.txt +0 -0
- {webex_bot-1.0.4 → webex_bot-1.0.5}/webex_bot.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
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
|
|
@@ -455,7 +455,11 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
455
455
|
### 1.0.4 (2025-Jul-01)
|
|
456
456
|
|
|
457
457
|
* Add retry mechanism with backoff for websocket 404 errors
|
|
458
|
-
|
|
458
|
+
|
|
459
|
+
### 1.0.5 (2025-Sept-11)
|
|
460
|
+
|
|
461
|
+
* Update UA
|
|
462
|
+
|
|
459
463
|
|
|
460
464
|
[1]: https://github.com/aaugustin/websockets
|
|
461
465
|
|
|
@@ -415,7 +415,11 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
415
415
|
### 1.0.4 (2025-Jul-01)
|
|
416
416
|
|
|
417
417
|
* Add retry mechanism with backoff for websocket 404 errors
|
|
418
|
-
|
|
418
|
+
|
|
419
|
+
### 1.0.5 (2025-Sept-11)
|
|
420
|
+
|
|
421
|
+
* Update UA
|
|
422
|
+
|
|
419
423
|
|
|
420
424
|
[1]: https://github.com/aaugustin/websockets
|
|
421
425
|
|
|
@@ -57,6 +57,7 @@ class WebexBot(WebexWebsocketClient):
|
|
|
57
57
|
log.info("Registering bot with Webex cloud")
|
|
58
58
|
WebexWebsocketClient.__init__(self,
|
|
59
59
|
teams_bot_token,
|
|
60
|
+
bot_name,
|
|
60
61
|
on_message=self.process_incoming_message,
|
|
61
62
|
on_card_action=self.process_incoming_card_action,
|
|
62
63
|
proxies=proxies)
|
|
@@ -43,6 +43,7 @@ MAX_BACKOFF_TIME = 240
|
|
|
43
43
|
class WebexWebsocketClient(object):
|
|
44
44
|
def __init__(self,
|
|
45
45
|
access_token,
|
|
46
|
+
bot_name,
|
|
46
47
|
on_message=None,
|
|
47
48
|
on_card_action=None,
|
|
48
49
|
proxies=None):
|
|
@@ -50,9 +51,10 @@ class WebexWebsocketClient(object):
|
|
|
50
51
|
self.teams = WebexAPI(access_token=access_token, proxies=proxies)
|
|
51
52
|
self.tracking_id = f"webex-bot_{uuid.uuid4()}"
|
|
52
53
|
self.session = requests.Session()
|
|
53
|
-
self.session.headers = self._get_headers()
|
|
54
54
|
sdk_ua = self.teams._session.headers["User-Agent"]
|
|
55
|
-
self.
|
|
55
|
+
self.add_to_ua = f" '{bot_name}' ({sdk_ua})"
|
|
56
|
+
self.session.headers = self._get_headers()
|
|
57
|
+
self.teams._session.update_headers(self._get_headers())
|
|
56
58
|
# log the tracking ID
|
|
57
59
|
logger.info(f"Tracking ID: {self.tracking_id}")
|
|
58
60
|
self.device_info = None
|
|
@@ -69,11 +71,11 @@ class WebexWebsocketClient(object):
|
|
|
69
71
|
if proxy_connect is None:
|
|
70
72
|
raise ImportError("Failed to load libraries for proxy, maybe forgot [proxy] option during installation.")
|
|
71
73
|
|
|
72
|
-
def _get_headers(self
|
|
74
|
+
def _get_headers(self):
|
|
73
75
|
return {
|
|
74
76
|
"Authorization": f"Bearer {self.access_token}",
|
|
75
77
|
"Content-type": "application/json;charset=utf-8",
|
|
76
|
-
"User-Agent": f"webex_bot/{__version__}{add_to_ua}",
|
|
78
|
+
"User-Agent": f"webex_bot/{__version__}{self.add_to_ua}",
|
|
77
79
|
"trackingid": self.tracking_id
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -279,7 +281,7 @@ class WebexWebsocketClient(object):
|
|
|
279
281
|
# Track the number of consecutive 404 errors to prevent infinite loops
|
|
280
282
|
max_404_retries = 3
|
|
281
283
|
current_404_retries = 0
|
|
282
|
-
|
|
284
|
+
|
|
283
285
|
while True:
|
|
284
286
|
try:
|
|
285
287
|
asyncio.get_event_loop().run_until_complete(_connect_and_listen())
|
|
@@ -287,19 +289,19 @@ class WebexWebsocketClient(object):
|
|
|
287
289
|
break
|
|
288
290
|
except InvalidStatusCode as e:
|
|
289
291
|
logger.error(f"WebSocket handshake to {ws_url} failed with status {e.status_code}")
|
|
290
|
-
|
|
292
|
+
|
|
291
293
|
if e.status_code == 404:
|
|
292
294
|
current_404_retries += 1
|
|
293
295
|
if current_404_retries >= max_404_retries:
|
|
294
296
|
logger.error(f"Reached maximum retries ({max_404_retries}) for 404 errors. Giving up.")
|
|
295
297
|
raise Exception(f"Unable to connect to WebSocket after {max_404_retries} attempts. Device registration may be invalid.")
|
|
296
|
-
|
|
298
|
+
|
|
297
299
|
logger.info(f"Refreshing WDM device info and retrying... (Attempt {current_404_retries} of {max_404_retries})")
|
|
298
300
|
# Force a new device registration
|
|
299
301
|
self._get_device_info(check_existing=False)
|
|
300
302
|
# Update ws_url with the new device info
|
|
301
303
|
ws_url = self.device_info.get('webSocketUrl')
|
|
302
|
-
|
|
304
|
+
|
|
303
305
|
# Add a delay before retrying to avoid hammering the server
|
|
304
306
|
logger.info(f"Waiting 5 seconds before retry attempt {current_404_retries}...")
|
|
305
307
|
asyncio.get_event_loop().run_until_complete(asyncio.sleep(5))
|
|
@@ -308,15 +310,15 @@ class WebexWebsocketClient(object):
|
|
|
308
310
|
raise
|
|
309
311
|
except Exception as runException:
|
|
310
312
|
logger.error(f"runException: {runException}")
|
|
311
|
-
|
|
313
|
+
|
|
312
314
|
# Check if we can get device info
|
|
313
315
|
if self._get_device_info(check_existing=False) is None:
|
|
314
316
|
logger.error('could not create device info')
|
|
315
317
|
raise Exception("No WDM device info")
|
|
316
|
-
|
|
318
|
+
|
|
317
319
|
# Update the URL in case it changed
|
|
318
320
|
ws_url = self.device_info.get('webSocketUrl')
|
|
319
|
-
|
|
321
|
+
|
|
320
322
|
# Wait a bit before reconnecting
|
|
321
323
|
logger.info("Waiting 5 seconds before attempting to reconnect...")
|
|
322
324
|
asyncio.get_event_loop().run_until_complete(asyncio.sleep(5))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
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
|
|
@@ -455,7 +455,11 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
455
455
|
### 1.0.4 (2025-Jul-01)
|
|
456
456
|
|
|
457
457
|
* Add retry mechanism with backoff for websocket 404 errors
|
|
458
|
-
|
|
458
|
+
|
|
459
|
+
### 1.0.5 (2025-Sept-11)
|
|
460
|
+
|
|
461
|
+
* Update UA
|
|
462
|
+
|
|
459
463
|
|
|
460
464
|
[1]: https://github.com/aaugustin/websockets
|
|
461
465
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|