telegram-bot-logger


Nametelegram-bot-logger JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/arynyklas/telegram_bot_logger
SummaryIt is a library that allows you to send logging logs to Telegram
upload_time2023-12-06 15:36:27
maintainer
docs_urlNone
authorAryn Yklas
requires_python>=3.7
license
keywords telegram logger logging telegram_logger
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Telegram Bot Logger

[![PyPI Version](https://img.shields.io/pypi/v/telegram-bot-logger.svg)](https://pypi.org/project/telegram-bot-logger/)
[![Python Version](https://img.shields.io/pypi/pyversions/telegram-bot-logger.svg)](https://pypi.org/project/telegram-bot-logger/)

Telegram Bot Logger is a Python library that allows you to send logging logs to Telegram using the Bot API. It simplifies the process of integrating Telegram bot notifications into your Python applications, making it easy to monitor and manage your application's logs.


## Installation

You can install `telegram_bot_logger` using pip:

```bash
pip install telegram-bot-logger
```


## Usage

```python
import telegram_bot_logger

import logging


logger = logging.getLogger("telegram_bot_logger_example")

handler = telegram_bot_logger.TelegramMessageHandler(
    bot_token = "YOUR_BOT_TOKEN", # Required; bot's token from @BotFather
    chat_ids = [
        12345678,
        "@username"
    ], # Required; you can pass id as integer or username as string
    api_server = telegram_bot_logger.api_server.TelegramAPIServer(
        base = "https://api.telegram.org/bot{bot_token}/{method}"
    ), # Optional; set by default
    format_type = "text" or "TEXT" or telegram_bot_logger.formatters.FormatType.TEXT, # Optional; also can be "DOCUMENT", by default it is "TEXT"
    document_name_strategy = "timestamp" or "TIMESTAMP" or telegram_bot_logger.formatters.DocumentNameStrategy.TIMESTAMP, # Optional; used to define documents' names; also can be "ARGUMENT", by default it is "TIMESTAMP"
    proxies = {
        "http://": "http://localhost:8080"
    } or "http://localhost:8080", # Optional; "dict[scheme, url]" or just "url"
    formatter = formatters.TelegramHTMLTextFormatter(), # Optional; you can create your own class inherited from formatters.TelegramBaseFormatter and pass it
    additional_body = {
        "reply_to_message_id": 1
    } # Optional; additional request body on sendMessage and sendDocument
)

logger.setLevel(
    level = logging.DEBUG
)

logger.addHandler(handler)


logger.debug("debug-message")
# Or:
logger.debug("debug-message", 0) # 0 is argument; to use this feature you need to set format_type = formatters.FormatType.DOCUMENT and document_name_strategy = formatters.DocumentNameStrategy.ARGUMENT
```

Replace `YOUR_BOT_TOKEN` and `chat_ids` with your actual bot token and chat IDs. You can obtain a bot token by creating a new bot on Telegram and obtaining it from the [BotFather](https://t.me/BotFather).


## Stay Updated

For the latest news and updates, follow my [Telegram Channel](https://t.me/aryn_dev).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arynyklas/telegram_bot_logger",
    "name": "telegram-bot-logger",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "telegram,logger,logging,telegram_logger",
    "author": "Aryn Yklas",
    "author_email": "arynyklas@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "# Telegram Bot Logger\r\n\r\n[![PyPI Version](https://img.shields.io/pypi/v/telegram-bot-logger.svg)](https://pypi.org/project/telegram-bot-logger/)\r\n[![Python Version](https://img.shields.io/pypi/pyversions/telegram-bot-logger.svg)](https://pypi.org/project/telegram-bot-logger/)\r\n\r\nTelegram Bot Logger is a Python library that allows you to send logging logs to Telegram using the Bot API. It simplifies the process of integrating Telegram bot notifications into your Python applications, making it easy to monitor and manage your application's logs.\r\n\r\n\r\n## Installation\r\n\r\nYou can install `telegram_bot_logger` using pip:\r\n\r\n```bash\r\npip install telegram-bot-logger\r\n```\r\n\r\n\r\n## Usage\r\n\r\n```python\r\nimport telegram_bot_logger\r\n\r\nimport logging\r\n\r\n\r\nlogger = logging.getLogger(\"telegram_bot_logger_example\")\r\n\r\nhandler = telegram_bot_logger.TelegramMessageHandler(\r\n    bot_token = \"YOUR_BOT_TOKEN\", # Required; bot's token from @BotFather\r\n    chat_ids = [\r\n        12345678,\r\n        \"@username\"\r\n    ], # Required; you can pass id as integer or username as string\r\n    api_server = telegram_bot_logger.api_server.TelegramAPIServer(\r\n        base = \"https://api.telegram.org/bot{bot_token}/{method}\"\r\n    ), # Optional; set by default\r\n    format_type = \"text\" or \"TEXT\" or telegram_bot_logger.formatters.FormatType.TEXT, # Optional; also can be \"DOCUMENT\", by default it is \"TEXT\"\r\n    document_name_strategy = \"timestamp\" or \"TIMESTAMP\" or telegram_bot_logger.formatters.DocumentNameStrategy.TIMESTAMP, # Optional; used to define documents' names; also can be \"ARGUMENT\", by default it is \"TIMESTAMP\"\r\n    proxies = {\r\n        \"http://\": \"http://localhost:8080\"\r\n    } or \"http://localhost:8080\", # Optional; \"dict[scheme, url]\" or just \"url\"\r\n    formatter = formatters.TelegramHTMLTextFormatter(), # Optional; you can create your own class inherited from formatters.TelegramBaseFormatter and pass it\r\n    additional_body = {\r\n        \"reply_to_message_id\": 1\r\n    } # Optional; additional request body on sendMessage and sendDocument\r\n)\r\n\r\nlogger.setLevel(\r\n    level = logging.DEBUG\r\n)\r\n\r\nlogger.addHandler(handler)\r\n\r\n\r\nlogger.debug(\"debug-message\")\r\n# Or:\r\nlogger.debug(\"debug-message\", 0) # 0 is argument; to use this feature you need to set format_type = formatters.FormatType.DOCUMENT and document_name_strategy = formatters.DocumentNameStrategy.ARGUMENT\r\n```\r\n\r\nReplace `YOUR_BOT_TOKEN` and `chat_ids` with your actual bot token and chat IDs. You can obtain a bot token by creating a new bot on Telegram and obtaining it from the [BotFather](https://t.me/BotFather).\r\n\r\n\r\n## Stay Updated\r\n\r\nFor the latest news and updates, follow my [Telegram Channel](https://t.me/aryn_dev).\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "It is a library that allows you to send logging logs to Telegram",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/arynyklas/telegram_bot_logger"
    },
    "split_keywords": [
        "telegram",
        "logger",
        "logging",
        "telegram_logger"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35904212a8f2decc39b91f786dad7f3a5ad3478c537e823be9a5754e026fc5f2",
                "md5": "41c4dff84835470a4d7aa57fec609b22",
                "sha256": "2b302c13546f876a1855a161e162c7d7244e034a2a006e58b4593315ba3d090f"
            },
            "downloads": -1,
            "filename": "telegram_bot_logger-0.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "41c4dff84835470a4d7aa57fec609b22",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 7428,
            "upload_time": "2023-12-06T15:36:27",
            "upload_time_iso_8601": "2023-12-06T15:36:27.759538Z",
            "url": "https://files.pythonhosted.org/packages/35/90/4212a8f2decc39b91f786dad7f3a5ad3478c537e823be9a5754e026fc5f2/telegram_bot_logger-0.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-06 15:36:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arynyklas",
    "github_project": "telegram_bot_logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        }
    ],
    "lcname": "telegram-bot-logger"
}
        
Elapsed time: 0.15834s