Skip to content

CafeAuLait-CC/SlackDown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlackDown

SlackDown allows you to back up Slack messages (including public channels, private channels, direct messages, and group messages) to local Markdown files. It also supports downloading and organizing file attachments.

Features

  • Backs up Slack messages from:
    • Public channels
    • Private channels
    • Direct messages (DMs)
    • Group messages (MPIMs)
  • Saves messages in Markdown format with timestamps, reactions, and threads.
  • Downloads file attachments and organizes them into folders.
  • Supports selective backup of specific channels or users.

Prerequisites

  • Python 3.8 or higher.
  • A Slack app with the necessary permissions and a User OAuth token. See this instruction for more details.

Setup

  1. Clone the Repository:

    > git clone https://github.com/CafeAuLait-CC/SlackDown.git
    > cd SlackDown
  2. Install Dependencies:

    Linux & macOS:

    > python3 -m venv ./slack_env
    > source ./slack_env/bin/activate
    > pip install -r requirements.txt

    Windows (PowerShell):

    > python3 -m venv slack_env
    > slack_env\Scripts\Activate.ps1
    > pip install -r requirements.txt

    Note: You might need to run the following command if you encounter an error running the Activate.ps1 in PowerShell.

    > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  3. Create a Slack App:

    • Go to the Slack API and create a new app. See this instruction for more details.
    • Install the app to your workspace and obtain the User OAuth Token.
  4. Edit the config.txt File: Edit the config.txt file in the project directory with the following content:

    [Slack]
    User_OAuth_Token = xoxp-your-slack-user-oauth-token
    
    [Directories]
    Direct_Msg_Directory = backup/dm
    Group_Msg_Directory = backup/groups
    Channel_Msg_Directory = backup/channels
    Attachment_Directory = backup/attachments
    
    [Options]
    Backup_Attachments = True
    Backup_List = all
    • Replace xoxp-your-slack-user-oauth-token with your actual Slack User OAuth token (the one starts with xoxp).

    • You can choose whether or not you want to backup the attachments in the conversation, by setting the Backup_Attachments to True or False.

    • The Backup_List could be all or a specific list of conversations you want to backup, e.g. Backup_List = general, bob means backup the messages from the general channel and your DMs with bob, bob is the [display name] of a user in your workspace.

  5. Run the Script:

    > python slackdown.py

    The script will back up messages and attachments to the specified directories.

Configuration Options

config.txt

  • User_OAuth_Token: Your Slack user OAuth token.
  • Direct_Msg_Directory: Directory to store direct messages (default: dm).
  • Group_Msg_Directory: Directory to store group messages (default: groups).
  • Channel_Msg_Directory: Directory to store channel messages (default: channels).
  • Attachment_Directory: Directory to store downloaded attachments (default: attachments).
  • Backup_Attachments: Whether to download attachments (default: True).
  • Backup_List: List of specific channels or users to back up (default: all. E.g. general, alice, where general is the general channel and alice is the display name of a user in your workspace.).

Output

  • Messages: Saved as Markdown files in the respective directories (dm, groups, channels).
  • Attachments: Downloaded to the attachments folder, organized by channel or user.

Example Output

Markdown File (dm/alex.md)

#### 2023-10-10

**Alex** (12:34:56): Hello `@bob`, please check `@channel` for updates.

**Bob** (12:35:10): Got it!

_Reactions_: 👍 (x2), 😂 (x1)

[Attachment: Alex_image1.png](attachments/dm/Alex_image1.png)

Attachments Folder

attachments/
├── dm/
│   ├── Alex_image1.png
│   └── Alex_image2.png
└── general/
    └── Team_image1.png

Notes

  • Run this script periodically (e.g. monthly or every 3 months) could appends new messages to existing backup files, ensuring that edits and new messages are reflected.
  • Attachment files in one conversation with the same content are not duplicated; instead, the existing file is reused.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgement

This project is generated by DeepSeek-V3.

About

Save your Slack messages to local Markdown.

Resources

License

Stars

Watchers

Forks

Contributors

Languages