dhooks-lite


Namedhooks-lite JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryAnother simple class wrapper for interacting with Discord webhooks.
upload_time2023-07-16 14:16:49
maintainer
docs_urlNone
author
requires_python>=3.6
license
keywords discord discordhooks discordwebhooks webhooks
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dhooks-lite

Another simple class wrapper for interacting with Discord webhooks.

[![release](https://img.shields.io/pypi/v/dhooks-lite?label=release)](https://pypi.org/project/dhooks-lite/)
[![python](https://img.shields.io/pypi/pyversions/dhooks-lite)](https://pypi.org/project/dhooks-lite/)
[![pipeline status](https://gitlab.com/ErikKalkoken/dhooks-lite/badges/master/pipeline.svg)](https://gitlab.com/ErikKalkoken/dhooks-lite/-/commits/master)
[![codecov](https://codecov.io/gl/ErikKalkoken/dhooks-lite/branch/master/graph/badge.svg?token=9YNL3HEJ5D)](https://codecov.io/gl/ErikKalkoken/dhooks-lite)
[![Documentation Status](https://readthedocs.org/projects/dhooks-lite/badge/?version=latest)](https://dhooks-lite.readthedocs.io/en/latest/?badge=latest)
[![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/ErikKalkoken/dhooks-lite/-/blob/master/LICENSE)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![chat](https://img.shields.io/discord/790364535294132234)](https://discord.gg/zmh52wnfvM)

## Contents

- [Overview](#overview)
- [Functionality](#functionality)
- [Examples](#examples)
- [Installation](#installation)
- [Documentation](#documentation)
- [Contribution](#contribution)

## Overview

**dhooks-lite** is a library with a set of classes for interacting with Discord webhooks written in Python 3.

This library aims to differentiate itself from similar libraries with the following properties:

- is fully tested
- simple to use (only one way of doing things, same name of attributes and objects as in the [official Discord documentation](https://discordapp.com/developers/docs/resources/webhook#execute-webhook))
- has logging
- requests are automatically retried and have sensible timeouts
- works with older Python versions

## Functionality

This library provides following functionality:

- Posting messages in Discord channels via webhooks (synchronous calls only)
- Attaching Embeds to messages
- Retrieve send reports and from Discord
- Retrieve HTTP status and headers from Discord, e.g. for implementing rate limit handling

## Examples

Here are some examples on how to use dhooks-lite in your Python scripts.

Note that you also find the source code of all examples in the `/examples` folder of this repo.

### Hello World

Minimal example for posting a message.

```python
from dhooks_lite import Webhook

hook = Webhook(DISCORD_WEBHOOK_URL)
hook.execute('Hello, World!')
```

![example1](https://i.imgur.com/t3mxMAJ.png)

### Posting with custom avatar

In this example we are setting username and avatar.

```python
from dhooks_lite import Webhook

hook = Webhook(
    DISCORD_WEBHOOK_URL,
    username='Bruce Wayne',
    avatar_url='https://i.imgur.com/thK8erv.png'
)
hook.execute('I am Batman!')
```

![example2](https://i.imgur.com/mseg2Yx.png)

### Complete example with embeds

Finally, here is an example for posting a message with two embeds and using all available features (shortened):

```python
import datetime
from dhooks_lite import Webhook, Embed, Footer, Image, Thumbnail, Author, Field

hook = Webhook(DISCORD_WEBHOOK_URL)
e1 = Embed(
    description='Only a few years ago, scientists stumbled upon an electrical current of cosmic proportions.(...)',
    title='Universe\'s highest electric current found',
    url='https://www.newscientist.com/article/mg21028174-900-universes-highest-electric-current-found/',
    timestamp=datetime.datetime.utcnow(),
    color=0x5CDBF0,
    footer=Footer(
        'Science Department',
        'https://i.imgur.com/Bgsv04h.png'
    ),
    image=Image('https://i.imgur.com/eis1Y0P.jpg'),
    thumbnail=Thumbnail('https://i.imgur.com/2A4k28x.jpg'),
    author=Author(
        'John Scientist',
        url='https://en.wikipedia.org/wiki/Albert_Einstein',
        icon_url='https://i.imgur.com/1JoHDw1.png'
    ),
    fields=[
        Field('1st Measurement', 'Failed'),
        Field('2nd Measurement', 'Succeeded')
    ]
)
e2 = Embed(description="TOP SECRET - Do not distribute!")

hook.execute(
    'Checkout this new report from the science department:',
    username='Bruce Wayne',
    avatar_url='https://i.imgur.com/thK8erv.png',
    embeds=[e1, e2],
    wait_for_response=True
)
```

![example2](https://i.imgur.com/RoWBh2n.png)

## Installation

You can install this library directly from PyPI:

```bash
pip install dhooks-lite
```

## Documentation

For a full documentation of all classes please see the official docs [here](https://dhooks-lite.readthedocs.io/en/latest/).

## Contribution

We welcome any contribution!

If you found a bug or have a feature request please raise an issue.

If you want to help further improve this library please feel free to issue a merge request. Please adhere to the following requirements in your change:

- Code should be compliant with [PEP8](https://www.python.org/dev/peps/pep-0008/)
- Full overage by unit tests
- All classes should be immutable
- All classes and their public methods must have docstring documentation
- All changes must be documented in the Change Log


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dhooks-lite",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "discord,discordhooks,discordwebhooks,webhooks",
    "author": "",
    "author_email": "Erik Kalkoken <kalkoken87@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/69/4f/b8d58e88babd930314a4ec7dbf6190479353d69b8a2015757522a69f8e7b/dhooks_lite-1.1.0.tar.gz",
    "platform": null,
    "description": "# dhooks-lite\n\nAnother simple class wrapper for interacting with Discord webhooks.\n\n[![release](https://img.shields.io/pypi/v/dhooks-lite?label=release)](https://pypi.org/project/dhooks-lite/)\n[![python](https://img.shields.io/pypi/pyversions/dhooks-lite)](https://pypi.org/project/dhooks-lite/)\n[![pipeline status](https://gitlab.com/ErikKalkoken/dhooks-lite/badges/master/pipeline.svg)](https://gitlab.com/ErikKalkoken/dhooks-lite/-/commits/master)\n[![codecov](https://codecov.io/gl/ErikKalkoken/dhooks-lite/branch/master/graph/badge.svg?token=9YNL3HEJ5D)](https://codecov.io/gl/ErikKalkoken/dhooks-lite)\n[![Documentation Status](https://readthedocs.org/projects/dhooks-lite/badge/?version=latest)](https://dhooks-lite.readthedocs.io/en/latest/?badge=latest)\n[![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/ErikKalkoken/dhooks-lite/-/blob/master/LICENSE)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![chat](https://img.shields.io/discord/790364535294132234)](https://discord.gg/zmh52wnfvM)\n\n## Contents\n\n- [Overview](#overview)\n- [Functionality](#functionality)\n- [Examples](#examples)\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Contribution](#contribution)\n\n## Overview\n\n**dhooks-lite** is a library with a set of classes for interacting with Discord webhooks written in Python 3.\n\nThis library aims to differentiate itself from similar libraries with the following properties:\n\n- is fully tested\n- simple to use (only one way of doing things, same name of attributes and objects as in the [official Discord documentation](https://discordapp.com/developers/docs/resources/webhook#execute-webhook))\n- has logging\n- requests are automatically retried and have sensible timeouts\n- works with older Python versions\n\n## Functionality\n\nThis library provides following functionality:\n\n- Posting messages in Discord channels via webhooks (synchronous calls only)\n- Attaching Embeds to messages\n- Retrieve send reports and from Discord\n- Retrieve HTTP status and headers from Discord, e.g. for implementing rate limit handling\n\n## Examples\n\nHere are some examples on how to use dhooks-lite in your Python scripts.\n\nNote that you also find the source code of all examples in the `/examples` folder of this repo.\n\n### Hello World\n\nMinimal example for posting a message.\n\n```python\nfrom dhooks_lite import Webhook\n\nhook = Webhook(DISCORD_WEBHOOK_URL)\nhook.execute('Hello, World!')\n```\n\n![example1](https://i.imgur.com/t3mxMAJ.png)\n\n### Posting with custom avatar\n\nIn this example we are setting username and avatar.\n\n```python\nfrom dhooks_lite import Webhook\n\nhook = Webhook(\n    DISCORD_WEBHOOK_URL,\n    username='Bruce Wayne',\n    avatar_url='https://i.imgur.com/thK8erv.png'\n)\nhook.execute('I am Batman!')\n```\n\n![example2](https://i.imgur.com/mseg2Yx.png)\n\n### Complete example with embeds\n\nFinally, here is an example for posting a message with two embeds and using all available features (shortened):\n\n```python\nimport datetime\nfrom dhooks_lite import Webhook, Embed, Footer, Image, Thumbnail, Author, Field\n\nhook = Webhook(DISCORD_WEBHOOK_URL)\ne1 = Embed(\n    description='Only a few years ago, scientists stumbled upon an electrical current of cosmic proportions.(...)',\n    title='Universe\\'s highest electric current found',\n    url='https://www.newscientist.com/article/mg21028174-900-universes-highest-electric-current-found/',\n    timestamp=datetime.datetime.utcnow(),\n    color=0x5CDBF0,\n    footer=Footer(\n        'Science Department',\n        'https://i.imgur.com/Bgsv04h.png'\n    ),\n    image=Image('https://i.imgur.com/eis1Y0P.jpg'),\n    thumbnail=Thumbnail('https://i.imgur.com/2A4k28x.jpg'),\n    author=Author(\n        'John Scientist',\n        url='https://en.wikipedia.org/wiki/Albert_Einstein',\n        icon_url='https://i.imgur.com/1JoHDw1.png'\n    ),\n    fields=[\n        Field('1st Measurement', 'Failed'),\n        Field('2nd Measurement', 'Succeeded')\n    ]\n)\ne2 = Embed(description=\"TOP SECRET - Do not distribute!\")\n\nhook.execute(\n    'Checkout this new report from the science department:',\n    username='Bruce Wayne',\n    avatar_url='https://i.imgur.com/thK8erv.png',\n    embeds=[e1, e2],\n    wait_for_response=True\n)\n```\n\n![example2](https://i.imgur.com/RoWBh2n.png)\n\n## Installation\n\nYou can install this library directly from PyPI:\n\n```bash\npip install dhooks-lite\n```\n\n## Documentation\n\nFor a full documentation of all classes please see the official docs [here](https://dhooks-lite.readthedocs.io/en/latest/).\n\n## Contribution\n\nWe welcome any contribution!\n\nIf you found a bug or have a feature request please raise an issue.\n\nIf you want to help further improve this library please feel free to issue a merge request. Please adhere to the following requirements in your change:\n\n- Code should be compliant with [PEP8](https://www.python.org/dev/peps/pep-0008/)\n- Full overage by unit tests\n- All classes should be immutable\n- All classes and their public methods must have docstring documentation\n- All changes must be documented in the Change Log\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Another simple class wrapper for interacting with Discord webhooks.",
    "version": "1.1.0",
    "project_urls": {
        "Changelog": "https://gitlab.com/ErikKalkoken/dhooks-lite/-/blob/master/CHANGELOG.md",
        "Documentation": "https://dhooks-lite.readthedocs.io/en/latest/",
        "Homepage": "https://gitlab.com/ErikKalkoken/dhooks-lite",
        "Source": "https://gitlab.com/ErikKalkoken/dhooks-lite",
        "Tracker": "https://gitlab.com/ErikKalkoken/dhooks-lite/-/issues"
    },
    "split_keywords": [
        "discord",
        "discordhooks",
        "discordwebhooks",
        "webhooks"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0b1ef4cef58be27b241620a936c5f6e28115e2dc8580f186be8af78a206bdbe",
                "md5": "794d638118a6ac84d201bd943500a6c2",
                "sha256": "1e40fc74da2f9ceeed4e39d10d2d917627a535dc1d6a93ff03f7b865e3d371c9"
            },
            "downloads": -1,
            "filename": "dhooks_lite-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "794d638118a6ac84d201bd943500a6c2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10488,
            "upload_time": "2023-07-16T14:16:47",
            "upload_time_iso_8601": "2023-07-16T14:16:47.783009Z",
            "url": "https://files.pythonhosted.org/packages/b0/b1/ef4cef58be27b241620a936c5f6e28115e2dc8580f186be8af78a206bdbe/dhooks_lite-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "694fb8d58e88babd930314a4ec7dbf6190479353d69b8a2015757522a69f8e7b",
                "md5": "08c8e872560a0cac97a8f599df950171",
                "sha256": "1fee6ac0bdec54ab4800e8696270161833167ab0bd8c27a0812178f664a1ca0a"
            },
            "downloads": -1,
            "filename": "dhooks_lite-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "08c8e872560a0cac97a8f599df950171",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11213,
            "upload_time": "2023-07-16T14:16:49",
            "upload_time_iso_8601": "2023-07-16T14:16:49.603610Z",
            "url": "https://files.pythonhosted.org/packages/69/4f/b8d58e88babd930314a4ec7dbf6190479353d69b8a2015757522a69f8e7b/dhooks_lite-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-16 14:16:49",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "ErikKalkoken",
    "gitlab_project": "dhooks-lite",
    "lcname": "dhooks-lite"
}
        
Elapsed time: 0.10432s