Skip to content

Send messages to a Slack channel. Created for my personal use.

Notifications You must be signed in to change notification settings

srshearer/slack-announce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Slack Announce

Tools for sending messages to a Slack channel via the Slack API. Created for my personal use.

slackAnnounce.py

Description: This is an example script for using slacksenderutils to send notification messages to Slack via webhooks. Send arbitrary messages as your bot user, send expected downtime, or server up notifications.

slackutils.py

Description: This contains a wrapper class for building json payloads to send messages to Slack as well as a few basica utility functions.

Before this will work, you will need to do the following…

  1. Get a Slack webhook url. (More info at: https://api.slack.com/incoming-webhooks)
  2. Rename slack_config_example.py –> slack_config.py
  3. Add the following information to slack_config.py
    • Your Slack webhook url
    • Slack webhook url to send messages to yourself
    • The default username you want to send messages as
    • Slack channel to send messages to by default
    • Slack channel to send messages to when you are developing/testing/debugging
  4. Verify that .gitignore lists *config.py as an ignored file and that slack_config.py will not be pushed to git. This should already be set up properly for you.

Required arguments:

-m, --message '<message>' Message to send to the channel.

  • 'up' will send a pre-formatted message stating the server is back up. Default color: (good/green)
  • 'down <number> <time unit>' (ex.'down 20 min') will send a pre-formatted message that the server will be going down for maintenance for that amount of time. Default color: (warn/yellow)
  • Any other message will be sent as-is. Default color: (info/gray)

Optional arguments:

-h, --help  Show help message and exit
-c, --color <color> Color for message. Color Options: gray/info (default), green/good, yellow/warn, red/danger, purple
-d, --debug Enable debug mode. Send message to test channel and show json output in console.
--dry Enable dryrun mode. Message will not be sent.
-r, --room <room> Slack channel room to send the message to.
-_t, --title <title> Set a message title.

About

Send messages to a Slack channel. Created for my personal use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages