webex-bot 0.5.1__py2.py3-none-any.whl → 0.6.0__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  """Top-level package for Webex Bot."""
2
2
 
3
3
  __author__ = """Finbarr Brady"""
4
- __version__ = '0.5.1'
4
+ __version__ = '0.6.0'
@@ -1,8 +1,8 @@
1
1
  import logging
2
2
 
3
- from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
3
+ from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
4
4
  Text, Image, HorizontalAlignment
5
- from webexteamssdk.models.cards.actions import Submit
5
+ from webexpythonsdk.models.cards.actions import Submit
6
6
 
7
7
  from webex_bot.formatting import quote_info
8
8
  from webex_bot.models.command import Command
@@ -1,8 +1,8 @@
1
1
  import logging
2
2
 
3
- from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
3
+ from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
4
4
  ImageSize, Image, Fact
5
- from webexteamssdk.models.cards.actions import Submit
5
+ from webexpythonsdk.models.cards.actions import Submit
6
6
 
7
7
  from webex_bot.models.command import Command, COMMAND_KEYWORD_KEY
8
8
  from webex_bot.models.response import response_from_adaptive_card
@@ -9,8 +9,9 @@ COMMAND_KEYWORD_KEY = "command_keyword"
9
9
 
10
10
  class Command(ABC):
11
11
 
12
- def __init__(self, command_keyword=None, chained_commands=[], card=None, help_message=None,
13
- delete_previous_message=False,
12
+ def __init__(self, command_keyword=None, exact_command_keyword_match=False,
13
+ chained_commands=[], card=None,
14
+ help_message=None, delete_previous_message=False,
14
15
  card_callback_keyword=None, approved_rooms=None):
15
16
  """
16
17
  Create a new bot command.
@@ -25,10 +26,11 @@ class Command(ABC):
25
26
  )
26
27
 
27
28
  @param command_keyword: (optional) Text indicating a phrase to invoke this card.
29
+ @param exact_command_keyword_match: If True, there will be an exact command_keyword match performed. If False, then a sub-string match will be performed. Default: False.
28
30
  @param chained_commands: (optional) List of other commands related
29
31
  to this command. This allows multiple related cards to be added at once.
30
32
  @param card: (deprecated) A dict representation of the JSON card.
31
- Prefer to use cards built in code using the webexteamssdk.models.cards classes
33
+ Prefer to use cards built in code using the webexpythonsdk.models.cards classes
32
34
  (see https://github.com/fbradyirl/webex_bot/blob/main/webex_bot/commands/echo.py for example)
33
35
  @param help_message: Short description of this command.
34
36
  @param delete_previous_message: If True, the card which invoked this command will be deleted. (default False)
@@ -37,6 +39,7 @@ class Command(ABC):
37
39
  @param approved_rooms: If defined, only members of these spaces will be allowed to run this command. Default: None (everyone)
38
40
  """
39
41
  self.command_keyword = command_keyword
42
+ self.exact_command_keyword_match = exact_command_keyword_match
40
43
  self.help_message = help_message
41
44
  self.card = card
42
45
  self.pre_card_callback = self.execute
@@ -52,7 +55,7 @@ class Command(ABC):
52
55
  if card is not None:
53
56
  log.warning(f"[{command_keyword}]. Using a card dict is now deprecated. "
54
57
  f"Switch to use adaptive cards built in code "
55
- "using the webexteamssdk.models.cards classes (see "
58
+ "using the webexpythonsdk.models.cards classes (see "
56
59
  "https://github.com/fbradyirl/webex_bot/blob/main/webex_bot/commands/echo.py for example)")
57
60
  if 'actions' in card:
58
61
  if len(card['actions']) > 0:
@@ -1,6 +1,6 @@
1
1
  import json
2
2
 
3
- from webexteamssdk.models.cards import AdaptiveCard
3
+ from webexpythonsdk.models.cards import AdaptiveCard
4
4
 
5
5
 
6
6
  def response_from_adaptive_card(adaptive_card: AdaptiveCard):
webex_bot/webex_bot.py CHANGED
@@ -2,10 +2,11 @@
2
2
  import logging
3
3
  import os
4
4
 
5
+ import types
5
6
  import backoff
6
7
  import coloredlogs
7
8
  import requests
8
- import webexteamssdk
9
+ import webexpythonsdk
9
10
 
10
11
  from webex_bot.commands.echo import EchoCommand
11
12
  from webex_bot.commands.help import HelpCommand
@@ -95,7 +96,7 @@ class WebexBot(WebexWebsocketClient):
95
96
  @backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError)
