Skip to main content

TLGBot is a Python library for creating Telegram bots with ease. This library simplifies the interaction with the Telegram Bot API, allowing you to send messages, edit group descriptions, and more.

Project description

TLGBot - Telegram Bot Python Library

License

TLGBot is a Python library for creating Telegram bots with ease. This library simplifies the interaction with the Telegram Bot API, allowing you to send messages, edit group descriptions, and more.

Installation

You can install TLGBot using pip:

pip install tlgbot

Getting Started

  1. Create a Telegram bot and obtain the API token. You can do this by talking to the BotFather on Telegram.

  2. Import the TLGBot class and create an instance with your API token.

from tlgbot.tlgbot import TLGBot

# Replace 'YOUR_API_TOKEN' with your actual bot API token
bot = TLGBot('YOUR_API_TOKEN')

Use the library's functions to interact with your bot.

Usage

Sending a Message

Send a text message to a chat by specifying the chat ID and message text:

chat_id = 'YOUR_CHAT_ID'  # Replace with the chat ID you want to send the message to
message = 'Hello, Telegram!'
bot.send_message(chat_id, message)

Sending a Photo

Send a photo to a chat by specifying the chat ID, the path to the photo file, and an optional caption:

chat_id = 'YOUR_CHAT_ID'  # Replace with the chat ID you want to send the photo to
photo_path = 'path/to/your/photo.jpg'  # Replace with the actual file path
caption = 'Check out this cool photo!'
bot.send_photo(chat_id, photo_path, caption)

Editing Group Description

Edit the description of a group chat by specifying the chat ID and the new description:

chat_id = 'YOUR_CHAT_ID'  # Replace with the chat ID of the group
new_description = 'This is our updated group description.'
if bot.edit_about(chat_id, new_description):
    print('Group description edited successfully.')
else:
    print('Error editing group description.')

Responding to Last Message

Reply to the last message in a chat by specifying the chat ID and the reply message:

chat_id = 'YOUR_CHAT_ID'  # Replace with the chat ID you want to respond in
reply_message = 'Thanks for your message!'
bot.reply_last_msg(chat_id, reply_message)

EXAMPLE PRODUCTION CODE

from tlgbot.tlgbot import TLGBot

# Define tu token
token = 'Your_Bot_Token'

# Obtén el último chat ID utilizando la función last_id
chat_id = TLGBot.last_id(token)

if chat_id is not None:
    print(f'Último chat ID: {chat_id}')

    # Define un mensaje de respuesta
    response_message = 'Hello test'

    # Envia el mensaje al último chat ID
    TLGBot.send_message(TLGBot(token), chat_id, response_message)
    print('Mensaje enviado exitosamente.')
else:
    print('No se pudo obtener el chat ID.')

License

This library is available under the MIT license.

Support

If you have any questions, suggestions, or need help with this library, please create an issue on the Github Repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tlgbot-1.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tlgbot-1.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tlgbot-1.3.tar.gz.

File metadata

  • Download URL: tlgbot-1.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tlgbot-1.3.tar.gz
Algorithm Hash digest
SHA256 e20c9909eb6fd05f20e3f0dfe1266a576d0893e1a5756aaa76946905b6201118
MD5 429f813df61a64aa569e35367f022ea4
BLAKE2b-256 9b1f305f6fce100c6f6ebbd93afafa241e9a7da79b467a0d0510106f7fab977c

See more details on using hashes here.

File details

Details for the file tlgbot-1.3-py3-none-any.whl.

File metadata

  • Download URL: tlgbot-1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tlgbot-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2542adc000ae9a8bd68bcfce00c13cfc77174f5a85e34a82bf5acad153e693d3
MD5 bcde6847124b3379524900677a90ec47
BLAKE2b-256 5ce79949194cf74c1ce3b9adcd50ad97238fbce6eac437b4991811f7f43848e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page