TeleNet: Async Telegram Bot API framework
Project description
TeleNet
TeleNet یک کتابخانه مدرن و قدرتمند Python برای ساخت رباتهای چت و مدیریت دستورهاست، با قابلیت Long Polling و طراحی ساده اما منعطف. با TeleNet میتوانی رباتهای پیچیده با پیام فارسی، دکمه کیبرد، هندلینگ پیشرفته و مدیریت کامل کامندها بسازی، بدون دردسر و با کمترین کدنویسی.
🔹 ویژگیها
-
طراحی مدرن و سبک با asyncio
-
پشتیبانی کامل از پیامهای فارسی و Unicode
-
سیستم Router & Command برای مدیریت کامندها
-
امکان ساخت هندلرهای چندگانه برای دستورهای مختلف
-
Long Polling ساده برای دریافت آپدیتها
-
کاملاً آماده برای گسترش و ماژولار شدن
-
مناسب برای رباتهای شخصی و عمومی
🔹 نصب
pip install telenet```
- > TeleNet نیاز به Python 3.10+ دارد.
---
🔹 شروع سریع
```python
import asyncio
from telenet import TeleNetClient, Router, Command
TOKEN = "<YOUR_BOT_TOKEN>"
bot = TeleNetClient(TOKEN)
router = Router()
@router.on(Command("start"))
async def start(ctx):
await bot.send_message(ctx.chat.id, "سلام! خوش اومدی 😎")
async def main():
await bot.start()
await bot.poll_updates(router=router)
if __name__ == "__main__":
asyncio.run(main())
🔹 هندلرهای پیشرفته
import asyncio
from telenet import TeleNetClient, Router, Command, InlineButton
TOKEN = "<YOUR_BOT_TOKEN>"
bot = TeleNetClient(TOKEN)
router = Router()
@router.on(Command("start"))
async def start(ctx):
buttons = [
[InlineButton("رفتن به گوگل", url="https://google.com"),
InlineButton("رفتن به تلگرام", url="https://t.me")],
]
await bot.send_message(
ctx.chat.id,
"یکی از گزینهها را انتخاب کنید:",
buttons=buttons
)
async def main():
await bot.start()
await bot.poll_updates(router=router)
if __name__ == "__main__":
asyncio.run(main())
🔹 ویژگیهای پیشرفته
-
کامند داینامیک: میتوانی دستورها را در زمان اجرا اضافه یا حذف کنی.
-
پشتیبانی از چندین Router: مدیریت پیچیده مسیرها و گروههای کامندها.
-
سازگار با انواع آپدیتها: پیام، عکس، فایل، استیکر و دکمهها.
-
ماژولار و قابل گسترش: افزودن Middleware و Hookهای اختصاصی آسان است.
🔹 نکات مهم
-
ذخیره فایلها با UTF-8 برای پیامهای فارسی
-
اجرای asyncio.run(main()) تنها یکبار در برنامه
-
هندلرها باید async باشند
-
برای پاسخ سریعتر، میتوان از taskهای جداگانه استفاده کرد
🔹 مثال کامل ربات
i```python import asyncio from telenet import TeleNetClient, Router, Command, InlineButton
TOKEN = "<YOUR_BOT_TOKEN>" bot = TeleNetClient(TOKEN) router = Router()
@router.on(Command("start")) async def start(ctx): # پیام خوش آمد await bot.send_message(ctx.chat.id, "سلام! خوش اومدی 😎")
# پیام با دکمههای inline
buttons = [
[InlineButton("رفتن به گوگل", url="https://google.com"),
InlineButton("رفتن به تلگرام", url="https://t.me")],
]
await bot.send_message(
ctx.chat.id,
"یکی از گزینهها را انتخاب کنید:",
buttons=buttons
)
async def main(): await bot.start() await bot.poll_updates(router=router)
if name == "main": asyncio.run(main())
---
🔹 چرا TeleNet؟
- ساده و سریع
- قابل گسترش و ماژولار
- مناسب برای رباتهای حرفهای و پروژههای بزرگ
- ساختار مدرن asyncio و مدیریت آسان کامندها
> Designed by Ali-Jafari & GPT | With ❤.
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
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 telenet-2.7.0.tar.gz.
File metadata
- Download URL: telenet-2.7.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bf417107c60eb346a86ecfb2c544c79ee96137212fe619f123d4d4e46df962d
|
|
| MD5 |
5e1fb1446365ac146681079de26f79ea
|
|
| BLAKE2b-256 |
cf21673f83b4827d9358dc996b141b53bccc94bc5f8a6e1acaf2c4b3e17591d9
|
File details
Details for the file telenet-2.7.0-py3-none-any.whl.
File metadata
- Download URL: telenet-2.7.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a382b07c2d8bb185a8b0d17df3a5ca569d3d343d9b713ab98cdc4f0549070463
|
|
| MD5 |
8fbf887b0ed86c2b04724e6f61c22f40
|
|
| BLAKE2b-256 |
d56ff4679a4972dbcc10d16351fe2f1abe3dac2e514557ba398abd77a01e5fe5
|