Skip to main content

archbyte

A Python library for Telegram automation and group management.

Author: Cyrus Arch

Installation

pip install archbyte

Features

  • Session-based authentication with persistent login
  • Bulk leave operations with rate limiting
  • Whitelist protection for important chats
  • Keyword-based spam detection and auto-leave
  • Activity logging and tracking
  • Async/await support with context managers

Quick Start

import asyncio
from archbyte import Telecemper

async def main():
    client = Telecemper(
        api_id='YOUR_API_ID',
        api_hash='YOUR_API_HASH',
        phone_number='+1234567890'
    )
    
    # First time authentication
    await client.request_code()
    code = input("Enter code: ")
    message, session = await client.authenticate(code)
    
    # Save session for future use
    print(f"Session: {session}")
    
    await client.disconnect()

asyncio.run(main())

Configuration

Get your API credentials from https://my.telegram.org

Required:

  • api_id - Telegram API ID
  • api_hash - Telegram API hash
  • phone_number - Phone number with country code

Usage Examples

Using saved session

client = Telecemper(
    api_id='YOUR_API_ID',
    api_hash='YOUR_API_HASH',
    phone_number='+1234567890',
    session_string='YOUR_SAVED_SESSION'
)

await client.login_with_session()

Whitelist management

# Add chats to whitelist (by ID, username, or title)
client.add_to_whitelist(123456789, "family_group", "Work Team")

# Load from file
client.load_whitelist_from_file("whitelist.txt")

# Save to file
client.save_whitelist_to_file("whitelist.txt")

# View protected chats
protected = client.get_whitelist()

Bulk operations

# Leave all chats except whitelisted
summary = await client.leave_all_chats(
    delay_range=(1, 5),
    respect_whitelist=True
)

print(f"Left: {summary['left_count']}")
print(f"Protected: {summary['skipped_count']}")

Spam detection

# Enable auto-leave on spam keywords
keywords = ['free giveaway', 'get rich quick', 'limited offer']
await client.enable_spam_detection(keywords)

# Disable spam detection
client.disable_spam_detection()

List all chats

chats = await client.list_all_chats()
for chat in chats:
    status = "Protected" if chat['protected'] else "Unprotected"
    print(f"{chat['title']}: {status}")

View logs

logs = client.get_logs()
print(logs['leave_log'])
print(logs['join_log'])
print(logs['activity_log'])

Whitelist File Format

Create a whitelist.txt file with one identifier per line:

# Comments start with #
123456789
family_chat
Work Team
987654321

API Reference

Authentication Methods

  • request_code() - Request verification code
  • authenticate(code) - Authenticate with code, returns session string
  • login_with_session() - Login with saved session

Whitelist Methods

  • add_to_whitelist(*identifiers) - Add chats to whitelist
  • remove_from_whitelist(*identifiers) - Remove from whitelist
  • clear_whitelist() - Clear all whitelist items
  • get_whitelist() - Get list of whitelisted items
  • load_whitelist_from_file(filepath) - Load from file
  • save_whitelist_to_file(filepath) - Save to file

Operation Methods

  • leave_all_chats(delay_range, respect_whitelist) - Leave all groups/channels
  • list_all_chats(include_protected) - List all chats with status
  • enable_spam_detection(keywords) - Enable auto-leave on spam
  • disable_spam_detection() - Disable spam detection
  • get_logs() - Retrieve activity logs

Utility Methods

  • start() - Start the client
  • disconnect() - Disconnect the client

Context Manager

async with Telecemper(api_id, api_hash, phone, session) as client:
    await client.leave_all_chats()
    # Automatically disconnects on exit

Logging

Configure Python logging to see detailed activity:

import logging

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

Best Practices

  • Store session strings securely, never commit to version control
  • Use delays between operations to respect rate limits
  • Always whitelist important chats before bulk operations
  • Monitor logs for unexpected behavior
  • Use context managers for automatic cleanup

License

MIT License

Metadata

Release files for archbyte 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for archbyte 0.2.2
File Size Uploaded Provenance
archbyte-0.2.2.tar.gz 7.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for archbyte 0.2.2
File Interpreter ABI Platform
archbyte-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / archbyte-0.2.2.tar.gz

Download URL archbyte-0.2.2.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9f78c7c5afe6a7c326ae5ecc04b728e0c2f4af936eb76c2c5827f5be1feaa702
BLAKE2b-256 checksum
How to use checksums
38d9a9374cbb8af6bbc17abec343ddcbe7aa9b2a3d38e9830c506329bd78acc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / archbyte-0.2.2-py3-none-any.whl

Download URL archbyte-0.2.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b46c9201a22c72cfa70042c7699c4f35a4aeffd3db633797c4432408d48a1687
BLAKE2b-256 checksum
How to use checksums
d8077107f6e2cc122904d9359e96e632514be44d9e7bb2a8cfccd97839e8a99e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for archbyte 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page