# snotify
Lightweight notification manager with support for Telegram, email, and custom channels.
## Description
`snotify` is a library for managing notifications that allows sending messages through various channels such as Telegram, email, and custom channels. It supports a fallback mechanism that allows sending messages through alternative channels in case the primary one fails.
## Installation
Install the library using pip:
```bash
pip install snotify
```
## Usage Example
```python
from snotify import Notifier, TelegramChannel, EmailChannel
# Create an instance of Notifier
notifier = Notifier()
# Add a Telegram channel
telegram_channel = TelegramChannel(bot_token="your_bot_token", recipients=[...])
notifier.add_channel(telegram_channel, "telegram")
# Add an Email channel
email_channel = EmailChannel(
smtp_server="smtp.example.com",
smtp_port=587,
smtp_user="your_user",
smtp_password="your_password",
recipients=[...]
)
notifier.add_channel(email_channel, "email")
# Send a notification
await notifier.send("Your message")
```
## Creating a Custom Channel
To create a custom channel, you need to extend the `BaseChannel` class and implement the `send` and `validate_config` methods. Here's a basic example:
```python
from snotify.channels.base import BaseChannel, BaseRecipient
import logging
class CustomChannel(BaseChannel):
def __init__(self, custom_param, recipients):
super().__init__(recipients)
self.custom_param = custom_param
async def send(self, message, recipients=None):
logger = logging.getLogger(__name__)
recipients_to_use = recipients if recipients is not None else self.recipients
for recipient in recipients_to_use:
# Implement your custom sending logic here
logger.info(f"Sending message to {recipient.get_recipient_name()} via custom channel")
def validate_config(self):
if not self.custom_param:
raise ValueError("Custom parameter is required")
```
## Features
- **Support for multiple channels**: Telegram, Email, and Custom channels.
- **Fallback mechanism**: ability to specify the order of channels for sending messages in case of failure.
- **Easy setup and use**.
## Requirements
- Python 3.7+
- aiohttp
- aiosmtplib
## License
MIT License. See the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/swtormy/snotify",
"name": "snotify",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "notifications telegram, webhook, email",
"author": "Konstantin Vasilev",
"author_email": "swtormy@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/47/32/d8d00e73fd088dbfc63b496910d946b46d18f89e4fab80e438c6acaed306/snotify-0.1.1.tar.gz",
"platform": null,
"description": "# snotify\r\n\r\nLightweight notification manager with support for Telegram, email, and custom channels.\r\n\r\n## Description\r\n\r\n`snotify` is a library for managing notifications that allows sending messages through various channels such as Telegram, email, and custom channels. It supports a fallback mechanism that allows sending messages through alternative channels in case the primary one fails.\r\n\r\n## Installation\r\n\r\nInstall the library using pip:\r\n\r\n```bash\r\npip install snotify\r\n```\r\n\r\n## Usage Example\r\n\r\n```python\r\nfrom snotify import Notifier, TelegramChannel, EmailChannel\r\n\r\n# Create an instance of Notifier\r\nnotifier = Notifier()\r\n\r\n# Add a Telegram channel\r\ntelegram_channel = TelegramChannel(bot_token=\"your_bot_token\", recipients=[...])\r\nnotifier.add_channel(telegram_channel, \"telegram\")\r\n\r\n# Add an Email channel\r\nemail_channel = EmailChannel(\r\n smtp_server=\"smtp.example.com\",\r\n smtp_port=587,\r\n smtp_user=\"your_user\",\r\n smtp_password=\"your_password\",\r\n recipients=[...]\r\n)\r\nnotifier.add_channel(email_channel, \"email\")\r\n\r\n# Send a notification\r\nawait notifier.send(\"Your message\")\r\n```\r\n\r\n## Creating a Custom Channel\r\n\r\nTo create a custom channel, you need to extend the `BaseChannel` class and implement the `send` and `validate_config` methods. Here's a basic example:\r\n\r\n```python\r\nfrom snotify.channels.base import BaseChannel, BaseRecipient\r\nimport logging\r\n\r\nclass CustomChannel(BaseChannel):\r\n def __init__(self, custom_param, recipients):\r\n super().__init__(recipients)\r\n self.custom_param = custom_param\r\n\r\n async def send(self, message, recipients=None):\r\n logger = logging.getLogger(__name__)\r\n recipients_to_use = recipients if recipients is not None else self.recipients\r\n for recipient in recipients_to_use:\r\n # Implement your custom sending logic here\r\n logger.info(f\"Sending message to {recipient.get_recipient_name()} via custom channel\")\r\n\r\n def validate_config(self):\r\n if not self.custom_param:\r\n raise ValueError(\"Custom parameter is required\")\r\n```\r\n\r\n## Features\r\n\r\n- **Support for multiple channels**: Telegram, Email, and Custom channels.\r\n- **Fallback mechanism**: ability to specify the order of channels for sending messages in case of failure.\r\n- **Easy setup and use**.\r\n\r\n## Requirements\r\n\r\n- Python 3.7+\r\n- aiohttp\r\n- aiosmtplib\r\n\r\n## License\r\n\r\nMIT License. See the LICENSE file for details.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Lightweight notification manager for Telegram, Webhook, Email and Custom channels",
"version": "0.1.1",
"project_urls": {
"Documentation": "https://github.com/swtormy/snotify#readme",
"Homepage": "https://github.com/swtormy/snotify",
"Source": "https://github.com/swtormy/snotify",
"Tracker": "https://github.com/swtormy/snotify/issues"
},
"split_keywords": [
"notifications telegram",
" webhook",
" email"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b9ae412c0909b7aa254c2fa234d2e04f9ca8b601f4ce3d829dcd98773bfd4fc",
"md5": "965ce339a32c0e7994d09ccbbec78b3d",
"sha256": "38e655c4e5e934acf94287336ce0adb64f050b78710f19bd78c41dc85d3ef800"
},
"downloads": -1,
"filename": "snotify-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "965ce339a32c0e7994d09ccbbec78b3d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11849,
"upload_time": "2024-11-20T17:21:50",
"upload_time_iso_8601": "2024-11-20T17:21:50.468602Z",
"url": "https://files.pythonhosted.org/packages/0b/9a/e412c0909b7aa254c2fa234d2e04f9ca8b601f4ce3d829dcd98773bfd4fc/snotify-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4732d8d00e73fd088dbfc63b496910d946b46d18f89e4fab80e438c6acaed306",
"md5": "8e25f1b22861241f9730abfb211265bc",
"sha256": "254305dbbc1c91cba1125090c1365f7b2880e5eb368d7afb6acef7adc4095c79"
},
"downloads": -1,
"filename": "snotify-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "8e25f1b22861241f9730abfb211265bc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 9234,
"upload_time": "2024-11-20T17:21:53",
"upload_time_iso_8601": "2024-11-20T17:21:53.233036Z",
"url": "https://files.pythonhosted.org/packages/47/32/d8d00e73fd088dbfc63b496910d946b46d18f89e4fab80e438c6acaed306/snotify-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-20 17:21:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "swtormy",
"github_project": "snotify",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "snotify"
}