96
97
  def get_me_info(self):
97
98
  """
98
- Fetch me info from webexteamssdk
99
+ Fetch me info from webexpythonsdk
99
100
  """
100
101
  me = self.teams.people.me()
101
102
  self.bot_display_name = me.displayName
@@ -168,7 +169,7 @@ class WebexBot(WebexWebsocketClient):
168
169
  for member in room_members:
169
170
  if member.personEmail == user_email:
170
171
  is_user_member = True
171
- except webexteamssdk.exceptions.ApiError as apie:
172
+ except webexpythonsdk.exceptions.ApiError as apie:
172
173
  log.warn(f"API error: {apie}")
173
174
  return is_user_member
174
175
 
@@ -234,10 +235,21 @@ class WebexBot(WebexWebsocketClient):
234
235
 
235
236
  if not is_card_callback_command and c.command_keyword:
236
237
  log.debug(f"c.command_keyword: {c.command_keyword}")
237
- if user_command.find(c.command_keyword) != -1:
238
- command = c
239
- # If a command was found, stop looking for others
240
- break
238
+ log.info(f"exact_command_keyword_match: {c.exact_command_keyword_match}")
239
+ log.info(f"user_command: {user_command}")
240
+ log.info(f"command_keyword: {c.command_keyword}")
241
+ if c.exact_command_keyword_match: # Check if the "exact_command_keyword_match" flag is set to True
242
+ if user_command == c.command_keyword:
243
+ log.info("Exact match found!")
244
+ command=c
245
+ # If a command was found, stop looking for others
246
+ break
247
+ else: # Enter here if the "exact_command_keyword_match" flag is set to False
248
+ if user_command.find(c.command_keyword) != -1:
249
+ log.info("Sub-string match found!")
250
+ command = c
251
+ # If a command was found, stop looking for others
252
+ break
241
253
  else:
242
254
  log.debug(f"card_callback_keyword: {c.card_callback_keyword}")
243
255
  if user_command == c.command_keyword or user_command == c.card_callback_keyword:
@@ -325,7 +337,7 @@ class WebexBot(WebexWebsocketClient):
325
337
  self.teams.messages.create(**reply)
326
338
  reply = "ok"
327
339
  # Support returning a list of Responses
328
- elif reply and isinstance(reply, list):
340
+ elif reply and (isinstance(reply, list) or isinstance(reply, types.GeneratorType)):
329
341
  for response in reply:
330
342
  # Make sure is a Response
331
343
  if isinstance(response, Response):
@@ -9,7 +9,7 @@ import backoff
9
9
  import certifi
10
10
  import requests
11
11
  import websockets
12
- from webexteamssdk import WebexTeamsAPI
12
+ from webexpythonsdk import WebexAPI
13
13
 
14
14
  try:
15
15
  from websockets_proxy import Proxy, proxy_connect
@@ -45,7 +45,7 @@ class WebexWebsocketClient(object):
45
45
  on_card_action=None,
46
46
  proxies=None):
47
47
  self.access_token = access_token
48
- self.teams = WebexTeamsAPI(access_token=access_token, proxies=proxies)
48
+ self.teams = WebexAPI(access_token=access_token, proxies=proxies)
49
49
  self.device_url = device_url
50
50
  self.device_info = None
51
51
  self.on_message = on_message
@@ -1,33 +1,55 @@
1
- Metadata-Version: 2.1
2
- Name: webex-bot
3
- Version: 0.5.1
1
+ Metadata-Version: 2.4
2
+ Name: webex_bot
3
+ Version: 0.6.0
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
7
7
  Author-email: finbarr@somemail.com
8
8
  License: MIT license
9
9
  Keywords: webex_bot
10
- Platform: UNKNOWN
11
10
  Classifier: Development Status :: 2 - Pre-Alpha
