Skip to main content

An APIwrapper for slack with python.

Project description

PyPI PyPI - License PyPI - Downloads

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.

Document for slack.py

How to install

:warning: If you have slack_bolt installed, you cannot import this package. You may have file conflicts.

# stable
$ pip install wsslack.py

# latest
$ pip install git+https://github.com/peco2282/slack.py

Example

Event References

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_message

on_channel_create

on_channel_create

Commands usage.

New style of messaging. If you use app with commands..

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!")

msg

ping

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsslack.py-1.4.4.tar.gz (33.0 kB view hashes)

Uploaded Source

Built Distribution

wsslack.py-1.4.4-py3-none-any.whl (43.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page