Skip to main content

A package to fetch Telegram group chat ID, user ID, username, and message info

Project description

telegramid

telegramid is a Python package for easily fetching Telegram bot information such as chat ID, user ID, username, and message details using the Telegram Bot API.

Overview

Managing interactions with Telegram bots often involves retrieving specific information such as chat IDs, user IDs, usernames, and details about incoming messages. The telegramid package simplifies this process by providing straightforward functions to fetch these details using the Telegram Bot API.

Usage

Fetching Chat ID, User ID, and Username

To retrieve essential information about the Telegram bot's interactions:

from telegramid import telegram_chat

# Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your actual Telegram bot token
token = "YOUR_TELEGRAM_BOT_TOKEN"

# Fetch chat ID
chat_id = telegram_chat.id(token)
if chat_id:
    print(f"Chat ID: {chat_id}")
else:
    print("Failed to fetch chat ID within the specified time.")

# Fetch user ID
user_id = telegram_chat.user_id(token)
if user_id:
    print(f"User ID: {user_id}")
else:
    print("Failed to fetch user ID within the specified time.")

# Fetch username
username = telegram_chat.username(token)
if username:
    print(f"Username: {username}")
else:
    print("Failed to fetch username within the specified time.")

Fetching Message Information

To retrieve detailed information about the latest message received by the bot:

# Fetch message info
message_info = telegram_chat.message_info(token)
if message_info:
    print(f"Telegram group ID: {message_info['group_id']}")
    print(f"Telegram group username: {message_info['group_username']}")
    print(f"Message sender user ID: {message_info['user_id']}")
    print(f"Message sender username: {message_info['username']}")
else:
    print("Failed to fetch message info within the specified time.")

Explanation:

  • Overview: Provides a brief introduction to the package's purpose and benefits.
  • Usage: Offers practical examples of using the package functions to fetch essential Telegram bot information.
  • Functionality Details: Explains the package's features, including synchronous fetching, retry mechanism, handling timeouts, and the structure of returned message information.
  • Additional Information: Provides guidance on ensuring bot permissions and refers users to official Telegram Bot API documentation for more information.
  • License: Mentions the licensing terms under which the package is distributed.

This README.md file is designed to provide comprehensive information and guidance for users of the telegramid package, enhancing clarity and usability.

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

telegramid-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

telegramid-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file telegramid-1.0.0.tar.gz.

File metadata

  • Download URL: telegramid-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for telegramid-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ba754f6819d8e52ec812695acec15e6a4bd905177f0494ff2e65692f3726c765
MD5 739a514e72b5b36734c4d37a703c733f
BLAKE2b-256 857fd2ed29e66ede70290d0729b9c9c768fdb1faa0d36c3947d6ebd4c7dce981

See more details on using hashes here.

File details

Details for the file telegramid-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: telegramid-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for telegramid-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07fefee86975cd0b2a7023bc761d5b5823306ae829e84ff05bc7ae1b15fbaf88
MD5 14b10f79d0d0039a0831aa2552a8481a
BLAKE2b-256 a1dce7543f40ce7c739b5ae87d1524864d62a12a4a7da1f9eff897e2b7670022

See more details on using hashes here.

Supported by

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