webex-bot 0.5.1__tar.gz → 0.6.0__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-0.5.1 → webex_bot-0.6.0}/CONTRIBUTING.rst +1 -1
- {webex_bot-0.5.1 → webex_bot-0.6.0}/PKG-INFO +86 -17
- webex_bot-0.5.1/webex_bot.egg-info/PKG-INFO → webex_bot-0.6.0/README.md +60 -31
- {webex_bot-0.5.1 → webex_bot-0.6.0}/setup.cfg +1 -1
- {webex_bot-0.5.1 → webex_bot-0.6.0}/setup.py +7 -5
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/__init__.py +1 -1
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/commands/echo.py +2 -2
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/commands/help.py +2 -2
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/models/command.py +7 -4
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/models/response.py +1 -1
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/webex_bot.py +20 -8
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/websockets/webex_websocket_client.py +2 -2
- webex_bot-0.5.1/README.md → webex_bot-0.6.0/webex_bot.egg-info/PKG-INFO +100 -8
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot.egg-info/requires.txt +1 -1
- {webex_bot-0.5.1 → webex_bot-0.6.0}/LICENSE +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/MANIFEST.in +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/Makefile +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/conf.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/contributing.rst +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/index.rst +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/installation.rst +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/make.bat +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/docs/usage.rst +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/tests/__init__.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/tests/test_webex_bot.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/cards/__init__.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/commands/__init__.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/exceptions.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/formatting.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/models/__init__.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot/websockets/__init__.py +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot.egg-info/SOURCES.txt +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot.egg-info/dependency_links.txt +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot.egg-info/not-zip-safe +0 -0
- {webex_bot-0.5.1 → webex_bot-0.6.0}/webex_bot.egg-info/top_level.txt +0 -0
|
@@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
|
|
|
102
102
|
2. If the pull request adds functionality, the docs should be updated. Put
|
|
103
103
|
your new functionality into a function with a docstring, and add the
|
|
104
104
|
feature to the list in README.rst.
|
|
105
|
-
3. The pull request should work for Python 3.
|
|
105
|
+
3. The pull request should work for Python 3.10, 3.11, 3.12, and 3.13, and for PyPy. Check
|
|
106
106
|
https://travis-ci.com/fbradyirl/webex_bot/pull_requests
|
|
107
107
|
and make sure that the tests pass for all supported Python versions.
|
|
108
108
|
|
|
@@ -1,28 +1,55 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 0.
|
|
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.
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
|
|
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
|
-
Provides-Extra: proxy
|
|
20
20
|
License-File: LICENSE
|
|
21
|
+
Requires-Dist: webexpythonsdk==2.0.4
|
|
22
|
+
Requires-Dist: coloredlogs
|
|
23
|
+
Requires-Dist: websockets==11.0.3
|
|
24
|
+
Requires-Dist: backoff
|
|
25
|
+
Provides-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
|
|
21
40
|
|
|
22
41
|
# Introduction
|
|
23
42
|
|
|
24
43
|
[](https://pypi.python.org/pypi/webex_bot) [](https://github.com/fbradyirl/webex_bot/actions)
|
|
25
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
|
+
|
|
26
53
|
By using this module, you can create a [Webex Teams][5] messaging bot quickly in just a couple of lines of code.
|
|
27
54
|
|
|
28
55
|
This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or
|
|
@@ -36,7 +63,7 @@ inside a LAN. This package instead uses a websocket to receive messages from the
|
|
|
36
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
|
|
37
64
|
fit in a single response.
|
|
38
65
|
* Restrict bot to certain users or domains.
|
|
39
|
-
* Uses the [
|
|
66
|
+
* Uses the [webexpythonsdk][2] package to send back replies from the bot.
|
|
40
67
|
|
|
41
68
|
## 🚀 Getting started
|
|
42
69
|
|
|
@@ -48,7 +75,7 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
|
|
|
48
75
|
|
|
49
76
|
----
|
|
50
77
|
|
|
51
|
-
**Only Python 3.
|
|
78
|
+
**Only Python 3.13 is tested at this time.**
|
|
52
79
|
|
|
53
80
|
1. Install this module from pypi:
|
|
54
81
|
|
|
@@ -61,7 +88,7 @@ If you need optional proxy support, use this command instead:
|
|
|
61
88
|
2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
|
|
62
89
|
|
|
63
90
|
```sh
|
|
64
|
-
export
|
|
91
|
+
export WEBEX_ACCESS_TOKEN=<your bots token>
|
|
65
92
|
```
|
|
66
93
|
|
|
67
94
|
3. Run your script:
|
|
@@ -84,7 +111,7 @@ proxies = {
|
|
|
84
111
|
}
|
|
85
112
|
|
|
86
113
|
# Create a Bot Object
|
|
87
|
-
bot = WebexBot(teams_bot_token=os.getenv("
|
|
114
|
+
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
|
|
88
115
|
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
|
|
89
116
|
bot_name="My Teams Ops Bot",
|
|
90
117
|
include_demo_commands=True,
|
|
@@ -102,9 +129,9 @@ where EchoCommand is defined as:
|
|
|
102
129
|
```python
|
|
103
130
|
import logging
|
|
104
131
|
|
|
105
|
-
from
|
|
132
|
+
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
|
|
106
133
|
Text, Image, HorizontalAlignment
|
|
107
|
-
from
|
|
134
|
+
from webexpythonsdk.models.cards.actions import Submit
|
|
108
135
|
|
|
109
136
|
from webex_bot.formatting import quote_info
|
|
110
137
|
from webex_bot.models.command import Command
|
|
@@ -196,7 +223,8 @@ and off you go!
|
|
|
196
223
|
|
|
197
224
|
# Help
|
|
198
225
|
|
|
199
|
-
* If you are a Cisco employee,
|
|
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].
|
|
200
228
|
* Alternatively, open an issue or PR with a question on usage.
|
|
201
229
|
|
|
202
230
|
# History
|
|
@@ -377,9 +405,42 @@ and off you go!
|
|
|
377
405
|
|
|
378
406
|
* Add Proxy Support. ([#56][pr56])
|
|
379
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
|
+
|
|
380
441
|
[1]: https://github.com/aaugustin/websockets
|
|
381
442
|
|
|
382
|
-
[2]: https://github.com/
|
|
443
|
+
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
383
444
|
|
|
384
445
|
[3]: https://developer.webex.com/docs/bots
|
|
385
446
|
|
|
@@ -391,6 +452,8 @@ and off you go!
|
|
|
391
452
|
|
|
392
453
|
[7]: https://eurl.io/#TeBLqZjLs
|
|
393
454
|
|
|
455
|
+
[8]: https://www.globoforce.net/microsites/t/awards/Redeem?client=cisco&setCAG=true
|
|
456
|
+
|
|
394
457
|
[pr43]: https://github.com/fbradyirl/webex_bot/pull/43
|
|
395
458
|
|
|
396
459
|
[pr46]: https://github.com/fbradyirl/webex_bot/pull/46
|
|
@@ -403,6 +466,14 @@ and off you go!
|
|
|
403
466
|
|
|
404
467
|
[pr56]: https://github.com/fbradyirl/webex_bot/pull/56
|
|
405
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
|
+
|
|
406
477
|
[i1]: https://github.com/fbradyirl/webex_bot/issues/1
|
|
407
478
|
|
|
408
479
|
[i2]: https://github.com/fbradyirl/webex_bot/issues/2
|
|
@@ -412,5 +483,3 @@ and off you go!
|
|
|
412
483
|
[i13]: https://github.com/fbradyirl/webex_bot/issues/13
|
|
413
484
|
|
|
414
485
|
[i20]: https://github.com/fbradyirl/webex_bot/issues/20
|
|
415
|
-
|
|
416
|
-
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: webex-bot
|
|
3
|
-
Version: 0.5.1
|
|
4
|
-
Summary: Python package for a Webex Bot based on websockets.
|
|
5
|
-
Home-page: https://github.com/fbradyirl/webex_bot
|
|
6
|
-
Author: Finbarr Brady
|
|
7
|
-
Author-email: finbarr@somemail.com
|
|
8
|
-
License: MIT license
|
|
9
|
-
Keywords: webex_bot
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Natural Language :: English
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Requires-Python: >=3.8
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
Provides-Extra: proxy
|
|
20
|
-
License-File: LICENSE
|
|
21
|
-
|
|
22
1
|
# Introduction
|
|
23
2
|
|
|
24
3
|
[](https://pypi.python.org/pypi/webex_bot) [](https://github.com/fbradyirl/webex_bot/actions)
|
|
25
4
|
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> This repository is only sporadically maintained. Breaking API changes will be maintained on a best efforts basis.
|
|
7
|
+
>
|
|
8
|
+
> Collaborators are welcome, as are PRs for enhancements.
|
|
9
|
+
>
|
|
10
|
+
> Bug reports unrelated to API changes may not get the attention you want.
|
|
11
|
+
|
|
12
|
+
|
|
26
13
|
By using this module, you can create a [Webex Teams][5] messaging bot quickly in just a couple of lines of code.
|
|
27
14
|
|
|
28
15
|
This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or
|
|
@@ -36,7 +23,7 @@ inside a LAN. This package instead uses a websocket to receive messages from the
|
|
|
36
23
|
* 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
|
|
37
24
|
fit in a single response.
|
|
38
25
|
* Restrict bot to certain users or domains.
|
|
39
|
-
* Uses the [
|
|
26
|
+
* Uses the [webexpythonsdk][2] package to send back replies from the bot.
|
|
40
27
|
|
|
41
28
|
## 🚀 Getting started
|
|
42
29
|
|
|
@@ -48,7 +35,7 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
|
|
|
48
35
|
|
|
49
36
|
----
|
|
50
37
|
|
|
51
|
-
**Only Python 3.
|
|
38
|
+
**Only Python 3.13 is tested at this time.**
|
|
52
39
|
|
|
53
40
|
1. Install this module from pypi:
|
|
54
41
|
|
|
@@ -61,7 +48,7 @@ If you need optional proxy support, use this command instead:
|
|
|
61
48
|
2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
|
|
62
49
|
|
|
63
50
|
```sh
|
|
64
|
-
export
|
|
51
|
+
export WEBEX_ACCESS_TOKEN=<your bots token>
|
|
65
52
|
```
|
|
66
53
|
|
|
67
54
|
3. Run your script:
|
|
@@ -84,7 +71,7 @@ proxies = {
|
|
|
84
71
|
}
|
|
85
72
|
|
|
86
73
|
# Create a Bot Object
|
|
87
|
-
bot = WebexBot(teams_bot_token=os.getenv("
|
|
74
|
+
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
|
|
88
75
|
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
|
|
89
76
|
bot_name="My Teams Ops Bot",
|
|
90
77
|
include_demo_commands=True,
|
|
@@ -102,9 +89,9 @@ where EchoCommand is defined as:
|
|
|
102
89
|
```python
|
|
103
90
|
import logging
|
|
104
91
|
|
|
105
|
-
from
|
|
92
|
+
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
|
|
106
93
|
Text, Image, HorizontalAlignment
|
|
107
|
-
from
|
|
94
|
+
from webexpythonsdk.models.cards.actions import Submit
|
|
108
95
|
|
|
109
96
|
from webex_bot.formatting import quote_info
|
|
110
97
|
from webex_bot.models.command import Command
|
|
@@ -196,7 +183,8 @@ and off you go!
|
|
|
196
183
|
|
|
197
184
|
# Help
|
|
198
185
|
|
|
199
|
-
* If you are a Cisco employee,
|
|
186
|
+
* If you are a Cisco employee, and find this useful, consider sending me a [Connected Recognition][8] (cec: `fibrady`) 🙂
|
|
187
|
+
* Also, join the [discussion space here][7].
|
|
200
188
|
* Alternatively, open an issue or PR with a question on usage.
|
|
201
189
|
|
|
202
190
|
# History
|
|
@@ -377,9 +365,42 @@ and off you go!
|
|
|
377
365
|
|
|
378
366
|
* Add Proxy Support. ([#56][pr56])
|
|
379
367
|
|
|
368
|
+
### 0.5.2 (2024-Aug-21)
|
|
369
|
+
|
|
370
|
+
* Introduce exact_command_keyword_match feature ([#59][pr59])
|
|
371
|
+
|
|
372
|
+
### 0.6.0 (2025-Apr-24)
|
|
373
|
+
|
|
374
|
+
* Migrate from "webexteamssdk" library to "webexpythonsdk" library ([#62][pr62])
|
|
375
|
+
* Updated webexpythonsdk library version ([#69][pr69])
|
|
376
|
+
* Added support for generators ([#71][pr71])
|
|
377
|
+
|
|
378
|
+
#### Breaking changes for the existing webex_bot based applications:
|
|
379
|
+
|
|
380
|
+
* Support is limited to only Python 3.10+ versions. webex_bot applications running on lower Python versions will have to
|
|
381
|
+
adapt to this change in Python version requirement.
|
|
382
|
+
* Make the following code changes to your webex_bot application to adapt to ```webex_bot 0.6.0 version and upwards```.
|
|
383
|
+
|
|
384
|
+
1. ***Mandatory step:*** Replace all imports from `webexteamssdk` to `webexpythonsdk`. For example:
|
|
385
|
+
```
|
|
386
|
+
from webexteamssdk.models.cards import TextBlock
|
|
387
|
+
```
|
|
388
|
+
to
|
|
389
|
+
```
|
|
390
|
+
from webexpythonsdk.models.cards import TextBlock\
|
|
391
|
+
```
|
|
392
|
+
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:
|
|
393
|
+
```
|
|
394
|
+
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN")
|
|
395
|
+
```
|
|
396
|
+
to
|
|
397
|
+
```
|
|
398
|
+
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
399
|
+
```
|
|
400
|
+
|
|
380
401
|
[1]: https://github.com/aaugustin/websockets
|
|
381
402
|
|
|
382
|
-
[2]: https://github.com/
|
|
403
|
+
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
383
404
|
|
|
384
405
|
[3]: https://developer.webex.com/docs/bots
|
|
385
406
|
|
|
@@ -391,6 +412,8 @@ and off you go!
|
|
|
391
412
|
|
|
392
413
|
[7]: https://eurl.io/#TeBLqZjLs
|
|
393
414
|
|
|
415
|
+
[8]: https://www.globoforce.net/microsites/t/awards/Redeem?client=cisco&setCAG=true
|
|
416
|
+
|
|
394
417
|
[pr43]: https://github.com/fbradyirl/webex_bot/pull/43
|
|
395
418
|
|
|
396
419
|
[pr46]: https://github.com/fbradyirl/webex_bot/pull/46
|
|
@@ -403,6 +426,14 @@ and off you go!
|
|
|
403
426
|
|
|
404
427
|
[pr56]: https://github.com/fbradyirl/webex_bot/pull/56
|
|
405
428
|
|
|
429
|
+
[pr59]: https://github.com/fbradyirl/webex_bot/pull/59
|
|
430
|
+
|
|
431
|
+
[pr62]: https://github.com/fbradyirl/webex_bot/pull/62
|
|
432
|
+
|
|
433
|
+
[pr69]: https://github.com/fbradyirl/webex_bot/pull/69
|
|
434
|
+
|
|
435
|
+
[pr71]: https://github.com/fbradyirl/webex_bot/pull/71
|
|
436
|
+
|
|
406
437
|
[i1]: https://github.com/fbradyirl/webex_bot/issues/1
|
|
407
438
|
|
|
408
439
|
[i2]: https://github.com/fbradyirl/webex_bot/issues/2
|
|
@@ -412,5 +443,3 @@ and off you go!
|
|
|
412
443
|
[i13]: https://github.com/fbradyirl/webex_bot/issues/13
|
|
413
444
|
|
|
414
445
|
[i20]: https://github.com/fbradyirl/webex_bot/issues/20
|
|
415
|
-
|
|
416
|
-
|
|
@@ -7,7 +7,7 @@ from setuptools import setup, find_packages
|
|
|
7
7
|
with open('README.md') as readme_file:
|
|
8
8
|
readme = readme_file.read()
|
|
9
9
|
|
|
10
|
-
requirements = ['
|
|
10
|
+
requirements = ['webexpythonsdk==2.0.4', 'coloredlogs', 'websockets==11.0.3', 'backoff']
|
|
11
11
|
|
|
12
12
|
setup_requirements = ['pytest-runner', ]
|
|
13
13
|
|
|
@@ -20,14 +20,16 @@ extras_requirements = {
|
|
|
20
20
|
setup(
|
|
21
21
|
author="Finbarr Brady",
|
|
22
22
|
author_email='finbarr@somemail.com',
|
|
23
|
-
python_requires='>=3.
|
|
23
|
+
python_requires='>=3.10',
|
|
24
24
|
classifiers=[
|
|
25
25
|
'Development Status :: 2 - Pre-Alpha',
|
|
26
26
|
'Intended Audience :: Developers',
|
|
27
27
|
'License :: OSI Approved :: MIT License',
|
|
28
28
|
'Natural Language :: English',
|
|
29
|
-
'Programming Language :: Python :: 3.
|
|
30
|
-
'Programming Language :: Python :: 3.
|
|
29
|
+
'Programming Language :: Python :: 3.10',
|
|
30
|
+
'Programming Language :: Python :: 3.11',
|
|
31
|
+
'Programming Language :: Python :: 3.12',
|
|
32
|
+
'Programming Language :: Python :: 3.13',
|
|
31
33
|
],
|
|
32
34
|
description="Python package for a Webex Bot based on websockets.",
|
|
33
35
|
extras_require=extras_requirements,
|
|
@@ -43,6 +45,6 @@ setup(
|
|
|
43
45
|
test_suite='tests',
|
|
44
46
|
tests_require=test_requirements,
|
|
45
47
|
url='https://github.com/fbradyirl/webex_bot',
|
|
46
|
-
version='0.
|
|
48
|
+
version='0.6.0',
|
|
47
49
|
zip_safe=False,
|
|
48
50
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
|
|
4
4
|
Text, Image, HorizontalAlignment
|
|
5
|
-
from
|
|
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
|
|
3
|
+
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
|
|
4
4
|
ImageSize, Image, Fact
|
|
5
|
-
from
|
|
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,
|
|
13
|
-
|
|
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
|
|
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
|
|
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:
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
|
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 =
|
|
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,7 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: webex_bot
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Python package for a Webex Bot based on websockets.
|
|
5
|
+
Home-page: https://github.com/fbradyirl/webex_bot
|
|
6
|
+
Author: Finbarr Brady
|
|
7
|
+
Author-email: finbarr@somemail.com
|
|
8
|
+
License: MIT license
|
|
9
|
+
Keywords: webex_bot
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
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
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: webexpythonsdk==2.0.4
|
|
22
|
+
Requires-Dist: coloredlogs
|
|
23
|
+
Requires-Dist: websockets==11.0.3
|
|
24
|
+
Requires-Dist: backoff
|
|
25
|
+
Provides-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
|
|
40
|
+
|
|
1
41
|
# Introduction
|
|
2
42
|
|
|
3
43
|
[](https://pypi.python.org/pypi/webex_bot) [](https://github.com/fbradyirl/webex_bot/actions)
|
|
4
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
|
+
|
|
5
53
|
By using this module, you can create a [Webex Teams][5] messaging bot quickly in just a couple of lines of code.
|
|
6
54
|
|
|
7
55
|
This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or
|
|
@@ -15,7 +63,7 @@ inside a LAN. This package instead uses a websocket to receive messages from the
|
|
|
15
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
|
|
16
64
|
fit in a single response.
|
|
17
65
|
* Restrict bot to certain users or domains.
|
|
18
|
-
* Uses the [
|
|
66
|
+
* Uses the [webexpythonsdk][2] package to send back replies from the bot.
|
|
19
67
|
|
|
20
68
|
## 🚀 Getting started
|
|
21
69
|
|
|
@@ -27,7 +75,7 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
|
|
|
27
75
|
|
|
28
76
|
----
|
|
29
77
|
|
|
30
|
-
**Only Python 3.
|
|
78
|
+
**Only Python 3.13 is tested at this time.**
|
|
31
79
|
|
|
32
80
|
1. Install this module from pypi:
|
|
33
81
|
|
|
@@ -40,7 +88,7 @@ If you need optional proxy support, use this command instead:
|
|
|
40
88
|
2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
|
|
41
89
|
|
|
42
90
|
```sh
|
|
43
|
-
export
|
|
91
|
+
export WEBEX_ACCESS_TOKEN=<your bots token>
|
|
44
92
|
```
|
|
45
93
|
|
|
46
94
|
3. Run your script:
|
|
@@ -63,7 +111,7 @@ proxies = {
|
|
|
63
111
|
}
|
|
64
112
|
|
|
65
113
|
# Create a Bot Object
|
|
66
|
-
bot = WebexBot(teams_bot_token=os.getenv("
|
|
114
|
+
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
|
|
67
115
|
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
|
|
68
116
|
bot_name="My Teams Ops Bot",
|
|
69
117
|
include_demo_commands=True,
|
|
@@ -81,9 +129,9 @@ where EchoCommand is defined as:
|
|
|
81
129
|
```python
|
|
82
130
|
import logging
|
|
83
131
|
|
|
84
|
-
from
|
|
132
|
+
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
|
|
85
133
|
Text, Image, HorizontalAlignment
|
|
86
|
-
from
|
|
134
|
+
from webexpythonsdk.models.cards.actions import Submit
|
|
87
135
|
|
|
88
136
|
from webex_bot.formatting import quote_info
|
|
89
137
|
from webex_bot.models.command import Command
|
|
@@ -175,7 +223,8 @@ and off you go!
|
|
|
175
223
|
|
|
176
224
|
# Help
|
|
177
225
|
|
|
178
|
-
* If you are a Cisco employee,
|
|
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].
|
|
179
228
|
* Alternatively, open an issue or PR with a question on usage.
|
|
180
229
|
|
|
181
230
|
# History
|
|
@@ -356,9 +405,42 @@ and off you go!
|
|
|
356
405
|
|
|
357
406
|
* Add Proxy Support. ([#56][pr56])
|
|
358
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
|
+
|
|
359
441
|
[1]: https://github.com/aaugustin/websockets
|
|
360
442
|
|
|
361
|
-
[2]: https://github.com/
|
|
443
|
+
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
362
444
|
|
|
363
445
|
[3]: https://developer.webex.com/docs/bots
|
|
364
446
|
|
|
@@ -370,6 +452,8 @@ and off you go!
|
|
|
370
452
|
|
|
371
453
|
[7]: https://eurl.io/#TeBLqZjLs
|
|
372
454
|
|
|
455
|
+
[8]: https://www.globoforce.net/microsites/t/awards/Redeem?client=cisco&setCAG=true
|
|
456
|
+
|
|
373
457
|
[pr43]: https://github.com/fbradyirl/webex_bot/pull/43
|
|
374
458
|
|
|
375
459
|
[pr46]: https://github.com/fbradyirl/webex_bot/pull/46
|
|
@@ -382,6 +466,14 @@ and off you go!
|
|
|
382
466
|
|
|
383
467
|
[pr56]: https://github.com/fbradyirl/webex_bot/pull/56
|
|
384
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
|
+
|
|
385
477
|
[i1]: https://github.com/fbradyirl/webex_bot/issues/1
|
|
386
478
|
|
|
387
479
|
[i2]: https://github.com/fbradyirl/webex_bot/issues/2
|
|
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
|