Grampo
A Python Telegram API Library , with official Telegram APIs.
Installation
pip install Grampo
Quick start
import asyncio
from Grampo import (
TelegramApp,
Sessions,
CreateNewSession,
UseCurrentSession,
GrampoOptions
)
async def main():
telegram=TelegramApp(None,['http','127.0.0.1',10809],options=GrampoOptions())
# If there is a session, it will start it, otherwise,
# a new session will be created and saved.
await telegram.start_telegram('+9811122233')
me=await telegram.get_me()
print(me.first_name)
await telegram.disconnect()
if __name__=="__main__":
asyncio.run(main())
Connect to a saved session:
async def main():
telegram=TelegramApp('+9811122233',['http','127.0.0.1',10809])
await telegram.connect_telegram()
me=await telegram.get_me()
print(me.first_name)
await telegram.disconnect()
if __name__=="__main__":
asyncio.run(main())
Convert telethon session to tdata (desktop session):
async def main():
telegram=TelegramApp('+9811122233',['http','127.0.0.1',10809])
await telegram.start_telegram()
me=await telegram.get_me()
print(me.first_name)
# Use the current session
tdesk=await telegram.convert_to_tdata('E:/Telegram/TD-DATAS')
# # Create a new desktop session
# tdesk=await telegram.convert_to_tdata(
# output_dir='E:/Telegram/TD-DATAS',
# new_session=True,
# password='password')
# Use the current session
tdesk=await telegram.convert_to_tdata(output_dir='E:/Telegram/TD-DATAS',new_session=False)
await telegram.disconnect()
client:TelegramApp=await tdesk.ToTelethon(None,flag=UseCurrentSession,api=tdesk.api,proxy=['http','127.0.0.1',10809])
await client.connect()
await client.PrintSessions()
if __name__=="__main__":
asyncio.run(main())
Get login code:
import asyncio
from Grampo import TelegramApp
async def main():
telegram=TelegramApp('+9811122233',['http','127.0.0.1',10809])
await telegram.connect_telegram()
me=await telegram.get_me()
print(me.first_name)
print('Now apply for login in the TelegramApp app:')
code=await telegram.get_login_code()
print('Login Code: ', code)
await telegram.disconnect()
if __name__=="__main__":
asyncio.run(main())
Manage saved sessions:
SESSIONS=Sessions('sessions.ses')
session=SESSIONS.get_one(phone='+9811122233')
print(f"Name: {session.first_name:<15} | Is bot: {'YES' if session.is_bot else 'NO':<3} | status: {session.status}")
all_sessions=SESSIONS.get_many()
for session in all_sessions:
print(f"Name: {session.first_name:<15} | Is bot: {'YES' if session.is_bot else 'NO':<3} | status: {session.status}")
active_sessions=SESSIONS.get_many(status='ACTIVE')
inactive_sessions=SESSIONS.get_many(status='INACTIVE')
bot_sessions=SESSIONS.get_many(is_bot=True)
random_session=SESSIONS.get_one(random=True, status='ACTIVE',is_bot=False)
first_5_sessions=SESSIONS.get_many(limit=5, status='ACTIVE',is_bot=False)
delete_session=SESSIONS.delete(is_bot=True)
print(f'Deleted {delete_session} session !')
delete_all_session=SESSIONS.delete(delete_all=True)
print(f'Deleted {delete_all_session} session !')
delete_inactive_session=SESSIONS.delete(status='INACTIVE')
print(f'Deleted {delete_inactive_session} session !')
update_session=SESSIONS.update({'status':'INACTIVE'},is_bot=True)
print(f'Update {update_session} session !')
update_session=SESSIONS.update({'status':'INACTIVE'},phone='+9811111')
print(f'Update {update_session} session !')
Powered by Abbas Bachari.
Metadata
Release files for Grampo 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grampo-1.0.0.tar.gz | 79.9 kB | Without provenance | Details for grampo-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grampo-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for grampo-1.0.0-py3-none-any.whl |
Total release size: 167.7 kB
Release files / grampo-1.0.0.tar.gz
| Download URL | grampo-1.0.0.tar.gz |
|---|---|
| Size | 79.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a62ed44e58aa12906b769b6293150e935a628be84b7cfa151f426e64212a4937
|
|
BLAKE2b-256 checksum How to use checksums |
ba7ca8fb57f223bf87974107bd5be52e72678086952f2e2f6bc0160331195ac1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / grampo-1.0.0-py3-none-any.whl
| Download URL | grampo-1.0.0-py3-none-any.whl |
|---|---|
| Size | 87.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd0842f241a2957c9f75080a2f23b2b9bf3eda0a431d2258c71ce8bc3d3d1780
|
|
BLAKE2b-256 checksum How to use checksums |
c41cf23f86e8b3a4411ab7a22c04c1b43ac0a6e9a5735ffed1747f9dd6fbce76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for Grampo 1.0.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.