Goygram: unified Telegram runtime on Python and Rust
Project description
GoyGram
GoyGram is a Telegram framework with one clean entrypoint for user code and split low-level lanes under the hood: Bot API on aiohttp, MT transport on raw sockets, Rust for frame and crypto primitives.
Build
python -m venv .venv
source .venv/bin/activate
pip install -U pip maturin aiohttp pydantic
maturin develop
Quick Start
import asyncio
from goygram import GoyGram, InlineKbd, LinkOpts
app = GoyGram(
bot_token="123456:BOT_TOKEN",
)
kbd = InlineKbd().add_btn("Ping", data="ping")
links = LinkOpts(above=True, large=True)
@app.on_msg
async def echo(msg):
if not msg.text:
return
if msg.text == "/start":
await app.send_msg(msg.chat_id, "hello https://example.com", kbd=kbd, link_options=links, via=msg.src)
return
await msg.reply(f"rx: {msg.text}")
asyncio.run(app.run())
Commands And Callbacks
@app.on_cmd("start", "help")
async def boot(msg):
await msg.reply("ready")
@app.on_cb
async def taps(cb):
if cb.data == "ping":
await cb.answer("pong")
await cb.edit("updated")
Public API
from goygram import GoyGram, InlineKbd, ReplyKbd, Btn
GoyGram(...) accepts flat config:
bot_tokenmt_hostmt_portmt_keymt_iv
Main calls:
@app.on_msg@app.on_cmd("start")@app.on_cb@app.on_poll@app.on_memberawait app.send_msg(chat_id, text, kbd=..., via=...)await app.send_msg(chat_id, text, link_options=...)await app.send_photo(chat_id, photo, caption=...)await app.send_doc(chat_id, document, caption=...)await app.send_media_group(chat_id, media)await app.answer_cb(cb_id, text=...)await app.edit_text(chat_id, msg_id, text)await app.set_webhook(url)await app.delete_webhook()await app.get_webhook_info()await msg.reply(text, kbd=...)await msg.delete()await app.run()
Extra UI helpers:
InlineKbdReplyKbdForceReplyReplyGone
Package Layout
.
├── ext_rust
│ ├── Cargo.toml
│ └── src/lib.rs
├── goygram
│ ├── __init__.py
│ ├── client.py
│ ├── api
│ ├── core
│ ├── tl
│ ├── types
│ └── vendor
├── tools
│ ├── gen_botapi.py
│ └── gen_mtproto.py
└── tests
Codegen
python tools/gen_botapi.py
python tools/gen_mtproto.py
Generated targets:
goygram/api/types.pygoygram/api/methods.pygoygram/tl/schema.py
Tests
python -m unittest tests.test_matrix -v
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.3.5.tar.gz.
File metadata
- Download URL: goygram-0.3.5.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ee930df86360efc60081e75db41010e2ae9f11d73b50ac79be87b15b05f2175
|
|
| MD5 |
f29f4ec886d8b25379db7d9885656ee8
|
|
| BLAKE2b-256 |
a2238e854cbc1095bc2533ef2f13ce3ac720d8689b9fcfb84fcb7495425632e5
|
File details
Details for the file goygram-0.3.5-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: goygram-0.3.5-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 156.5 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 |
aad9a66eeaf32d54574fcbd8304728411dbcdda9eb1076f3a0ce7593b53167a5
|
|
| MD5 |
daae00ca0388a44e47cdc45a908c62d0
|
|
| BLAKE2b-256 |
aeb2ed1fd5f7e6fa0823397ece8c69ae3185db2dc6447eed410491f7892a3a84
|
File details
Details for the file goygram-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: goygram-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 240.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 |
13eaa14b846c3a7829b4c0c98ca8c0fb3cb0ea43bfb61744ae1248ccc65facff
|
|
| MD5 |
5cc2f9d7a8eea0758246f0db75f26614
|
|
| BLAKE2b-256 |
2ebc6e59e93039bad8e6bc45065a93639b468e73d2f30b1b8a6433e5e9385bfe
|
File details
Details for the file goygram-0.3.5-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: goygram-0.3.5-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 223.2 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 |
dc9e9836a8fc86269056952fce5c1998155280c747bc43a0fa13623210adb1b3
|
|
| MD5 |
d3be0f0ca2fb53c121b26b4c3308ac30
|
|
| BLAKE2b-256 |
e16c660558fc88de0bb4834d77b43977f7dc593c03c00697ee9d1db055066d9f
|