slack-message-pipe
slack_message_pipe is a library for reading a Slack channel's message history as simple Python data structures. This has many benefits over Slack's API when formatting channel history for human or LLM consumption:
- We stitch data from multiple API calls into a single data structure. For example, our
Messageobject contains user and channel names instead of IDs. - We convert Slack's special markdown into standard markdown.
- We provide the output as simple, typed Python objects that you and your IDE can understand.
We intend to enhance this package also process the live message flow as activity proceeds in a set of Slack channels or threads.
This project began as a clone of ErikKalkoken / slackchannel2pdf. We transformed that code to produce Python data structures instead of PDF files. We have no way to test on Windows, so we have dropped that support.
Contents
Overview
slack-message-pipe is open source under the MIT license. See ./LICENSE.
We use Flit for package management and distribution.
Installation
Python
This package is compatible with Python 3.10 and 3.11.
You can install the tool from PyPI with pip install:
pip install slack-message-pipe
You can then run the tool with the command slack-message-pipe as explained in detail under Usage.
Token
To run slack-message-pipe, you need to have a token for your Slack workspace with the following permissions:
channels:historychannels:readgroups:historygroups:readusers:readusergroups:read
Here is one way to do that:
- Create a new Slack app in your workspace (you can give it any name).
- Under Oauth & Permissions / User Token Scopes add all the required scopes as documented above.
- Install the app into your workspace
After successful installation the token for your app will then shown under Basic Information / App Credentials.
Usage
Currently, the cli is just for testing. It exports the data as pretty printed python data structures.
You can provide the Slack token either as command line argument --token or by setting the environment variable SLACK_TOKEN.
Logging to file: slack_message_pipe.log
usage: slack-message-pipe [-h] [--token TOKEN] [--formatter_timezone FORMATTER_TIMEZONE] [--formatter_locale FORMATTER_LOCALE] [--version]
[--max-messages MAX_MESSAGES] [--quiet]
{pprint,markdown} oldest latest channel_id [channel_id ...]
A tool for reading a Slack channel's message history and converting it to various formats.
The output is written to a file with the same name as the channel and the date range.
Example: slack-message-pipe markdown "2024-01-01 00:00" now C0423S252BH
For more information, see the README: https://github.com/dean-thompson/slack-message-pipe
positional arguments:
{pprint,markdown} Action to take on the data
oldest Oldest timestamp from which to load messages; format: YYYY-MM-DD HH:MM [timezone]
Defaults to this processe's timezone. (It is an error if no timezone is specified and the process's timezone is not known.)
latest Latest timestamp from which to load messages; format: YYYY-MM-DD HH:MM [timezone] or 'now'
Defaults to this process's timezone. (It is an error if no timezone is specified and the user's timezone is not known.)
If not provided, will process messages up to the current time.
channel_id One or several: ID of channel to export.
options:
-h, --help show this help message and exit
--token TOKEN Slack OAuth token. Can instead be provided in the environment variable SLACK_TOKEN.
--formatter_timezone FORMATTER_TIMEZONE
Manually set the timezone to be used for formatting dates and times, such as 'Europe/Berlin'. Use a timezone name as defined here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zonesDefaults to the process timezone.
--formatter_locale FORMATTER_LOCALE
Manually set the locale to be used for formatting, with a IETF language tag, e.g. 'de-DE' for Germany. See this page for a list of valid tags: https://en.wikipedia.org/wiki/IETF_language_tag . Defaults to the process locale.
--version Show the program version and exit
--max-messages MAX_MESSAGES
Max number of messages to export
--quiet When provided will not generate normal console output, but still show errors
Configuration
You can configure many defaults and behaviors via configuration files. Configuration files must have the name slack_message_pipe.ini and can be placed in two locations:
- home directory (home)
- current working directory (cwd)
You can also have a configuration file in both. Settings in cwd will overwrite the same settings in home. And calling this app with command line arguments will overwrite the corresponding configuration setting.
Please see the master configuration file for a list of all available configuration sections, options, and the current defaults.
Limitations
- Text only: slack-message-pipe will export only text from a channel, but not images or icons.
- No Emojis: the tools is currently not able to write emojis as icons will will use their text representation instead (e.g.
:laughing:instead of 😆). - DMs, Group DM: Currently not supported
- Limited blocks support:Some non-text features of layout blocks not yet supported
- Limited script support: This tool is rendering all PDF text with the Google Noto Sans font and will therefore support all 500+ languages that are support by that font. It does however not support many Asian languages / scripts like Chinese, Japanese, Korean, Thai and others.
Metadata
Release files for slack_message_pipe 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| slack_message_pipe-0.0.6.tar.gz | 1.2 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| slack_message_pipe-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.3 MB
Release files / slack_message_pipe-0.0.6.tar.gz
| Download URL | slack_message_pipe-0.0.6.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2c92ca8267f99f5d3383c13207ee2c265a9104f5c96868a01ff2ae456325f42
|
|
BLAKE2b-256 checksum How to use checksums |
a2a4d9ebedd949bac1eef7f74c6b34604559327607a5de7482122b2c9ed1e42b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / slack_message_pipe-0.0.6-py3-none-any.whl
| Download URL | slack_message_pipe-0.0.6-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d32b250fa90c7e5f67b1fb706a1ca6a0847d533543e91e772f0452da7d1f2a5c
|
|
BLAKE2b-256 checksum How to use checksums |
30c53bcacebf8685bde84d7bc16651b1fc66c391c1f18f8212e69aab76e3c960
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for slack_message_pipe 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.