12
11
  Classifier: Intended Audience :: Developers
13
12
  Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Natural Language :: English
15
- Classifier: Programming Language :: Python :: 3.8
16
- Classifier: Programming Language :: Python :: 3.9
17
- Requires-Python: >=3.8
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Python: >=3.10
18
19
  Description-Content-Type: text/markdown
19
20
  License-File: LICENSE
20
- Requires-Dist: webexteamssdk ==1.6.1
21
+ Requires-Dist: webexpythonsdk==2.0.4
21
22
  Requires-Dist: coloredlogs
22
- Requires-Dist: websockets ==11.0.3
23
+ Requires-Dist: websockets==11.0.3
23
24
  Requires-Dist: backoff
24
25
  Provides-Extra: proxy
25
- Requires-Dist: websockets-proxy >=0.1.1 ; extra == 'proxy'
26
+ Requires-Dist: websockets_proxy>=0.1.1; extra == "proxy"
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: provides-extra
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
26
40
 
27
41
  # Introduction
28
42
 
29
43
  [![Pypi](https://img.shields.io/pypi/v/webex_bot.svg)](https://pypi.python.org/pypi/webex_bot) [![Build Status](https://github.com/fbradyirl/webex_bot/workflows/Python%20package/badge.svg)](https://github.com/fbradyirl/webex_bot/actions)
30
44
 
45
+ > [!IMPORTANT]
46
+ > This repository is only sporadically maintained. Breaking API changes will be maintained on a best efforts basis.
47
+ >
48
+ > Collaborators are welcome, as are PRs for enhancements.
49
+ >
50
+ > Bug reports unrelated to API changes may not get the attention you want.
51
+
52
+
31
53
  By using this module, you can create a [Webex Teams][5] messaging bot quickly in just a couple of lines of code.
32
54
 
33
55
  This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or
@@ -41,7 +63,7 @@ inside a LAN. This package instead uses a websocket to receive messages from the
41
63
  * Allows for single or multi-post responses. This is useful if you want to reply with a lot of data, but it won't all
42
64
  fit in a single response.
43
65
  * Restrict bot to certain users or domains.
44
- * Uses the [webexteamssdk][2] package to send back replies from the bot.
66
+ * Uses the [webexpythonsdk][2] package to send back replies from the bot.
45
67
 
46
68
  ## 🚀 Getting started
47
69
 
@@ -53,7 +75,7 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
53
75
 
54
76
  ----
55
77
 
56
- **Only Python 3.9 is tested at this time.**
78
+ **Only Python 3.13 is tested at this time.**
57
79
 
58
80
  1. Install this module from pypi:
59
81
 
@@ -66,7 +88,7 @@ If you need optional proxy support, use this command instead:
66
88
  2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
67
89
 
68
90
  ```sh
69
- export WEBEX_TEAMS_ACCESS_TOKEN=<your bots token>
91
+ export WEBEX_ACCESS_TOKEN=<your bots token>
70
92
  ```
71
93
 
72
94
  3. Run your script:
@@ -89,7 +111,7 @@ proxies = {
89
111
  }
90
112
 
91
113
  # Create a Bot Object
92
- bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
114
+ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
93
115
  approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
94
116
  bot_name="My Teams Ops Bot",
95
117
  include_demo_commands=True,
@@ -107,9 +129,9 @@ where EchoCommand is defined as:
107
129
  ```python
108
130
  import logging
109
131
 
110
- from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
132
+ from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
111
133
  Text, Image, HorizontalAlignment
112
- from webexteamssdk.models.cards.actions import Submit
134
+ from webexpythonsdk.models.cards.actions import Submit
113
135
 
114
136
  from webex_bot.formatting import quote_info
115
137
  from webex_bot.models.command import Command
@@ -201,7 +223,8 @@ and off you go!
201
223
 
202
224
  # Help
203
225
 
204
- * If you are a Cisco employee, you can join the [discussion space here][7].
226
+ * If you are a Cisco employee, and find this useful, consider sending me a [Connected Recognition][8] (cec: `fibrady`) 🙂
227
+ * Also, join the [discussion space here][7].
205
228
  * Alternatively, open an issue or PR with a question on usage.
206
229
 
207
230
  # History
@@ -382,9 +405,42 @@ and off you go!
382
405
 
383
406
  * Add Proxy Support. ([#56][pr56])
384
407
 
408
+ ### 0.5.2 (2024-Aug-21)
409
+
410
+ * Introduce exact_command_keyword_match feature ([#59][pr59])
411
+
412
+ ### 0.6.0 (2025-Apr-24)
413
+
414
+ * Migrate from "webexteamssdk" library to "webexpythonsdk" library ([#62][pr62])
415
+ * Updated webexpythonsdk library version ([#69][pr69])
416
+ * Added support for generators ([#71][pr71])
417
+
418
+ #### Breaking changes for the existing webex_bot based applications:
419
+
420
+ * Support is limited to only Python 3.10+ versions. webex_bot applications running on lower Python versions will have to
421
+ adapt to this change in Python version requirement.
422
+ * Make the following code changes to your webex_bot application to adapt to ```webex_bot 0.6.0 version and upwards```.
423
+
424
+ 1. ***Mandatory step:*** Replace all imports from `webexteamssdk` to `webexpythonsdk`. For example:
425
+ ```
426
+ from webexteamssdk.models.cards import TextBlock
427
+ ```
428
+ to
429
+ ```
430
+ from webexpythonsdk.models.cards import TextBlock\
431
+ ```
432
+ 2. ***This step is applicable only if you pass your Webex bot access token to webex_bot via environment variable:*** Change your Webex bot access token environment variable from `WEBEX_TEAMS_ACCESS_TOKEN` to `WEBEX_ACCESS_TOKEN`. Also, make the following code change in your webex_bot application:
433
+ ```
434
+ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN")
435
+ ```
436
+ to
437
+ ```
438
+ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
439
+ ```
440
+
385
441
  [1]: https://github.com/aaugustin/websockets
386
442
 
387
- [2]: https://github.com/CiscoDevNet/webexteamssdk
443
+ [2]: https://github.com/WebexCommunity/WebexPythonSDK
388
444
 
389
445
  [3]: https://developer.webex.com/docs/bots
390
446
 
@@ -396,6 +452,8 @@ and off you go!
396
452
 
397
453
  [7]: https://eurl.io/#TeBLqZjLs
398
454
 
455
+ [8]: https://www.globoforce.net/microsites/t/awards/Redeem?client=cisco&setCAG=true
456
+
399
457
  [pr43]: https://github.com/fbradyirl/webex_bot/pull/43
400
458
 
401
459
  [pr46]: https://github.com/fbradyirl/webex_bot/pull/46
@@ -408,6 +466,14 @@ and off you go!
408
466
 
409
467
  [pr56]: https://github.com/fbradyirl/webex_bot/pull/56
410
468
 
469
+ [pr59]: https://github.com/fbradyirl/webex_bot/pull/59
470
+
471
+ [pr62]: https://github.com/fbradyirl/webex_bot/pull/62
472
+
473
+ [pr69]: https://github.com/fbradyirl/webex_bot/pull/69
474
+
475
+ [pr71]: https://github.com/fbradyirl/webex_bot/pull/71
476
+
411
477
  [i1]: https://github.com/fbradyirl/webex_bot/issues/1
412
478
 
413
479
  [i2]: https://github.com/fbradyirl/webex_bot/issues/2
@@ -417,5 +483,3 @@ and off you go!
417
483
  [i13]: https://github.com/fbradyirl/webex_bot/issues/13
418
484
 
419
485
  [i20]: https://github.com/fbradyirl/webex_bot/issues/20
420
-
421
-
@@ -0,0 +1,18 @@
1
+ webex_bot/__init__.py,sha256=S5gT3L7JqYWDSwjnLQa_VGARrFqlB4Q6IF_ElUCnWWs,95
2
+ webex_bot/exceptions.py,sha256=qs9yVitfJtvxwBMC8uCvTDOxUQ_oZjWFf1dU8Oaue14,740
3
+ webex_bot/formatting.py,sha256=jvPKym-z8CIJygpPVTVbt6vFXQo9_HQHpRDJB-nh-SI,382
4
+ webex_bot/webex_bot.py,sha256=pLNmcAP7J9ZG9QnEDZLYZJa_y1qtO5vudhT0fAi2stA,21282
5
+ webex_bot/cards/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ webex_bot/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ webex_bot/commands/echo.py,sha256=STY-MikBRjUteDK-g8G4GPB0V-Yi7siPN1DRMXrT-QU,3399
8
+ webex_bot/commands/help.py,sha256=n7sbnJHepNSqUgZ0-8PW37kbGsaqvGIk2-jYy6I7ch4,3470
9
+ webex_bot/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ webex_bot/models/command.py,sha256=MyThlDaEkGlj1fDE_i_wr79O3QboakimRme8yI744yo,5327
11
+ webex_bot/models/response.py,sha256=d4k2ohR5SUVzvuQzcnm7jQQVTMB0gH9Kz9y09vkoAaU,2545
12
+ webex_bot/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ webex_bot/websockets/webex_websocket_client.py,sha256=kYepNP4gK0dddPndtK6ltCg52TYMhMtMHVKkxO15jTs,10618
14
+ webex_bot-0.6.0.dist-info/licenses/LICENSE,sha256=93eGb10xmgkBP2Fh_n0E9YDXe0c0oz-FsnAimXG0S4Y,1072
15
+ webex_bot-0.6.0.dist-info/METADATA,sha256=cOLj7txCMm0F0rwwtSmNb9Vf0T54sO6Jx3U6h--dPC0,14348
16
+ webex_bot-0.6.0.dist-info/WHEEL,sha256=AeO2BvogYWm3eGaHCvhzmUYt8ia7KfURiHzO_1atlys,109
17
+ webex_bot-0.6.0.dist-info/top_level.txt,sha256=q1Y0RtYYinR7oXSwL93cK59c2KN_CbMVca8MLWeF63M,10
18
+ webex_bot-0.6.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,18 +0,0 @@
1
- webex_bot/__init__.py,sha256=fIrggpbtbmnosDI6vwtRg8leUTo8BeJZJZqojDOzZGM,95
2
- webex_bot/exceptions.py,sha256=qs9yVitfJtvxwBMC8uCvTDOxUQ_oZjWFf1dU8Oaue14,740
3
- webex_bot/formatting.py,sha256=jvPKym-z8CIJygpPVTVbt6vFXQo9_HQHpRDJB-nh-SI,382
4
- webex_bot/webex_bot.py,sha256=f4qJeNfl1x-dvFyAxcBrAWTT0HB-pAq0Kl3gfjrXYe0,20473
5
- webex_bot/cards/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- webex_bot/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- webex_bot/commands/echo.py,sha256=YmeRVh56pzsj0_lRHDvgyrv6YqQQdRiusG65dHTh9qU,3397
8
- webex_bot/commands/help.py,sha256=s4buQxnmHijkqWiYs8RZ_H-yzi3EhAffSozPCGNndD0,3468
9
- webex_bot/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- webex_bot/models/command.py,sha256=Rok661eZM2Mg465CZ4GgctWi1RD-BD5Bruq0FsJ8GDQ,5023
11
- webex_bot/models/response.py,sha256=1U0EQv8O5R3-demaumxMExn278DG4AeQHhXP_g4xndk,2544
12
- webex_bot/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- webex_bot/websockets/webex_websocket_client.py,sha256=QUTQUWgnBYg3bSZ857m_vM49Ns9GWHWT69TYP4U6R9I,10627
14
- webex_bot-0.5.1.dist-info/LICENSE,sha256=93eGb10xmgkBP2Fh_n0E9YDXe0c0oz-FsnAimXG0S4Y,1072
15
- webex_bot-0.5.1.dist-info/METADATA,sha256=aSiwp8MqPv55j1njJOpHRCF_FnDiB077O-f_hzKqBhg,11991
16
- webex_bot-0.5.1.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
17
- webex_bot-0.5.1.dist-info/top_level.txt,sha256=q1Y0RtYYinR7oXSwL93cK59c2KN_CbMVca8MLWeF63M,10
18
- webex_bot-0.5.1.dist-info/RECORD,,