Skip to content

Commit 903b312

Browse files
authored
Migrate from aioslacker to python-slack-sdk (#1280)
1 parent e97a216 commit 903b312

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

demos/moderator_bot/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Model reused from [Moderator AI](https://github.com/aio-libs/aiohttp-demos/tree/
1010

1111
## Requirements
1212
- [aiohttp](https://github.com/aio-libs/aiohttp)
13-
- [aioslacker](https://github.com/aio-libs/aioslacker)
13+
- [slack_sdk](https://github.com/slackapi/python-slack-sdk)
1414

1515

1616
## Prerequisites

demos/moderator_bot/moderator_bot/handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ async def _respond(self, event):
3636
text = (f"Hey <@{event['user']}>, please be polite! "
3737
f"Here is a funny cat GIF for you {image_url}")
3838

39-
await self.slack_client.chat.post_message(
40-
event["channel"],
39+
await self.slack_client.chat_postMessage(
40+
channel=event["channel"],
4141
text=text,
4242
)
4343

demos/moderator_bot/moderator_bot/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
from aiohttp import web
7-
from aioslacker import Slacker
7+
from slack_sdk.web.async_client import AsyncWebClient
88

99
from .giphy import GiphyClient
1010
from .handlers import MainHandler
@@ -38,7 +38,7 @@ async def init_application(config):
3838

3939
executor = ProcessPoolExecutor(MAX_WORKERS)
4040

41-
slack_client = Slacker(SLACK_BOT_TOKEN)
41+
slack_client = AsyncWebClient(SLACK_BOT_TOKEN)
4242
giphy_client = GiphyClient(GIPHY_API_KEY, config["request_timeout"])
4343

4444
handler = MainHandler(executor, slack_client, giphy_client)
@@ -55,7 +55,6 @@ async def init_application(config):
5555

5656
app.on_cleanup.append(setup_cleanup_hooks([
5757
partial(executor.shutdown, wait=True),
58-
slack_client.close,
5958
giphy_client.close,
6059
]))
6160

demos/moderator_bot/requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-i https://pypi.org/simple/
22
aiohttp==3.11.7
3-
aioslacker==0.0.11
43
async-timeout==5.0.1
54
atomicwrites==1.4.1
65
attrs==24.2.0
@@ -19,7 +18,7 @@ pyyaml==6.0.2
1918
scikit-learn==1.5.2
2019
scipy==1.13.1
2120
six==1.16.0
22-
slacker==0.9.42
21+
slack_sdk==3.33.4
2322
urllib3==2.2.3
2423
yarl==1.18.0
2524
zipp==3.21.0

0 commit comments

Comments
 (0)