It is a library that allows you to send logging logs to Telegram
Project description
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:
pip install telegram-bot-logger
Usage
import telegram_bot_logger
import logging
logger: logging.Logger = logging.getLogger("telegram_bot_logger_example")
handler: telegram_bot_logger.TelegramMessageHandler = telegram_bot_logger.TelegramMessageHandler(
bot_token = "YOUR_BOT_TOKEN",
chat_ids = [
12345678,
"@username"
],
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 telegram_bot_logger.formatters.FormatType.TEXT, # Optional, also can be "DOCUMENT", by default it is "TEXT"
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")
Replace YOUR_BOT_TOKEN
and chat_ids
with your actual bot token and chat ID. You can obtain a bot token by creating a new bot on Telegram and obtaining it from the BotFather.
Stay Updated
For the latest news and updates, follow my Telegram Channel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for telegram_bot_logger-0.0.2.post0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | efce611abba7c0cdd1a7c1a57a41c3dfdf7750166fd6cf97aed7a81c20654ede |
|
MD5 | bceaf00f391f4730ba15874ccf222c28 |
|
BLAKE2b-256 | 5cafec37c650070b62b9aef4bb9e0ba57961aa817ef5e020085e85ca0e6c893c |
Close
Hashes for telegram_bot_logger-0.0.2.post0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 423bed2ec2d3aa5fbe7f0220e1bf5756e25f0869d69d30a0b2f065606e1fd8f7 |
|
MD5 | 77e9ccda34c026260333e75a7408332a |
|
BLAKE2b-256 | d1701c376af7fdf4a83babc743b2acb41191b73808d66b11d92e81d4754941a4 |