telegramtk


Nametelegramtk JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/sdelquin/telegramtk.git
SummaryTelegram toolkit
upload_time2024-08-23 14:28:16
maintainerNone
docs_urlNone
authorSergio Delgado Quintero
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # telegramtk

**Telegram toolkit**

This package provides easy (and sync) access for the Telegram Bot API.

## Installation

```console
pip install telegramtk
```

## Setup

First of all you must [create a Telegram bot](https://core.telegram.org/bots/features#creating-a-new-bot) and grab the **bot token**.

```python
import telegramtk

telegramtk.init('<your-telegram-bot-token-here>')
```

## Send message

```python
import telegramtk

telegramtk.send_message(to, msg)
```

Notes:

- `to` is the recipient and must be a _chat id_ (integer value) or a _known name_ (string value).
- `msg` is the message (string value) and can be "Markdown" formatted.

### Error handling

If an error ocurred during the request to the Telegram API, an exception is raised. You can find this exception at:

```python
import telegramtk
from telegramtk.exceptions import TelegramError

try:
    telegramtk.send_message(to, msg)
except TelegramError as err:
    handle_error(err)
```

## Escape markdown

It's common to send Markdown content through Telegram, but sometimes we want to escape Markdown symbols in order to avoid syntax errors when parsing.

For that end, you might use the following function:

```python
from telegramtk.utils import escape_markdown

>>> escape_markdown('Just some *Markdown* _stuff_ [here](https://example.com/)')
'Just some \\*Markdown\\* \\_stuff\\_ \\[here\\]\\(https://example\\.com/\\)'
```

> 💡 Source: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/helpers.py#L45

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sdelquin/telegramtk.git",
    "name": "telegramtk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Sergio Delgado Quintero",
    "author_email": "sdelquin@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7b/c8/e621bd4668e790bb32b519016076e8ee7089b5a87be1d224ac489aa023a2/telegramtk-0.1.0.tar.gz",
    "platform": null,
    "description": "# telegramtk\n\n**Telegram toolkit**\n\nThis package provides easy (and sync) access for the Telegram Bot API.\n\n## Installation\n\n```console\npip install telegramtk\n```\n\n## Setup\n\nFirst of all you must [create a Telegram bot](https://core.telegram.org/bots/features#creating-a-new-bot) and grab the **bot token**.\n\n```python\nimport telegramtk\n\ntelegramtk.init('<your-telegram-bot-token-here>')\n```\n\n## Send message\n\n```python\nimport telegramtk\n\ntelegramtk.send_message(to, msg)\n```\n\nNotes:\n\n- `to` is the recipient and must be a _chat id_ (integer value) or a _known name_ (string value).\n- `msg` is the message (string value) and can be \"Markdown\" formatted.\n\n### Error handling\n\nIf an error ocurred during the request to the Telegram API, an exception is raised. You can find this exception at:\n\n```python\nimport telegramtk\nfrom telegramtk.exceptions import TelegramError\n\ntry:\n    telegramtk.send_message(to, msg)\nexcept TelegramError as err:\n    handle_error(err)\n```\n\n## Escape markdown\n\nIt's common to send Markdown content through Telegram, but sometimes we want to escape Markdown symbols in order to avoid syntax errors when parsing.\n\nFor that end, you might use the following function:\n\n```python\nfrom telegramtk.utils import escape_markdown\n\n>>> escape_markdown('Just some *Markdown* _stuff_ [here](https://example.com/)')\n'Just some \\\\*Markdown\\\\* \\\\_stuff\\\\_ \\\\[here\\\\]\\\\(https://example\\\\.com/\\\\)'\n```\n\n> \ud83d\udca1 Source: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/helpers.py#L45\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Telegram toolkit",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/sdelquin/telegramtk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "095a3f3d775b86587af5346d59b4397055e9940932395357d85f36f4f7078800",
                "md5": "245de5f2b7d78566b2819c6d80e7db41",
                "sha256": "0b9e45c806427724aafbe614a44b112cd0275e6e080795e8b90461057558d830"
            },
            "downloads": -1,
            "filename": "telegramtk-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "245de5f2b7d78566b2819c6d80e7db41",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4268,
            "upload_time": "2024-08-23T14:28:15",
            "upload_time_iso_8601": "2024-08-23T14:28:15.155958Z",
            "url": "https://files.pythonhosted.org/packages/09/5a/3f3d775b86587af5346d59b4397055e9940932395357d85f36f4f7078800/telegramtk-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bc8e621bd4668e790bb32b519016076e8ee7089b5a87be1d224ac489aa023a2",
                "md5": "b377f49e8b0bba061d78d260346e9f99",
                "sha256": "ae2d3ef00b2f316f15f1283d4f79f7885d0f713cfea6433416d129f6a93bda3c"
            },
            "downloads": -1,
            "filename": "telegramtk-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b377f49e8b0bba061d78d260346e9f99",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3885,
            "upload_time": "2024-08-23T14:28:16",
            "upload_time_iso_8601": "2024-08-23T14:28:16.494591Z",
            "url": "https://files.pythonhosted.org/packages/7b/c8/e621bd4668e790bb32b519016076e8ee7089b5a87be1d224ac489aa023a2/telegramtk-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-23 14:28:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sdelquin",
    "github_project": "telegramtk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "telegramtk"
}
        
Elapsed time: 3.19635s