Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from "webexteamssdk" library to "webexpythonsdk" library #61

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inside a LAN. This package instead uses a websocket to receive messages from the
* 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
fit in a single response.
* Restrict bot to certain users or domains.
* Uses the [webexteamssdk][2] package to send back replies from the bot.
* Uses the [webexpythonsdk][2] package to send back replies from the bot.

## 🚀 Getting started

Expand All @@ -48,7 +48,7 @@ If you need optional proxy support, use this command instead:
2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.

```sh
export WEBEX_TEAMS_ACCESS_TOKEN=<your bots token>
export WEBEX_ACCESS_TOKEN=<your bots token>
```

3. Run your script:
Expand All @@ -71,7 +71,7 @@ proxies = {
}

# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
bot_name="My Teams Ops Bot",
include_demo_commands=True,
Expand All @@ -89,9 +89,9 @@ where EchoCommand is defined as:
```python
import logging

from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
Text, Image, HorizontalAlignment
from webexteamssdk.models.cards.actions import Submit
from webexpythonsdk.models.cards.actions import Submit

from webex_bot.formatting import quote_info
from webex_bot.models.command import Command
Expand Down Expand Up @@ -370,7 +370,7 @@ and off you go!

[1]: https://github.com/aaugustin/websockets

[2]: https://github.com/CiscoDevNet/webexteamssdk
[2]: https://github.com/WebexCommunity/WebexPythonSDK

[3]: https://developer.webex.com/docs/bots

Expand Down
2 changes: 1 addition & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN"),
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
bot_name="My Teams Ops Bot",
include_demo_commands=True,
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ tox==3.14.0
coverage==4.5.4
Sphinx==1.8.5
twine==1.14.0
webexteamssdk==1.6.1
webexpythonsdk
pytest==4.6.5
pytest-runner==5.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
with open('README.md') as readme_file:
readme = readme_file.read()

requirements = ['webexteamssdk==1.6.1', 'coloredlogs', 'websockets==11.0.3', 'backoff']
requirements = ['webexpythonsdk', 'coloredlogs', 'websockets==11.0.3', 'backoff']

setup_requirements = ['pytest-runner', ]

Expand Down
4 changes: 2 additions & 2 deletions webex_bot/commands/echo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
Text, Image, HorizontalAlignment
from webexteamssdk.models.cards.actions import Submit
from webexpythonsdk.models.cards.actions import Submit

from webex_bot.formatting import quote_info
from webex_bot.models.command import Command
Expand Down
4 changes: 2 additions & 2 deletions webex_bot/commands/help.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
from webexpythonsdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
ImageSize, Image, Fact
from webexteamssdk.models.cards.actions import Submit
from webexpythonsdk.models.cards.actions import Submit

from webex_bot.models.command import Command, COMMAND_KEYWORD_KEY
from webex_bot.models.response import response_from_adaptive_card
Expand Down
4 changes: 2 additions & 2 deletions webex_bot/models/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, command_keyword=None, exact_command_keyword_match=False,
@param chained_commands: (optional) List of other commands related
to this command. This allows multiple related cards to be added at once.
@param card: (deprecated) A dict representation of the JSON card.
Prefer to use cards built in code using the webexteamssdk.models.cards classes
Prefer to use cards built in code using the webexpythonsdk.models.cards classes
(see https://github.com/fbradyirl/webex_bot/blob/main/webex_bot/commands/echo.py for example)
@param help_message: Short description of this command.
@param delete_previous_message: If True, the card which invoked this command will be deleted. (default False)
Expand All @@ -55,7 +55,7 @@ def __init__(self, command_keyword=None, exact_command_keyword_match=False,
if card is not None:
log.warning(f"[{command_keyword}]. Using a card dict is now deprecated. "
f"Switch to use adaptive cards built in code "
"using the webexteamssdk.models.cards classes (see "
"using the webexpythonsdk.models.cards classes (see "
"https://github.com/fbradyirl/webex_bot/blob/main/webex_bot/commands/echo.py for example)")
if 'actions' in card:
if len(card['actions']) > 0:
Expand Down
2 changes: 1 addition & 1 deletion webex_bot/models/response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from webexteamssdk.models.cards import AdaptiveCard
from webexpythonsdk.models.cards import AdaptiveCard


def response_from_adaptive_card(adaptive_card: AdaptiveCard):
Expand Down
6 changes: 3 additions & 3 deletions webex_bot/webex_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import backoff
import coloredlogs
import requests
import webexteamssdk
import webexpythonsdk

from webex_bot.commands.echo import EchoCommand
from webex_bot.commands.help import HelpCommand
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self,
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError)
def get_me_info(self):
"""
Fetch me info from webexteamssdk
Fetch me info from webexpythonsdk
"""
me = self.teams.people.me()
self.bot_display_name = me.displayName
Expand Down Expand Up @@ -168,7 +168,7 @@ def is_user_member_of_room(self, user_email, approved_rooms):
for member in room_members:
if member.personEmail == user_email:
is_user_member = True
except webexteamssdk.exceptions.ApiError as apie:
except webexpythonsdk.exceptions.ApiError as apie:
log.warn(f"API error: {apie}")
return is_user_member

Expand Down
4 changes: 2 additions & 2 deletions webex_bot/websockets/webex_websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import certifi
import requests
import websockets
from webexteamssdk import WebexTeamsAPI
from webexpythonsdk import WebexAPI

try:
from websockets_proxy import Proxy, proxy_connect
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self,
on_card_action=None,
proxies=None):
self.access_token = access_token
self.teams = WebexTeamsAPI(access_token=access_token, proxies=proxies)
self.teams = WebexAPI(access_token=access_token, proxies=proxies)
self.device_url = device_url
self.device_info = None
self.on_message = on_message
Expand Down
Loading