Telegant
Telegant
Telegant is an elegant modern bot framework for Python, designed to provide developers with simple and elegant access to the Telegram bot API. The project is currently at the alpha testing stage and provides only the required basic features to prove the concept of simplicity.
Installation
To install the project, simply run:
pip install telegant
Example
from telegant import Bot
import asyncio
bot = Bot("YOUR_BOT_TOKEN_HERE")
@bot.hears("hello")
async def say_hello(bot, update):
await bot.sendMessage(text="What's up?")
#Your code here (Recommended to write your functions in order)
asyncio.run(bot.start_polling())
Usage
On text
If you need your bot to respond to specified text just use @bot.hears()
@bot.hears("hello")
async def say_hello(bot, update):
await bot.sendMessage(text="What's up?")
Sending bot with buttons
Inline buttons example
@bot.hears("hello")
async def say_hello(bot, update):
buttons = [
{"text": "Option 1 (inline)", "data": "option1"},
]
await bot.sendMessage(text="What's up?", reply_markup=bot.create_reply_markup(buttons))
Reply buttons example
@bot.hears("hello")
async def say_hello(bot, update):
buttons = [
{"text": "Option 1 (reply)"},
]
await bot.sendMessage(text="What's up?", reply_markup=bot.create_reply_markup(buttons))
Bot always detects your buttons type automatically by data key. If you want to use inline buttons you have to write text and data values for each button. As it is detects your inline button when you have "data" key in your button. Otherwise, it will detect as reply keyboard.
Commands
You can assign to one function one command or many commands as needed. For single command use @bot.command() decorator.
@bot.command("start")
async def say_hello(bot, update):
await bot.sendMessage(text="Sup I'm start")
For several commands use @bot.commands() decorator.
@bot.commands(['help', 'ask'])
async def say_hello(bot, update):
await bot.sendMessage(text="You've reached for help")
Export data after command by your keys
@bot.commands(['usernameandage'])
@bot.with_args(['username', 'age'])
async def handler(bot, update, data):
await bot.sendMessage(text=f"Hello {data['username']}, you are {data['age']} years old.")
Callbacks
Telegant also offers to you simply detect your callbacks where you able to assign many or one callback to your function
Many callbacks example
@bot.callbacks(['option1', 'option2'])
async def say_hello(bot, update):
await bot.sendMessage(text="Callbacks are perfect!")
Single callback example
@bot.callback('option1')
async def say_hello(bot, update):
await bot.sendMessage(text="Callback is perfect")
Metadata
Release files for Telegant 0.1.7
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 |
|---|---|---|---|---|
| Telegant-0.1.7.tar.gz | 5.5 kB | Without provenance | Details for Telegant-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Telegant-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for Telegant-0.1.7-py3-none-any.whl |
Total release size: 11.3 kB
Release files / Telegant-0.1.7.tar.gz
| Download URL | Telegant-0.1.7.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a41ddb6400bd34cc2a3832832eea71586ffd36db3ed2f58d955a5ad3f7942e7
|
|
BLAKE2b-256 checksum How to use checksums |
7e3f9dcd632d97755bf0b74cd51119565d1b2eb2fd9e8aff50d16062040235a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / Telegant-0.1.7-py3-none-any.whl
| Download URL | Telegant-0.1.7-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
947f368c7ea1838076dc27586391e5f2226b8039f2fc272a483173ff10e8afcf
|
|
BLAKE2b-256 checksum How to use checksums |
76796713dc4efd7bd764bd8439c6d1a3c5ae61ed42b69a9641462f915394d8eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for Telegant 0.1.7
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.