Goygram: unified Telegram runtime on Python and Rust
Project description
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 infarm_worker_1.vault. - If
farm_worker_1.sessionexists, it is migrated tofarm_worker_1.vaultduring 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
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 Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file goygram-0.4.7.tar.gz.
File metadata
- Download URL: goygram-0.4.7.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2161bfa671c2ef1619d6c9215c2af467ca9c7be84b90c3ac3a9a2195db21b1ba
|
|
| MD5 |
3e2637a568e11e9efce97b9d35fbc4db
|
|
| BLAKE2b-256 |
d79d1c349172e87bd6b01e9b03b9d149ee7372f2b89e878cf8e3b25e20e85cc0
|
File details
Details for the file goygram-0.4.7-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: goygram-0.4.7-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 170.9 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ae31467e430966cfbc017e101c0a30316bcbcce1ff90b6142535053a1955aaf
|
|
| MD5 |
aec18da060319d8b964f4bc707030319
|
|
| BLAKE2b-256 |
566a8d2cffbe875fcf12bafc71850e3f5eea9760b9df4e7484ab92f051248313
|
File details
Details for the file goygram-0.4.7-cp311-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: goygram-0.4.7-cp311-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 254.7 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60adcd76c9f27d59bbe9618890257c4dd142778bf7d41c5b405b789fb644f51e
|
|
| MD5 |
fc4bb2deb010a5282dadcecdef7e8ed2
|
|
| BLAKE2b-256 |
1b56221eeec7bb36fb1bbc156b4a639f2fb2919748c01f22b070cd4df767d46d
|
File details
Details for the file goygram-0.4.7-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: goygram-0.4.7-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 237.0 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5f87a4bd4e9bf93717b2136d580761d96154751134b8f5c436d120f49fff85d
|
|
| MD5 |
8a3c1f0cb3938c24cc6cd37770996847
|
|
| BLAKE2b-256 |
79a84e78548b007c639fa860883207088ba00e1985696cfc0ed4423959fc3b92
|