Skip to main content

A powerful webhook handler for Discord and Slack

Project description

HookMe

A powerful and easy-to-use Python package for handling Discord and Slack webhooks.

Installation

Usage

Sending a Simple Message

from hookme import DiscordWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
webhook = DiscordWebhook(webhook_url)

response = webhook.send_message("Hello, Discord!")
print(response.status_code)

Sending an Embedded Message

from hookme import DiscordWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
webhook = DiscordWebhook(webhook_url)

embed = {
    "title": "Sample Embed",
    "description": "This is an embedded message",
    "color": 0x00ff00
}

response = webhook.send_embed(
    title=embed["title"],
    description=embed["description"],
    color=embed["color"]
)
print(response.status_code)

Sending a File

from hookme import DiscordWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
webhook = DiscordWebhook(webhook_url)

file_path = "path/to/your/file.txt"

response = webhook.send_file(file_path, content="Here is a file")
print(response.status_code)

Scheduling a Message

from hookme.automated_webhook import AutomatedWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
automated_webhook = AutomatedWebhook(webhook_url)

# Schedule a message to be sent every hour
schedule_id = automated_webhook.schedule_message(
    schedule_type="interval",
    schedule_value="1h",
    content="This is a scheduled message"
)

# Start the scheduler
automated_webhook.start_scheduler()

Sending Multiple Files with an Embedded Message

from hookme import DiscordWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
webhook = DiscordWebhook(webhook_url)

files = ["path/to/your/file1.txt", "path/to/your/file2.txt"]

response = webhook.send_files_with_embed(
    files=files,
    title="Files with Embed",
    description="These are multiple files with an embedded message",
    color=0x00ff00
)
print(response.status_code)

Handling Automated Webhooks

from hookme.automated_webhook import AutomatedWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
automated_webhook = AutomatedWebhook(webhook_url)

# Schedule an embedded message to be sent daily at 9 AM
schedule_id = automated_webhook.schedule_embed(
    schedule_type="cron",
    schedule_value="0 9 * * *",
    title="Daily Update",
    description="This is a daily update",
    color=0x00ff00
)

# Start the scheduler
automated_webhook.start_scheduler()

Retrieving Webhook Logs

from hookme.automated_webhook import AutomatedWebhook
from datetime import datetime

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
automated_webhook = AutomatedWebhook(webhook_url)

# Retrieve logs for a specific webhook ID
logs = automated_webhook.get_webhook_logs(webhook_id=1)
print(logs)

# Retrieve logs within a date range
start_date = datetime(2023, 1, 1)
end_date = datetime(2023, 12, 31)
logs = automated_webhook.get_webhook_logs(start_date=start_date, end_date=end_date)
print(logs)

# Retrieve logs with a specific status
logs = automated_webhook.get_webhook_logs(status="success")
print(logs)

Starting and Stopping the Scheduler

from hookme.automated_webhook import AutomatedWebhook

webhook_url = "YOUR_DISCORD_WEBHOOK_URL"
automated_webhook = AutomatedWebhook(webhook_url)

# Start the scheduler
automated_webhook.start_scheduler()

# Stop the scheduler
automated_webhook.stop_scheduler()

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

hookme-0.1.8.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hookme-0.1.8-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file hookme-0.1.8.tar.gz.

File metadata

  • Download URL: hookme-0.1.8.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for hookme-0.1.8.tar.gz
Algorithm Hash digest
SHA256 928de4d77968aec1390d2d582d4c4a0ba9b53cb200a4c9bdb578c571d3c7eaaf
MD5 65d3bf9acc295784fe29fbba503210c4
BLAKE2b-256 418e8b9f6597a537dbeca075ea78a5c5e501145cab86f4205ad74b1d16328351

See more details on using hashes here.

File details

Details for the file hookme-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: hookme-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for hookme-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a03960a038793c1668498c9de82055a0ff49539a3d05925f455c0302667d1a83
MD5 16d4beb0295fa2bad9549f1922f8d99a
BLAKE2b-256 43b535c3d169f1f401773ee0fd2375ce4a9f549c9fdb72cf855f3a8572940add

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page