https://github.com/peco2282/slack.py
An API wrapper for slack written in Python.
https://github.com/peco2282/slack.py
asyncio bot python3 slack slack-api slack-bot slackbot
Last synced: 5 months ago
JSON representation
An API wrapper for slack written in Python.
- Host: GitHub
- URL: https://github.com/peco2282/slack.py
- Owner: peco2282
- License: mit
- Created: 2022-10-07T11:02:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T08:47:08.000Z (about 2 years ago)
- Last Synced: 2025-05-15T15:14:25.004Z (6 months ago)
- Topics: asyncio, bot, python3, slack, slack-api, slack-bot, slackbot
- Language: Python
- Homepage: https://slack-py.readthedocs.io/en/latest/
- Size: 526 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README



# An API wrapper with Slack written in Python.
## Key feature
- Modern Pythonic API using `async` and `await`.
- API and interactive components of the platform by utilizing websockets.
[//]: # (:warning: This is an alpha version.)
## Document for slack.py
- [**Startup**](https://slack-py.readthedocs.io/en/latest/startup.html)
- [**Core API**](https://slack-py.readthedocs.io/en/latest/api/index.html)
- [**Command extention**](https://slack-py.readthedocs.io/en/latest/commands/index.html)
## How to install
:warning: If you have `slack_bolt` installed, you cannot import this package. You may have file conflicts.
```shell
# stable
$ pip install wsslack.py
# latest
$ pip install git+https://github.com/peco2282/slack.py
```
## [Example](https://github.com/peco2282/slack.py/tree/main/examples)
#### [Event References](https://slack-py.readthedocs.io/en/latest/api/events.html)
```python
import slack
client = slack.Client(
user_token="...",
bot_token="...",
token="..."
)
@client.event
async def on_message(message: slack.Message):
if message.content.startswith("!"):
await message.channel.send("Hello.")
@client.event
async def on_channel_create(channel: slack.Channel):
await channel.send("Hello!")
client.run()
```
### **on_message**

### **on_channel_create**

## Commands usage.
New style of messaging.
If you use app with commands..
```python
from slack import commands
bot = commands.Bot(..., prefix="!")
@bot.command(name="msg")
async def message(ctx: commands.Context, *args):
await ctx.channel.send("message received!")
@bot.command()
async def ping(ctx: commands.Context, *args):
await ctx.channel.send("pong!")
```

