Skip to main content

Command line tool for exporting the text contents of any Slack channel to a PDF file.

Project description

slackchannel2pdf

slackchannel2pdf is a command line tool for exporting the text contents of any Slack channel to a PDF file.

release python license Tests codecov Code style: black

Contents

Overview

This tool is aimed at end users that want to make backups of Slack conversations or be able to share them outside Slack. It will create a PDF file for every exported channel and will work both for public and private channels.

slackchannel2pdf is an open source project and offered free of charge and under the MIT license. Please check attached licence file for details.

Features

Here is a short summary of the key features of slackchannel2pdf:

  • Export of any public and private Slack channel to a PDF file (text only)
  • Automatic detection of timezone and locale based from Slack. Can also be set manually if needed.
  • Exporting support for all Slack features incl. threads and layout blocks
  • Ability to export only the portion of a channel for a specific time period
  • Ability to configure page layout of PDF file (e.g. Portrait vs. Landscape)
  • Many defaults and behaviors can be configured with configuration files

Installation

Python

You can install the tool from PyPI with pip install. This wil require you to have Python reinstalled in your machine and it will work with any OS supported by Python. We recommend installing it into a virtual environment like venv.

pip install slackchannel2pdf

You can then run the tool with the command slackchannel2pdf as explained in detail under Usage.

Windows

For windows users we also provide a Windows EXE that does not require you to install Python. You find the EXE file under releases.

Token

To run slackchannel2pdf your need to have a token for your Slack workspace with the following permissions:

  • channels:history
  • channels:read
  • groups:history
  • groups:read
  • users:read
  • usergroups:read

To get a working token you need to create a Slack app in your workspace with a user token. Here is one way on how to do that:

  1. Create a new Slack app in your workspace (you can give it any name).
  2. Under Oauth & Permissions / User Token Scopes add all the required scopes as documented above.
  3. Install the app into your workspace

After successful installation the token for your app will then shown under Basic Information / App Credentials.

Usage

In order to use slackchannel2pdf you need:

  1. have it installed on your system (see Installation)
  2. have a Slack token for the respective Slack workspace with the required permissions (see Token).

Here are some examples on how to use slackchannel2pdf:

To export the Slack channel "general":

slackchannel2pdf --token MY_TOKEN general

To export the Slack channels "general", "random" and "test":

slackchannel2pdf --token MY_TOKEN general random test

To export all message from channel "general" starting from July 5th, 2019 at 11:00.

slackchannel2pdf --token MY_TOKEN --oldest "2019-JUL-05 11:00" general

Tip: You can provide the Slack token either as command line argument --token or by setting the environment variable SLACK-TOKEN.

Arguments

usage: slackchannel2pdf [-h] [--token TOKEN] [--oldest OLDEST]
                        [--latest LATEST] [-d DESTINATION]
                        [--page-orientation {portrait,landscape}]
                        [--page-format {a3,a4,a5,letter,legal}]
                        [--timezone TIMEZONE] [--locale LOCALE] [--version]
                        [--max-messages MAX_MESSAGES] [--write-raw-data]
                        [--add-debug-info] [--quiet]
                        channel [channel ...]

This program exports the text of a Slack channel to a PDF file

positional arguments:
  channel               One or several: name or ID of channel to export.

optional arguments:
  -h, --help            show this help message and exit
  --token TOKEN         Slack OAuth token (default: None)
  --oldest OLDEST       don't load messages older than a date (default: None)
  --latest LATEST       don't load messages newer then a date (default: None)
  -d DESTINATION, --destination DESTINATION
                        Specify a destination path to store the PDF file.
                        (TBD) (default: .)
  --page-orientation {portrait,landscape}
                        Orientation of PDF pages (default: portrait)
  --page-format {a3,a4,a5,letter,legal}
                        Format of PDF pages (default: a4)
  --timezone TIMEZONE   Manually set the timezone to be used e.g.
                        'Europe/Berlin' Use a timezone name as defined here: h
                        ttps://en.wikipedia.org/wiki/List_of_tz_database_time_
                        zones (default: None)
  --locale LOCALE       Manually set the locale to be used 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
                        (default: None)
  --version             show the program version and exit
  --max-messages MAX_MESSAGES
                        max number of messages to export (default: 10000)
  --write-raw-data      will also write all raw data returned from the API to
                        files, e.g. messages.json with all messages (default:
                        None)
  --add-debug-info      wether to add debug info to PDF (default: False)
  --quiet               When provided will not generate normal console output,
                        but still show errors (console logging not affected
                        and needs to be configured through log levels instead)
                        (default: False)

Configuration

You can configure many defaults and behaviors via configuration files. Configuration files must have the name slackchannel2pdf.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. The master configuration file is slackchannel2pdf/slackchannel2pdf.ini in this repo.

Limitations

  • Text only: slackchannel2pdf will export only text from a channel, but not images or icons. This is by design.
  • 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 :laughing:).
  • 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 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

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

slackchannel2pdf-1.5.2.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

slackchannel2pdf-1.5.2-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file slackchannel2pdf-1.5.2.tar.gz.

File metadata

  • Download URL: slackchannel2pdf-1.5.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for slackchannel2pdf-1.5.2.tar.gz
Algorithm Hash digest
SHA256 b4e5fb5b05305dd083dc190641000ee8982802fddd51ddd493dc11d83019a845
MD5 84ab1afb11f8f4a9b18a55ff21044ecf
BLAKE2b-256 bb7427b64129fa5dbe42191fab82ae96492117985ff0990b6723fc7210bc1afd

See more details on using hashes here.

File details

Details for the file slackchannel2pdf-1.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for slackchannel2pdf-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3cda24b8fca3b33ca4187cd42e65655950d02cbf42828009c84b6d7543ac6061
MD5 5fdbb13ac3b17603bb33f0cb5d4c65b9
BLAKE2b-256 abd22489b6c428aaca1e0de5c5b86ec5ebc1c465aa6b55fbb234e3fe7fba2558

See more details on using hashes here.

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