Skip to main content

Goygram: unified Telegram runtime on Python and Rust

Project description

Python 3.14+ Rust Core License: AGPL v3 Telegram API Security

GoyGram

Ultimate split-brain Telegram framework (Python + Rust core) built for production-grade speed, control, and maximum OpSec.

Key Features

  • Split-brain architecture: ergonomic Python layer + blazing-fast Rust extension.
  • Session Eater: aggressive in-memory cleanup (zeroize strategy).
  • Vault AES-GCM: encrypted local session bootstrap.
  • TUI auth flow: terminal-first authorization workflow.
  • Proxy support: route traffic through your required network topology.
  • Dual transport: Bot API + MTProto (with API ID/API Hash) in one app runtime.
  • Dynamic DC Routing: MTProto nodes are fetched at startup from Telegram public config (no baked-in DC IP list).

Installation

pip install goygram

Quick Start

1) Bot API (token)

import asyncio
from goygram import GoyGram, filters

app = GoyGram(bot_token="123456:ABC_TOKEN")

@app.on_msg(filt=filters.text)
async def echo(msg):
    await msg.reply("Hello from Bot API")

asyncio.run(app.run())

2) MTProto (no bot token, requires API ID + API Hash)

import asyncio
from goygram import GoyGram

app = GoyGram(api_id=123456, api_hash="0123456789abcdef0123456789abcdef")  # auto-fetches Telegram DC endpoint at startup

@app.on_cmd("ping")
async def ping(msg):
    await msg.reply("pong from MTProto (api_id/api_hash)")

asyncio.run(app.run())

3) Named MTProto sessions (multi-session in one folder)

import asyncio
from goygram import GoyGram

app = GoyGram(
    api_id=123456,
    api_hash="0123456789abcdef0123456789abcdef",
    session_name="farm_worker_1",
)

asyncio.run(app.run())
  • By default, session data is stored in default.vault.
  • With session_name="farm_worker_1", session data is stored in farm_worker_1.vault.
  • If farm_worker_1.session exists, it is migrated to farm_worker_1.vault during bootstrap.

Dynamic API & Methods

GoyGram now supports all Telegram methods out of the box with dynamic dispatch:

  • Call Bot API methods directly even if they are not explicitly hardcoded:
    • await app.sendDocument(chat_id=..., document=...)
    • await app.getChat(chat_id=...)
    • await app.getUpdates(timeout=30)
  • Snake-case also works and is converted to Bot API method names:
    • await app.send_document(chat_id=..., document=...) -> sendDocument
  • MTProto actions (authorized with API ID/API Hash) are available with mt_ prefix:
    • await app.mt_get_dialogs(limit=50)
    • await app.mt_get_chat_full(chat_id=...)

This behavior is implemented through dynamic method resolution in the client core (__getattr__) and transport-aware request routing.

Developer Tools (Help)

Use built-in introspection tools:

app.help()            # pretty DX overview in console
print(dir(app))       # inspect available shortcuts + dynamic entries

or:

from goygram.utils import print_methods
print_methods(app)

With type hints on key event objects (MsgObj, CbObj, MemberObj, PollObj) and filter primitives, modern IDE autocomplete works much better out of the box.

Filters

goygram.filters supports composable boolean operators:

from goygram import filters

smart_filter = filters.text & ~filters.me
another = filters.text | filters.me

@app.on_msg(filt=smart_filter)
async def handler(msg):
    await msg.reply("Filtered")

License

See LICENSE.

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

goygram-0.4.2.tar.gz (30.3 kB view details)

Uploaded Source

Built Distributions

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

goygram-0.4.2-cp311-abi3-win_amd64.whl (170.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

goygram-0.4.2-cp311-abi3-manylinux_2_34_x86_64.whl (254.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

goygram-0.4.2-cp311-abi3-macosx_11_0_arm64.whl (236.7 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file goygram-0.4.2.tar.gz.

File metadata

  • Download URL: goygram-0.4.2.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for goygram-0.4.2.tar.gz
Algorithm Hash digest
SHA256 1f6f19f3e9e294f8021f5473878a146ab8a3970b1804eeab2abe5296f808b039
MD5 6d6d4cb6e34842b821c19a1d395ace41
BLAKE2b-256 8590626a0d601fb3c801e6d35881bc41917007318ba8f660ccb7871b0947fe82

See more details on using hashes here.

File details

Details for the file goygram-0.4.2-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: goygram-0.4.2-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 170.5 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for goygram-0.4.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 30a51f9db14c11cae75d718f87bf572a01e9e79521a4acff80bfe2a421dfa3fa
MD5 653f006326884dd7b962ac1eb8b321d1
BLAKE2b-256 e7ae300e42e3763f3a2dbfb5f3f0e2d47daf7b1c9ac79516cfca01bd389b0a4a

See more details on using hashes here.

File details

Details for the file goygram-0.4.2-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for goygram-0.4.2-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6d0e779cd18b2f2881cedc4825dd827d7f99490172683d2b02db6ac089af662f
MD5 46d07d678ee8f120c8c2fe55f94a538b
BLAKE2b-256 59c340c5946b6fbab156f67566bd21be580b5feb794fc96f8ad045937b274337

See more details on using hashes here.

File details

Details for the file goygram-0.4.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for goygram-0.4.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 496aec1dff9657d9ccc36a6dd0edb8bc0317f57ff8ff2759afb764c8529e3ac1
MD5 634a93fa907e7189efb42c33d8188a12
BLAKE2b-256 95e97a972edd02a460151431c6e3a9e329a992cae89d4acc044f389c45df2915

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