Skip to main content

Slack Messanger Client using Incoming Webhooks

Project description

slack-messenger

Description

The slack-messenger is a simple package that helps send Slack Messages via Incoming Webhook URLs. For more information on how to create a Slack App, and how to generate an incoming webhook URL please read the official Slack documentation on sending messages using Incoming Webhooks.

Downloads Downloads Supported Versions

How to use slack-messenger

from slack_messenger import SlackMessenger

# Create the SlackMessenger object with your Incoming Webhook URL
url = "https://hooks.slack.com/services/<rest-of-the-webhook>"
sm = SlackMessenger(slackbot_webhook_url=url)

# Create your message, you can use the usual formatting and layout blocks available from Slack
message = "Hello Slack :alert-emoji:, this is sent from `slack messenger`"

# The 'send_slack_msg' method will return a tuple with the first item boolean to represent if sending
# the message was successful and the second item as a string of text indicating if the message was 
# successfully sent or failed along with the message content and error message in the event of failure.
message_success, response_msg = sm.send_slack_msg(message=message)
print(f"SUCCESS: {message_success}  RESPONSE MSG: {response_msg}")

# If you wish to include a slack formatted date and timestamp in your message you can call the below
# method to return the slack date and include it in your message body
slack_date = sm.get_slack_formatted_date_num_time_secs()

Installing slack-messenger

Requests is available on PyPI:

$ python -m pip install slack-messenger

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

slack_messenger-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file slack_messenger-0.1.2.tar.gz.

File metadata

  • Download URL: slack_messenger-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for slack_messenger-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c6f6604f3d5b1975a7b64afd8f0ca7f6373b67090bc2557308a72f8209e8ac3a
MD5 556c7b32ee30a1c7705f96bb34f2892d
BLAKE2b-256 9c13e23a995b223fad640bb84d7e4722add8e3bcf13191feea3c47f487f9d2e5

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