bytelyst-devops-tools/MERGED
2025-10-04 21:59:20 +05:30
..
README.md Add MERGED directory with slack_poster.py and requirements 2025-10-04 21:59:20 +05:30
requirements.txt Add MERGED directory with slack_poster.py and requirements 2025-10-04 21:59:20 +05:30
slack_poster.py Add MERGED directory with slack_poster.py and requirements 2025-10-04 21:59:20 +05:30

Slack Message Poster CLI

A fast and simple command-line tool for posting messages to Slack channels.

Installation

  1. Install dependencies:
pip install -r requirements.txt

Usage

Command Line Arguments

python slack_poster.py --token <SLACK_TOKEN> --channel <CHANNEL_ID> --message "<MESSAGE>"

Interactive Mode

If any parameter is missing, the tool will prompt you interactively:

python slack_poster.py

Examples

# Full command line
python slack_poster.py -t xoxb-1234567890-1234567890-abcdefghijklmnopqrstuvwx -c C04ABC123 -m "Hello World!"

# Interactive mode
python slack_poster.py

Parameters

  • --token or -t: Slack Bot/User OAuth token (e.g., xoxb-...)
  • --channel or -c: Slack channel ID (e.g., C04ABC123)
  • --message or -m: Message text to post

Error Handling

The tool handles various error scenarios:

  • Invalid token
  • Channel not found
  • Bot not in channel
  • Rate limiting
  • Network issues
  • Empty messages

Getting Slack Credentials

  1. Go to https://api.slack.com/apps
  2. Create a new app or select existing one
  3. Go to "OAuth & Permissions"
  4. Add the chat:write scope
  5. Install the app to your workspace
  6. Copy the Bot User OAuth Token (starts with xoxb-)

Channel ID

To get a channel ID:

  1. Open Slack in your browser
  2. Navigate to the channel
  3. The channel ID is in the URL: https://app.slack.com/client/T1234567890/C04ABC123
  4. Use the part after /C (e.g., C04ABC123)