Name | toslack JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Python API and CLI for sending message in Slack |
upload_time | 2024-09-07 04:20:22 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | The MIT License (MIT) Copyright (c) 2015- Slack Technologies, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
slack
slack-api
chat
chatbot
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<h1 align="center">Python API and CLI for sending message in Slack</h1>
<p align="center">
<a href="https://pypi.org/project/toslack/">
<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/toslack"></a>
<a href="https://pypi.org/project/slack-sdk/">
<img alt="slack-to Versions" src="https://img.shields.io/badge/slack--sdk-%3E%3D3.31.0-red"></a>
<a href="https://pypi.org/project/toslack/">
<img alt="Python Versions" src="https://img.shields.io/pypi/pyversions/toslack.svg"></a>
</p>
**toslack** is a Python package that helps you send messages, images or files to slack channels with simple settings. Command line tools are also provided to do the same thing.
### Requirements
- **Python Version**: Ensure you are using Python 3.6 or higher.
- **Dependencies**:
- `slack_sdk` (version 3.31.0)
- `dataclasses` (built-in for Python 3.6+)
- `typing` (for type hinting)
## Installation
```
pip install toslack
```
## Sending a message to Slack
One of the most common use-cases is sending a message to Slack. 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).
```
import os
from toslack import SlackMessage
from toslack import SlackClient
client = SlackClient(token=os.environ['SLACK_BOT_TOKEN'], channel=os.environ['TO_SLACK_CHANNEL'])
message = SlackMessage(client=client)
message.post(text="Hello world!")
```
Or posting your message by the command line.
```
python slack.py --token xxx --channel C123456 post $message
```
## Uploading files to Slack
You can just include a path to the file directly in the API call and upload it that way.
```
import os
from toslack import SlackMessage
from toslack import SlackClient
client = SlackClient(token=os.environ['SLACK_BOT_TOKEN'], channel=os.environ['TO_SLACK_CHANNEL'])
message = SlackMessage(client=client)
message.upload(file_path="./tmp.txt")
```
Or upload by specifying the file path on the command line.
```
python slack.py --token xxx --channel C123456 upload $file_path
```
Raw data
{
"_id": null,
"home_page": null,
"name": "toslack",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "slack, slack-api, chat, chatbot",
"author": null,
"author_email": "HowieMen <howiemen@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f9/f0/298da143cee39424aeb94c5241a3ed0a8ed369fb23e2dd295dbdb1c14f06/toslack-0.1.0.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">Python API and CLI for sending message in Slack</h1>\n\n<p align=\"center\">\n <a href=\"https://pypi.org/project/toslack/\">\n <img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/toslack\"></a>\n <a href=\"https://pypi.org/project/slack-sdk/\">\n <img alt=\"slack-to Versions\" src=\"https://img.shields.io/badge/slack--sdk-%3E%3D3.31.0-red\"></a>\n <a href=\"https://pypi.org/project/toslack/\">\n <img alt=\"Python Versions\" src=\"https://img.shields.io/pypi/pyversions/toslack.svg\"></a>\n</p>\n\n**toslack** is a Python package that helps you send messages, images or files to slack channels with simple settings. Command line tools are also provided to do the same thing.\n\n### Requirements\n\n- **Python Version**: Ensure you are using Python 3.6 or higher.\n- **Dependencies**:\n - `slack_sdk` (version 3.31.0)\n - `dataclasses` (built-in for Python 3.6+)\n - `typing` (for type hinting)\n\n## Installation\n\n```\npip install toslack\n```\n\n## Sending a message to Slack\n\nOne of the most common use-cases is sending a message to Slack. 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```\nimport os\nfrom toslack import SlackMessage\nfrom toslack import SlackClient\n\nclient = SlackClient(token=os.environ['SLACK_BOT_TOKEN'], channel=os.environ['TO_SLACK_CHANNEL'])\nmessage = SlackMessage(client=client)\nmessage.post(text=\"Hello world!\")\n```\n\nOr posting your message by the command line.\n\n```\npython slack.py --token xxx --channel C123456 post $message\n```\n\n## Uploading files to Slack\n\nYou can just include a path to the file directly in the API call and upload it that way.\n\n```\nimport os\nfrom toslack import SlackMessage\nfrom toslack import SlackClient\n\nclient = SlackClient(token=os.environ['SLACK_BOT_TOKEN'], channel=os.environ['TO_SLACK_CHANNEL'])\nmessage = SlackMessage(client=client)\nmessage.upload(file_path=\"./tmp.txt\")\n```\n\nOr upload by specifying the file path on the command line.\n\n```\npython slack.py --token xxx --channel C123456 upload $file_path\n```\n",
"bugtrack_url": null,
"license": "The MIT License (MIT) Copyright (c) 2015- Slack Technologies, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Python API and CLI for sending message in Slack",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/HowieMen/toslack/issues",
"Homepage": "https://github.com/HowieMen/toslack"
},
"split_keywords": [
"slack",
" slack-api",
" chat",
" chatbot"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7b123b4eac584723c46d7fa8b8b1e3ad06c708e8e0ca1b0b4c3d01e3156aea5e",
"md5": "70b7cc869342fe293fc4f5a7c97539fe",
"sha256": "43a9a7b30e6ca3448c2afa00126311492bc06de67dd2524e31a77ca2967deb4d"
},
"downloads": -1,
"filename": "toslack-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "70b7cc869342fe293fc4f5a7c97539fe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4894,
"upload_time": "2024-09-07T04:20:21",
"upload_time_iso_8601": "2024-09-07T04:20:21.380909Z",
"url": "https://files.pythonhosted.org/packages/7b/12/3b4eac584723c46d7fa8b8b1e3ad06c708e8e0ca1b0b4c3d01e3156aea5e/toslack-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f9f0298da143cee39424aeb94c5241a3ed0a8ed369fb23e2dd295dbdb1c14f06",
"md5": "0f93661d2bd5bdda586516eda8c69b95",
"sha256": "b4cbac632dae6eb3470c845a74338a284db78ec30a20e45f27a6b74dd55be167"
},
"downloads": -1,
"filename": "toslack-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0f93661d2bd5bdda586516eda8c69b95",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3979,
"upload_time": "2024-09-07T04:20:22",
"upload_time_iso_8601": "2024-09-07T04:20:22.905086Z",
"url": "https://files.pythonhosted.org/packages/f9/f0/298da143cee39424aeb94c5241a3ed0a8ed369fb23e2dd295dbdb1c14f06/toslack-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-07 04:20:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HowieMen",
"github_project": "toslack",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "toslack"
}