slackclient


Nameslackclient JSON
Version 2.9.4 PyPI version JSON
download
home_pagehttps://github.com/slackapi/python-slack-sdk
SummarySlack API clients for Web API and RTM API (Legacy) - Please use https://pypi.org/project/slack-sdk/ instead.
upload_time2022-04-22 00:25:53
maintainer
docs_urlNone
authorSlack Technologies, LLC
requires_python>=3.6.0
licenseMIT
keywords slack slack-web slack-rtm chat chatbots bots chatops
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python slackclient

## Important Notice

**This [`slackclient`](https://pypi.org/project/slackclient/) PyPI project is in maintenance mode now** and [`slack-sdk`](https://pypi.org/project/slack-sdk/) project is the successor. The v3 SDK provides more functionalities such as Socket Mode, OAuth flow module, SCIM API, Audit Logs API, better asyncio support, retry handlers, and many more.

Refer to [the migration guide](https://slack.dev/python-slack-sdk/v3-migration/index.html#from-slackclient-2-x) to learn how to smoothly migrate your existing code.

## Overview

The Python `slackclient` library is a developer kit for interfacing with the Slack Web API and Real Time Messaging (RTM) API on Python 3.6 and above.

**Comprehensive documentation on using the Slack Python can be found at [https://slack.dev/python-slackclient/](https://slack.dev/python-slackclient/)**

Whether you're building a custom app for your team, or integrating a third party service into your Slack workflows, Slack Developer Kit for Python allows you to leverage the flexibility of Python to get your project up and running as quickly as possible.

The **Python slackclient** allows interaction with:

- The Slack web api methods available at our [Api Docs site][api-methods]
- Interaction with our [RTM API][rtm-docs]

If you want to use our [Events API][events-docs] and Interactivity features, please check the [Bolt for Python][bolt-python] library. Details on the Tokens and Authentication can be found in our [Auth Guide](https://slack.dev/python-slack-sdk/installation/).

Details on the Tokens and Authentication can be found in our [Auth Guide](https://slack.dev/python-slackclient/auth.html).

## Table of contents

* [Requirements](#requirements)
* [Installation](#installation)
* [Getting started tutorial](#getting-started-tutorial)
* [Basic Usage of the Web Client](#basic-usage-of-the-web-client)
  * [Sending a message to Slack](#sending-a-message-to-slack)
  * [Uploading files to Slack](#uploading-files-to-slack)
* [Basic Usage of the RTM Client](#basic-usage-of-the-rtm-client)
* [Async usage](#async-usage)
  * [Slackclient as a script](#slackclient-as-a-script)
  * [Slackclient in a framework](#slackclient-in-a-framework)
* [Advanced Options](#advanced-options)
  * [SSL](#ssl)
  * [Proxy](#proxy)
  * [DNS performance](#dns-performance)
  * [Example](#example)
* [Migrating from v1](#migrating-from-v1)
* [Support](#support)

### Requirements

---

This library requires Python 3.6 and above. If you require Python 2, please use our [SlackClient - v1.x][slackclientv1]. If you're unsure how to check what version of Python you're on, you can check it using the following:

> **Note:** You may need to use `python3` before your commands to ensure you use the correct Python path. e.g. `python3 --version`

```bash
python --version

-- or --

python3 --version
```

### Installation

We recommend using [PyPI][pypi] to install the Slack Developer Kit for Python.

```bash
$ pip3 install slackclient
```

### Getting started tutorial

---

We've created this [tutorial](/tutorial) to build a basic Slack app in less than 10 minutes. It requires some general programming knowledge, and Python basics. It focuses on the interacting with Slack's Web and RTM API. Use it to give you an idea of how to use this SDK.

**[Read the tutorial to get started!](/tutorial)**

### Basic Usage of the Web Client

---

Slack provide a Web API that gives you the ability to build applications that interact with Slack in a variety of ways. This Development Kit is a module based wrapper that makes interaction with that API easier. We have a basic example here with some of the more common uses but a full list of the available methods are available [here][api-methods]. More detailed examples can be found in our [Basic Usage](https://slack.dev/python-slackclient/basic_usage.html) guide.

#### Sending a message to Slack

One of the most common use-cases is sending a message to Slack. If you want to send a message as your app, or as a user, this method can do both. In our examples, we specify the channel name, however it is recommended to use the `channel_id` where possible. Also, if your app's bot user is not in a channel yet, invite the bot user before running the code snippet (or add `chat:write.public` to Bot Token Scopes for posting in any public channels).

```python
import os
from slack import WebClient
from slack.errors import SlackApiError

client = WebClient(token=os.environ['SLACK_API_TOKEN'])

try:
    response = client.chat_postMessage(
        channel='#random',
        text="Hello world!")
    assert response["message"]["text"] == "Hello world!"
except SlackApiError as e:
    # You will get a SlackApiError if "ok" is False
    assert e.response["ok"] is False
    assert e.response["error"]  # str like 'invalid_auth', 'channel_not_found'
    print(f"Got an error: {e.response['error']}")
```

Here we also ensure that the response back from Slack is a successful one and that the message is the one we sent by using the `assert` statement.

#### Uploading files to Slack

We've changed the process for uploading files to Slack to be much easier and straight forward. You can now just include a path to the file directly in the API call and upload it that way. You can find the details on this api call [here][files.upload]

```python
import os
from slack import WebClient
from slack.errors import SlackApiError

client = WebClient(token=os.environ['SLACK_API_TOKEN'])

try:
    filepath="./tmp.txt"
    response = client.files_upload(
        channels='#random',
        file=filepath)
    assert response["file"]  # the uploaded file
except SlackApiError as e:
    # You will get a SlackApiError if "ok" is False
    assert e.response["ok"] is False
    assert e.response["error"]  # str like 'invalid_auth', 'channel_not_found'
    print(f"Got an error: {e.response['error']}")
```

### Basic Usage of the RTM Client

---

The [Real Time Messaging (RTM) API][rtm-docs] is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users.

If you prefer events to be pushed to you instead, we recommend using the HTTP-based [Events API][events-docs] instead. Most event types supported by the RTM API are also available in the Events API. You can check out our [Python Slack Events Adaptor][events-sdk] if you want to use this API instead.

An RTMClient allows apps to communicate with the Slack Platform's RTM API.

The event-driven architecture of this client allows you to simply link callbacks to their corresponding events. When an event occurs this client executes your callback while passing along any information it receives. We also give you the ability to call our web client from inside your callbacks.

In our example below, we watch for a [message event][message-event] that contains "Hello" and if its received, we call the `say_hello()` function. We then issue a call to the web client to post back to the channel saying "Hi" to the user.

```python
import os
from slack import RTMClient
from slack.errors import SlackApiError

@RTMClient.run_on(event='message')
def say_hello(**payload):
    data = payload['data']
    web_client = payload['web_client']
    rtm_client = payload['rtm_client']
    if 'text' in data and 'Hello' in data.get('text', []):
        channel_id = data['channel']
        thread_ts = data['ts']
        user = data['user']

        try:
            response = web_client.chat_postMessage(
                channel=channel_id,
                text=f"Hi <@{user}>!",
                thread_ts=thread_ts
            )
        except SlackApiError as e:
            # You will get a SlackApiError if "ok" is False
            assert e.response["ok"] is False
            assert e.response["error"]  # str like 'invalid_auth', 'channel_not_found'
            print(f"Got an error: {e.response['error']}")

rtm_client = RTMClient(token=os.environ["SLACK_API_TOKEN"])
rtm_client.start()
```

Please note that the default way of creating Slack apps no longer supports RTM API. Events using the RTM API **must** use a classic Slack app (with a plain `bot` scope).

If you already have a classic Slack app, you can use those credentials. If you don't and need to use the RTM API, you can create a classic Slack app from [this link](https://api.slack.com/apps?new_classic_app=1). You can learn more in the [API documentation](https://api.slack.com/authentication/basics#soon).

Also, even if the Slack app configuration pages encourage you to upgrade to the newer permission model, don't upgrade it and keep using the "classic" bot permission.

### Async usage

slackclient v2 and higher uses [AIOHttp][aiohttp] under the hood for asynchronous requests and [urllib][urllib] for synchronous requests.

Normal usage of the library does not run it in async, hence a kwarg of `run_async=True` is needed.

When in async mode its important to remember to await or run/run_until_complete the call.

#### Slackclient as a script

```python
import asyncio
import os
from slack import WebClient
from slack.errors import SlackApiError

client = WebClient(
    token=os.environ['SLACK_API_TOKEN'],
    run_async=True
)
future = client.chat_postMessage(
    channel='#random',
    text="Hello world!"
)

loop = asyncio.get_event_loop()
try:
    # run_until_complete returns the Future's result, or raise its exception.
    response = loop.run_until_complete(future)
    assert response["message"]["text"] == "Hello world!"
except SlackApiError as e:
    assert e.response["ok"] is False
    assert e.response["error"]  # str like 'invalid_auth', 'channel_not_found'
    print(f"Got an error: {e.response['error']}")
finally:
    loop.close()
```

#### Slackclient in a framework

If you are using a framework invoking the asyncio event loop like : sanic/jupyter notebook/etc.

```python
import os
from slack import WebClient
from slack.errors import SlackApiError

client = WebClient(
    token=os.environ['SLACK_API_TOKEN'],
    run_async=True # turn async mode on
)
# Define this as an async function
async def send_to_slack(channel, text):
    try:
        # Don't forget to have await as the client returns asyncio.Future
        response = await client.chat_postMessage(
            channel=channel,
            text=text
        )
        assert response["message"]["text"] == text
    except SlackApiError as e:
        assert e.response["ok"] is False
        assert e.response["error"]  # str like 'invalid_auth', 'channel_not_found'
        raise e

# https://sanicframework.org/
from sanic import Sanic
from sanic.response import json

app = Sanic()
# e.g., http://localhost:3000/?text=foo&text=bar
@app.route('/')
async def test(request):
    text = 'Hello World!'
    if 'text' in request.args:
        text = "\t".join(request.args['text'])
    try:
        await send_to_slack(channel="#random", text=text)
        return json({'message': 'Done!'})
    except SlackApiError as e:
        return json({'message': f"Failed due to {e.response['error']}"})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=3000)
```

### Advanced Options

#### SSL

You can provide a custom SSL context or disable verification by passing the `ssl` option, supported by both the RTM and the Web client.

For async requests, see the [AIOHttp SSL documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#ssl-control-for-tcp-sockets).

For sync requests, see the [urllib SSL documentation](https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen).

#### Proxy

A proxy is supported when making async requests, pass the `proxy` option, supported by both the RTM and the Web client.

For async requests, see [AIOHttp Proxy documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support).

For sync requests, setting either `HTTPS_PROXY` env variable or the `proxy` option works.

#### DNS performance

Using the async client and looking for a performance boost? Installing the optional dependencies (aiodns) may help speed up DNS resolving by the client. We've included it as an extra called "optional":
```bash
$ pip3 install slackclient[optional]
```

#### Example

```python
import os
from slack import WebClient
from ssl import SSLContext

sslcert = SSLContext()
# pip3 install proxy.py
# proxy --port 9000 --log-level d
proxyinfo = "http://localhost:9000"

client = WebClient(
    token=os.environ['SLACK_API_TOKEN'],
    ssl=sslcert,
    proxy=proxyinfo
)
response = client.chat_postMessage(
    channel="#random",
    text="Hello World!")
print(response)
```


### Migrating from v1

---

If you're migrating from v1.x of slackclient to v2.x, Please follow our migration guide to ensure your app continues working after updating.

**[Check out the Migration Guide here!](https://github.com/slackapi/python-slackclient/wiki/Migrating-to-2.x)**

### Support

---

We no longer provide support for v1 or v2 of this SDK and only maintain the latest v3 version. If you would like support from this project's maintainers please consider updating to the latest version of the SDK first. Otherwise, you may visit the [Slack Community][slack-community] for getting help using Slack Developer Kit for Python or just generally bond with your fellow Slack developers.

<!-- Markdown links -->

[pypi-image]: https://badge.fury.io/py/slackclient.svg
[pypi-url]: https://pypi.python.org/pypi/slackclient
[travis-image]: https://travis-ci.org/slackapi/python-slackclient.svg?branch=main
[travis-url]: https://travis-ci.org/slackapi/python-slackclient
[python-version]: https://img.shields.io/pypi/pyversions/slackclient.svg
[codecov-image]: https://codecov.io/gh/slackapi/python-slackclient/branch/main/graph/badge.svg
[codecov-url]: https://codecov.io/gh/slackapi/python-slackclient
[contact-image]: https://img.shields.io/badge/contact-support-green.svg
[contact-url]: https://slack.com/support
[api-docs]: https://api.slack.com
[slackclientv1]: https://github.com/slackapi/python-slackclient/tree/v1
[api-methods]: https://api.slack.com/methods
[rtm-docs]: https://api.slack.com/rtm
[events-docs]: https://api.slack.com/events-api
[events-sdk]: https://github.com/slackapi/python-slack-events-api
[message-event]: https://api.slack.com/events/message
[python-slack-events-api]: https://github.com/slackapi/python-slack-events-api
[pypi]: https://pypi.python.org/pypi
[pipenv]: https://pypi.org/project/pipenv/
[gh-issues]: https://github.com/slackapi/python-slackclient/issues
[slack-community]: http://slackcommunity.com/
[dev-roadmap]: https://github.com/slackapi/python-slackclient/wiki/Slack-Python-SDK-Roadmap
[migration-guide]: documentation_v2/Migration.md
[files.upload]: https://api.slack.com/methods/files.upload
[auth-guide]: documentation_v2/auth.md
[basic-usage]: documentation_v2/basic_usage.md
[aiohttp]: https://aiohttp.readthedocs.io/
[urllib]: https://docs.python.org/3/library/urllib.request.html



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/slackapi/python-slack-sdk",
    "name": "slackclient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.0",
    "maintainer_email": "",
    "keywords": "slack slack-web slack-rtm chat chatbots bots chatops",
    "author": "Slack Technologies, LLC",
    "author_email": "opensource@slack.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/c4/f147d5602b060f76555688bc0d88d30c814b827602874c589674db46daeb/slackclient-2.9.4.tar.gz",
    "platform": null,
    "description": "# Python slackclient\n\n## Important Notice\n\n**This [`slackclient`](https://pypi.org/project/slackclient/) PyPI project is in maintenance mode now** and [`slack-sdk`](https://pypi.org/project/slack-sdk/) project is the successor. The v3 SDK provides more functionalities such as Socket Mode, OAuth flow module, SCIM API, Audit Logs API, better asyncio support, retry handlers, and many more.\n\nRefer to [the migration guide](https://slack.dev/python-slack-sdk/v3-migration/index.html#from-slackclient-2-x) to learn how to smoothly migrate your existing code.\n\n## Overview\n\nThe Python `slackclient` library is a developer kit for interfacing with the Slack Web API and Real Time Messaging (RTM) API on Python 3.6 and above.\n\n**Comprehensive documentation on using the Slack Python can be found at [https://slack.dev/python-slackclient/](https://slack.dev/python-slackclient/)**\n\nWhether you're building a custom app for your team, or integrating a third party service into your Slack workflows, Slack Developer Kit for Python allows you to leverage the flexibility of Python to get your project up and running as quickly as possible.\n\nThe **Python slackclient** allows interaction with:\n\n- The Slack web api methods available at our [Api Docs site][api-methods]\n- Interaction with our [RTM API][rtm-docs]\n\nIf you want to use our [Events API][events-docs] and Interactivity features, please check the [Bolt for Python][bolt-python] library. Details on the Tokens and Authentication can be found in our [Auth Guide](https://slack.dev/python-slack-sdk/installation/).\n\nDetails on the Tokens and Authentication can be found in our [Auth Guide](https://slack.dev/python-slackclient/auth.html).\n\n## Table of contents\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Getting started tutorial](#getting-started-tutorial)\n* [Basic Usage of the Web Client](#basic-usage-of-the-web-client)\n  * [Sending a message to Slack](#sending-a-message-to-slack)\n  * [Uploading files to Slack](#uploading-files-to-slack)\n* [Basic Usage of the RTM Client](#basic-usage-of-the-rtm-client)\n* [Async usage](#async-usage)\n  * [Slackclient as a script](#slackclient-as-a-script)\n  * [Slackclient in a framework](#slackclient-in-a-framework)\n* [Advanced Options](#advanced-options)\n  * [SSL](#ssl)\n  * [Proxy](#proxy)\n  * [DNS performance](#dns-performance)\n  * [Example](#example)\n* [Migrating from v1](#migrating-from-v1)\n* [Support](#support)\n\n### Requirements\n\n---\n\nThis library requires Python 3.6 and above. If you require Python 2, please use our [SlackClient - v1.x][slackclientv1]. If you're unsure how to check what version of Python you're on, you can check it using the following:\n\n> **Note:** You may need to use `python3` before your commands to ensure you use the correct Python path. e.g. `python3 --version`\n\n```bash\npython --version\n\n-- or --\n\npython3 --version\n```\n\n### Installation\n\nWe recommend using [PyPI][pypi] to install the Slack Developer Kit for Python.\n\n```bash\n$ pip3 install slackclient\n```\n\n### Getting started tutorial\n\n---\n\nWe've created this [tutorial](/tutorial) to build a basic Slack app in less than 10 minutes. It requires some general programming knowledge, and Python basics. It focuses on the interacting with Slack's Web and RTM API. Use it to give you an idea of how to use this SDK.\n\n**[Read the tutorial to get started!](/tutorial)**\n\n### Basic Usage of the Web Client\n\n---\n\nSlack provide a Web API that gives you the ability to build applications that interact with Slack in a variety of ways. This Development Kit is a module based wrapper that makes interaction with that API easier. We have a basic example here with some of the more common uses but a full list of the available methods are available [here][api-methods]. More detailed examples can be found in our [Basic Usage](https://slack.dev/python-slackclient/basic_usage.html) guide.\n\n#### Sending a message to Slack\n\nOne of the most common use-cases is sending a message to Slack. If you want to send a message as your app, or as a user, this method can do both. In our examples, we specify the channel name, however it is recommended to use the `channel_id` where possible. Also, if your app's bot user is not in a channel yet, invite the bot user before running the code snippet (or add `chat:write.public` to Bot Token Scopes for posting in any public channels).\n\n```python\nimport os\nfrom slack import WebClient\nfrom slack.errors import SlackApiError\n\nclient = WebClient(token=os.environ['SLACK_API_TOKEN'])\n\ntry:\n    response = client.chat_postMessage(\n        channel='#random',\n        text=\"Hello world!\")\n    assert response[\"message\"][\"text\"] == \"Hello world!\"\nexcept SlackApiError as e:\n    # You will get a SlackApiError if \"ok\" is False\n    assert e.response[\"ok\"] is False\n    assert e.response[\"error\"]  # str like 'invalid_auth', 'channel_not_found'\n    print(f\"Got an error: {e.response['error']}\")\n```\n\nHere we also ensure that the response back from Slack is a successful one and that the message is the one we sent by using the `assert` statement.\n\n#### Uploading files to Slack\n\nWe've changed the process for uploading files to Slack to be much easier and straight forward. You can now just include a path to the file directly in the API call and upload it that way. You can find the details on this api call [here][files.upload]\n\n```python\nimport os\nfrom slack import WebClient\nfrom slack.errors import SlackApiError\n\nclient = WebClient(token=os.environ['SLACK_API_TOKEN'])\n\ntry:\n    filepath=\"./tmp.txt\"\n    response = client.files_upload(\n        channels='#random',\n        file=filepath)\n    assert response[\"file\"]  # the uploaded file\nexcept SlackApiError as e:\n    # You will get a SlackApiError if \"ok\" is False\n    assert e.response[\"ok\"] is False\n    assert e.response[\"error\"]  # str like 'invalid_auth', 'channel_not_found'\n    print(f\"Got an error: {e.response['error']}\")\n```\n\n### Basic Usage of the RTM Client\n\n---\n\nThe [Real Time Messaging (RTM) API][rtm-docs] is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users.\n\nIf you prefer events to be pushed to you instead, we recommend using the HTTP-based [Events API][events-docs] instead. Most event types supported by the RTM API are also available in the Events API. You can check out our [Python Slack Events Adaptor][events-sdk] if you want to use this API instead.\n\nAn RTMClient allows apps to communicate with the Slack Platform's RTM API.\n\nThe event-driven architecture of this client allows you to simply link callbacks to their corresponding events. When an event occurs this client executes your callback while passing along any information it receives. We also give you the ability to call our web client from inside your callbacks.\n\nIn our example below, we watch for a [message event][message-event] that contains \"Hello\" and if its received, we call the `say_hello()` function. We then issue a call to the web client to post back to the channel saying \"Hi\" to the user.\n\n```python\nimport os\nfrom slack import RTMClient\nfrom slack.errors import SlackApiError\n\n@RTMClient.run_on(event='message')\ndef say_hello(**payload):\n    data = payload['data']\n    web_client = payload['web_client']\n    rtm_client = payload['rtm_client']\n    if 'text' in data and 'Hello' in data.get('text', []):\n        channel_id = data['channel']\n        thread_ts = data['ts']\n        user = data['user']\n\n        try:\n            response = web_client.chat_postMessage(\n                channel=channel_id,\n                text=f\"Hi <@{user}>!\",\n                thread_ts=thread_ts\n            )\n        except SlackApiError as e:\n            # You will get a SlackApiError if \"ok\" is False\n            assert e.response[\"ok\"] is False\n            assert e.response[\"error\"]  # str like 'invalid_auth', 'channel_not_found'\n            print(f\"Got an error: {e.response['error']}\")\n\nrtm_client = RTMClient(token=os.environ[\"SLACK_API_TOKEN\"])\nrtm_client.start()\n```\n\nPlease note that the default way of creating Slack apps no longer supports RTM API. Events using the RTM API **must** use a classic Slack app (with a plain `bot` scope).\n\nIf you already have a classic Slack app, you can use those credentials. If you don't and need to use the RTM API, you can create a classic Slack app from [this link](https://api.slack.com/apps?new_classic_app=1). You can learn more in the [API documentation](https://api.slack.com/authentication/basics#soon).\n\nAlso, even if the Slack app configuration pages encourage you to upgrade to the newer permission model, don't upgrade it and keep using the \"classic\" bot permission.\n\n### Async usage\n\nslackclient v2 and higher uses [AIOHttp][aiohttp] under the hood for asynchronous requests and [urllib][urllib] for synchronous requests.\n\nNormal usage of the library does not run it in async, hence a kwarg of `run_async=True` is needed.\n\nWhen in async mode its important to remember to await or run/run_until_complete the call.\n\n#### Slackclient as a script\n\n```python\nimport asyncio\nimport os\nfrom slack import WebClient\nfrom slack.errors import SlackApiError\n\nclient = WebClient(\n    token=os.environ['SLACK_API_TOKEN'],\n    run_async=True\n)\nfuture = client.chat_postMessage(\n    channel='#random',\n    text=\"Hello world!\"\n)\n\nloop = asyncio.get_event_loop()\ntry:\n    # run_until_complete returns the Future's result, or raise its exception.\n    response = loop.run_until_complete(future)\n    assert response[\"message\"][\"text\"] == \"Hello world!\"\nexcept SlackApiError as e:\n    assert e.response[\"ok\"] is False\n    assert e.response[\"error\"]  # str like 'invalid_auth', 'channel_not_found'\n    print(f\"Got an error: {e.response['error']}\")\nfinally:\n    loop.close()\n```\n\n#### Slackclient in a framework\n\nIf you are using a framework invoking the asyncio event loop like : sanic/jupyter notebook/etc.\n\n```python\nimport os\nfrom slack import WebClient\nfrom slack.errors import SlackApiError\n\nclient = WebClient(\n    token=os.environ['SLACK_API_TOKEN'],\n    run_async=True # turn async mode on\n)\n# Define this as an async function\nasync def send_to_slack(channel, text):\n    try:\n        # Don't forget to have await as the client returns asyncio.Future\n        response = await client.chat_postMessage(\n            channel=channel,\n            text=text\n        )\n        assert response[\"message\"][\"text\"] == text\n    except SlackApiError as e:\n        assert e.response[\"ok\"] is False\n        assert e.response[\"error\"]  # str like 'invalid_auth', 'channel_not_found'\n        raise e\n\n# https://sanicframework.org/\nfrom sanic import Sanic\nfrom sanic.response import json\n\napp = Sanic()\n# e.g., http://localhost:3000/?text=foo&text=bar\n@app.route('/')\nasync def test(request):\n    text = 'Hello World!'\n    if 'text' in request.args:\n        text = \"\\t\".join(request.args['text'])\n    try:\n        await send_to_slack(channel=\"#random\", text=text)\n        return json({'message': 'Done!'})\n    except SlackApiError as e:\n        return json({'message': f\"Failed due to {e.response['error']}\"})\n\nif __name__ == '__main__':\n    app.run(host='0.0.0.0', port=3000)\n```\n\n### Advanced Options\n\n#### SSL\n\nYou can provide a custom SSL context or disable verification by passing the `ssl` option, supported by both the RTM and the Web client.\n\nFor async requests, see the [AIOHttp SSL documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#ssl-control-for-tcp-sockets).\n\nFor sync requests, see the [urllib SSL documentation](https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen).\n\n#### Proxy\n\nA proxy is supported when making async requests, pass the `proxy` option, supported by both the RTM and the Web client.\n\nFor async requests, see [AIOHttp Proxy documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support).\n\nFor sync requests, setting either `HTTPS_PROXY` env variable or the `proxy` option works.\n\n#### DNS performance\n\nUsing the async client and looking for a performance boost? Installing the optional dependencies (aiodns) may help speed up DNS resolving by the client. We've included it as an extra called \"optional\":\n```bash\n$ pip3 install slackclient[optional]\n```\n\n#### Example\n\n```python\nimport os\nfrom slack import WebClient\nfrom ssl import SSLContext\n\nsslcert = SSLContext()\n# pip3 install proxy.py\n# proxy --port 9000 --log-level d\nproxyinfo = \"http://localhost:9000\"\n\nclient = WebClient(\n    token=os.environ['SLACK_API_TOKEN'],\n    ssl=sslcert,\n    proxy=proxyinfo\n)\nresponse = client.chat_postMessage(\n    channel=\"#random\",\n    text=\"Hello World!\")\nprint(response)\n```\n\n\n### Migrating from v1\n\n---\n\nIf you're migrating from v1.x of slackclient to v2.x, Please follow our migration guide to ensure your app continues working after updating.\n\n**[Check out the Migration Guide here!](https://github.com/slackapi/python-slackclient/wiki/Migrating-to-2.x)**\n\n### Support\n\n---\n\nWe no longer provide support for v1 or v2 of this SDK and only maintain the latest v3 version. If you would like support from this project's maintainers please consider updating to the latest version of the SDK first. Otherwise, you may visit the [Slack Community][slack-community] for getting help using Slack Developer Kit for Python or just generally bond with your fellow Slack developers.\n\n<!-- Markdown links -->\n\n[pypi-image]: https://badge.fury.io/py/slackclient.svg\n[pypi-url]: https://pypi.python.org/pypi/slackclient\n[travis-image]: https://travis-ci.org/slackapi/python-slackclient.svg?branch=main\n[travis-url]: https://travis-ci.org/slackapi/python-slackclient\n[python-version]: https://img.shields.io/pypi/pyversions/slackclient.svg\n[codecov-image]: https://codecov.io/gh/slackapi/python-slackclient/branch/main/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/slackapi/python-slackclient\n[contact-image]: https://img.shields.io/badge/contact-support-green.svg\n[contact-url]: https://slack.com/support\n[api-docs]: https://api.slack.com\n[slackclientv1]: https://github.com/slackapi/python-slackclient/tree/v1\n[api-methods]: https://api.slack.com/methods\n[rtm-docs]: https://api.slack.com/rtm\n[events-docs]: https://api.slack.com/events-api\n[events-sdk]: https://github.com/slackapi/python-slack-events-api\n[message-event]: https://api.slack.com/events/message\n[python-slack-events-api]: https://github.com/slackapi/python-slack-events-api\n[pypi]: https://pypi.python.org/pypi\n[pipenv]: https://pypi.org/project/pipenv/\n[gh-issues]: https://github.com/slackapi/python-slackclient/issues\n[slack-community]: http://slackcommunity.com/\n[dev-roadmap]: https://github.com/slackapi/python-slackclient/wiki/Slack-Python-SDK-Roadmap\n[migration-guide]: documentation_v2/Migration.md\n[files.upload]: https://api.slack.com/methods/files.upload\n[auth-guide]: documentation_v2/auth.md\n[basic-usage]: documentation_v2/basic_usage.md\n[aiohttp]: https://aiohttp.readthedocs.io/\n[urllib]: https://docs.python.org/3/library/urllib.request.html\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Slack API clients for Web API and RTM API (Legacy) - Please use https://pypi.org/project/slack-sdk/ instead.",
    "version": "2.9.4",
    "split_keywords": [
        "slack",
        "slack-web",
        "slack-rtm",
        "chat",
        "chatbots",
        "bots",
        "chatops"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c5c8600174214303bc2c4175d20787e7",
                "sha256": "a8cab9146795e23d66a03473b80dd23df8c500829dfa9d06b3e3d5aec0a2b293"
            },
            "downloads": -1,
            "filename": "slackclient-2.9.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c5c8600174214303bc2c4175d20787e7",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6.0",
            "size": 97128,
            "upload_time": "2022-04-22T00:25:51",
            "upload_time_iso_8601": "2022-04-22T00:25:51.473804Z",
            "url": "https://files.pythonhosted.org/packages/29/cd/89aafa39d7b9d30c82f4f82f50e13ba826bb273ade972befb273c5f6c05e/slackclient-2.9.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "8dbf816fa50237dc594e553a39dc3810",
                "sha256": "ab79fefb5412d0595bc01d2f195a787597f2a617b6766562932ab9ffbe5cb173"
            },
            "downloads": -1,
            "filename": "slackclient-2.9.4.tar.gz",
            "has_sig": false,
            "md5_digest": "8dbf816fa50237dc594e553a39dc3810",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.0",
            "size": 89588,
            "upload_time": "2022-04-22T00:25:53",
            "upload_time_iso_8601": "2022-04-22T00:25:53.860324Z",
            "url": "https://files.pythonhosted.org/packages/ca/c4/f147d5602b060f76555688bc0d88d30c814b827602874c589674db46daeb/slackclient-2.9.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-04-22 00:25:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "slackapi",
    "github_project": "python-slack-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "slackclient"
}
        
Elapsed time: 0.08161s