| .. | ||
| .env | ||
| env_template.txt | ||
| README.md | ||
| requirements.txt | ||
| slack_poster.py | ||
Slack Message Poster CLI
A fast and simple command-line tool for posting messages to Slack channels.
Installation
- 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
--tokenor-t: Slack Bot/User OAuth token (e.g., xoxb-...)--channelor-c: Slack channel ID (e.g., C04ABC123)--messageor-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
- Go to https://api.slack.com/apps
- Create a new app or select existing one
- Go to "OAuth & Permissions"
- Add the
chat:writescope - Install the app to your workspace
- Copy the Bot User OAuth Token (starts with
xoxb-)
Channel ID
To get a channel ID:
- Open Slack in your browser
- Navigate to the channel
- The channel ID is in the URL:
https://app.slack.com/client/T1234567890/C04ABC123 - Use the part after
/C(e.g.,C04ABC123)