A Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram.
Project description
Telegram MTProto API Framework for Python
A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram
Homepage
•
Documentation
•
Releases
•
News
Pyrography
Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
import asyncio
from pyrography import Client, filters, idle
# Creating a client instance to control your bot.
# NOTE: Get your `api_id` and `api_hash` credentials on: my.telegram.org
client = Client(
name='your_session_name',
api_id=...,
api_hash=...
)
@client.on_message(filters.command('start'))
async def ask_user_name(client, message):
# Ask the user age.
asking = message.ask("What's your name?")
# Getting ask message and answer message.
# TIP: you can to use `async for` too!
ask, answer = await anext(asking)
# Getting message text.
user_name = answer.text
# Replying message.
await answer.reply(f'Nice name, {user_name}!')
async def main():
# Start MTProto connection.
await client.start()
# Listen all command handlers.
await idle(client)
# When idle() is terminated, stop the client.
await client.stop()
if __name__ == '__main__':
# Getting asyncio event loop.
loop = asyncio.get_event_loop()
# Run main() function until complete it.
loop.run_until_complete(main())
Pyrography is a modern, elegant and asynchronous MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Python.
Why should you use Pyrography?
1. Stop safety
Pyrography is the only mtproto library currently that when pressing CTRL + C
to interrupt the program, it will wait for pending commands to finish, preventing anything from being incomplete.
To most performance and others
TgCrypto
A Cryptography Library written in C as a Python extension. It is designed to be portable, fast, easy to install and use. TgCrypto is intended for Pyrogram and implements the cryptographic algorithms Telegram requires.
Automatically installed, ignore it.
Uvloop
A fast, drop-in replacement of the built-in asyncio event loop. uvloop is implemented in Cython and uses libuv under the hood.
Install it with pip install uvloop
, import it and call uvloop.install()
in your main script.
Latency
On hosting, choose an region close to Miami to your machine.
Wonderful logging
Use the rich
library to have pretty logs.
Automatically installed and default setted on log_level
client parameter, set with logging.NOTSET
to disable it.
import logging
from rich.logging import RichHandler
logging.basicConfig(
level=logging.INFO,
format="%(message)s",
handlers=[RichHandler()]
)
log = logging.getLogger(__name__)
log.info("Hello, World!")
Installing
Pypi
pip install pyrography
Github
pip3 install git+https://github.com/d3cryptofc/pyrography
Support Official Pyrogram
If you'd like to support the official Pyrogram, you can consider:
Resources
- Check out the docs at https://docs.pyrogram.org to learn more about Pyrogram, get started right away and discover more in-depth material for building your client applications.
- Join the official channel at https://t.me/pyrogram and stay tuned for news, updates and announcements.
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 Distribution
File details
Details for the file Pyrography-1.0.0.tar.gz
.
File metadata
- Download URL: Pyrography-1.0.0.tar.gz
- Upload date:
- Size: 352.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32562c3c71035cc416acfb4b174ec0f37b3886c3a633c914619a7cd76735a91c |
|
MD5 | 27801783d0637fdb9b6b515b9a0a8d0e |
|
BLAKE2b-256 | cb5364bfbe324cbd76d423fc2029ab412f097e9fdb67a9a1064c4893eeaa001e |
File details
Details for the file Pyrography-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: Pyrography-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 263b6b13d771ec7506407c13880cdb3be58f17a0833eaff7329736627c198cd6 |
|
MD5 | 214eaff147134b40bf62b5541f963a29 |
|
BLAKE2b-256 | 1eae9b503f43c23122308726711f23a0ec22a04954557abc2757bb71a2bc4f77 |