Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 25 days 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 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T08:47:08.000Z (12 months ago)
- Last Synced: 2024-09-30T13:23:20.426Z (about 1 month 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: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![PyPI](https://img.shields.io/pypi/v/wsslack.py)
![PyPI - License](https://img.shields.io/pypi/l/wsslack.py)
![PyPI - Downloads](https://img.shields.io/pypi/dm/wsslack.py)# 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 slackclient = 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_message](https://gyazo.com/cb37b7c67015f0f37a28d0d945dad3c4.png)### **on_channel_create**
![on_channel_create](https://gyazo.com/40bec93c03343e43dee2180075716d39.png)## Commands usage.
New style of messaging.
If you use app with commands..```python
from slack import commandsbot = 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!")
```![msg](https://gyazo.com/38adfa4b18775e894d8c6f47d17d62f3.png)
![ping](https://gyazo.com/0f68ed0f4a125a2220782d703de0f24f.png)