AioTele is a new library written in pure python with asynchrony, this project was released quite recently but has basic functionality
An example of a bot on AioTele:
```python
from aiotele.bot import Bot
from aiotele.keyboards import Button, MarkupButton, MarkupButtonInline, InlineButton
from aiotele import html, LEAVE_TRANSITION, JOIN_TRANSITION, JOIN_TRANSITION
from aiotele.types import MessageObject, CommandObject, CallbackQuery, NewChatMember, LeaveChatMember
from aiotele.exceptions import ValidationError, TelegramBadRequest
import asyncio
TOKEN = "YOU_TOKEN"
bot = Bot(TOKEN)
@bot.chat_member(LEAVE_TRANSITION)
async def leave_chat_member(leave_member: LeaveChatMember):
await leave_member.reply(f"Bye {leave_member.leave_member.full_name}! was deleted by the administrator {leave_member.from_user.full_name}!")
@bot.chat_member(JOIN_TRANSITION)
async def new_chat_member(new_member: NewChatMember):
await new_member.answer(f"Hello {new_member.new_member.full_name}! Added you {new_member.old_member.full_name}!")
@bot.my_chat_member(JOIN_TRANSITION)
async def bot_join_chat_member(new_member: NewChatMember):
await new_member.answer(f"Thank you for adding me to the chat. {new_member.old_member.full_name}!")
@bot.message_handler("inline", prefix="!/.")
async def start(msg: MessageObject, command: CommandObject):
markup = MarkupButtonInline()
markup.add(InlineButton("Start", "start"))
markup.add(InlineButton("Start2", "start2"))
await msg.answer(f"Hello {html.link(value=msg.from_user.full_name, link=f'tg://user?id={msg.from_user.id}')}!", reply_markup=markup.keyboards)
@bot.message_handler("usual", prefix="!/.")
async def start(msg: MessageObject, command: CommandObject):
await bot.send_photo(chat_id=msg.chat.id, url_photo="https://i.ytimg.com/an_webp/gxnqVXilX0I/mqdefault_6s.webp?du=3000&sqp=CIq-wr0G&rs=AOn4CLBKglLYZ0fdfIScCNqeRFrmk47mpA")
markup = MarkupButton(one_time_keyboard=True)
markup.add(Button("Start"))
await msg.reply(f"Hello {html.link(value=msg.from_user.full_name, link=f'tg://user?id={msg.from_user.id}')}!", reply_markup=markup.keyboards)
@bot.message_handler("Start")
async def start(msg: MessageObject, command: CommandObject):
new_name: str = "Chat GPT-2"
try:
await bot.set_bot_name(new_name)
await msg.answer(f"The bot's name has been successfully changed to: {new_name}")
except (ValidationError, TelegramBadRequest) as e:
await msg.answer(f"An error has occurred: {e}")
@bot.message_handler()
async def start(msg: MessageObject, command: CommandObject):
"""
An example of processing messages that the bot does not know about:
```
await msg.reply(f"I don't know such a command!")
if msg.reply_to_message != None:
await msg.reply_to_message.reply(f"I don't know such a command!")
```
"""
await msg.reply(f"I don't know such a command!")
if msg.reply_to_message != None:
await msg.reply_to_message.reply(f"I don't know such a command!")
@bot.callback_handler()
async def start(callback: CallbackQuery):
if callback.data == "start":
"""
Example of using dice:
```
dice = await callback.message.answer_dice("🎲")
await callback.message.answer(f"The number dropped out: {dice.value}")
await callback.message.answer(f"Emotion: {dice.emoji}")
```
"""
await callback.message.answer(f"Details of the user who clicked the button:\nName: {callback.entities.from_user.full_name}\nID: {callback.entities.from_user.id}\nLanguage: {callback.entities.from_user.language_code}\nBot: {callback.entities.from_user.is_bot}")
await callback.answer(text="You clicked the button!", show_alert=True)
async def main():
await bot.delete_webhook(True)
await bot.run()
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Bogdan-godot/AioTele",
"name": "AioTele",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "telegram bot asyncio async telegram",
"author": "Bogdan Boris",
"author_email": "gdrghdhgddy@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/cd/84/1ecfc248f77a93e88da5aa94042ae2e26586075fae5e28630f7b06ce66e6/aiotele-0.1.6.tar.gz",
"platform": null,
"description": "AioTele is a new library written in pure python with asynchrony, this project was released quite recently but has basic functionality\r\n\r\nAn example of a bot on AioTele:\r\n```python\r\nfrom aiotele.bot import Bot\r\nfrom aiotele.keyboards import Button, MarkupButton, MarkupButtonInline, InlineButton\r\nfrom aiotele import html, LEAVE_TRANSITION, JOIN_TRANSITION, JOIN_TRANSITION\r\nfrom aiotele.types import MessageObject, CommandObject, CallbackQuery, NewChatMember, LeaveChatMember\r\nfrom aiotele.exceptions import ValidationError, TelegramBadRequest\r\nimport asyncio\r\n\r\nTOKEN = \"YOU_TOKEN\"\r\nbot = Bot(TOKEN)\r\n\r\n@bot.chat_member(LEAVE_TRANSITION)\r\nasync def leave_chat_member(leave_member: LeaveChatMember):\r\n await leave_member.reply(f\"Bye {leave_member.leave_member.full_name}! was deleted by the administrator {leave_member.from_user.full_name}!\")\r\n\r\n@bot.chat_member(JOIN_TRANSITION)\r\nasync def new_chat_member(new_member: NewChatMember):\r\n await new_member.answer(f\"Hello {new_member.new_member.full_name}! Added you {new_member.old_member.full_name}!\")\r\n\r\n@bot.my_chat_member(JOIN_TRANSITION)\r\nasync def bot_join_chat_member(new_member: NewChatMember):\r\n await new_member.answer(f\"Thank you for adding me to the chat. {new_member.old_member.full_name}!\")\r\n\r\n@bot.message_handler(\"inline\", prefix=\"!/.\")\r\nasync def start(msg: MessageObject, command: CommandObject):\r\n markup = MarkupButtonInline()\r\n markup.add(InlineButton(\"Start\", \"start\"))\r\n markup.add(InlineButton(\"Start2\", \"start2\"))\r\n await msg.answer(f\"Hello {html.link(value=msg.from_user.full_name, link=f'tg://user?id={msg.from_user.id}')}!\", reply_markup=markup.keyboards)\r\n\r\n@bot.message_handler(\"usual\", prefix=\"!/.\")\r\nasync def start(msg: MessageObject, command: CommandObject):\r\n await bot.send_photo(chat_id=msg.chat.id, url_photo=\"https://i.ytimg.com/an_webp/gxnqVXilX0I/mqdefault_6s.webp?du=3000&sqp=CIq-wr0G&rs=AOn4CLBKglLYZ0fdfIScCNqeRFrmk47mpA\")\r\n markup = MarkupButton(one_time_keyboard=True)\r\n markup.add(Button(\"Start\"))\r\n await msg.reply(f\"Hello {html.link(value=msg.from_user.full_name, link=f'tg://user?id={msg.from_user.id}')}!\", reply_markup=markup.keyboards)\r\n\r\n@bot.message_handler(\"Start\")\r\nasync def start(msg: MessageObject, command: CommandObject):\r\n new_name: str = \"Chat GPT-2\"\r\n try:\r\n await bot.set_bot_name(new_name)\r\n await msg.answer(f\"The bot's name has been successfully changed to: {new_name}\")\r\n except (ValidationError, TelegramBadRequest) as e:\r\n await msg.answer(f\"An error has occurred: {e}\")\r\n\r\n@bot.message_handler()\r\nasync def start(msg: MessageObject, command: CommandObject):\r\n \"\"\"\r\n An example of processing messages that the bot does not know about:\r\n ```\r\n await msg.reply(f\"I don't know such a command!\")\r\n if msg.reply_to_message != None:\r\n await msg.reply_to_message.reply(f\"I don't know such a command!\")\r\n ```\r\n \"\"\"\r\n await msg.reply(f\"I don't know such a command!\")\r\n if msg.reply_to_message != None:\r\n await msg.reply_to_message.reply(f\"I don't know such a command!\")\r\n\r\n@bot.callback_handler()\r\nasync def start(callback: CallbackQuery):\r\n if callback.data == \"start\":\r\n \"\"\"\r\n Example of using dice:\r\n ```\r\n dice = await callback.message.answer_dice(\"\ud83c\udfb2\")\r\n await callback.message.answer(f\"The number dropped out: {dice.value}\")\r\n await callback.message.answer(f\"Emotion: {dice.emoji}\")\r\n ```\r\n \"\"\"\r\n await callback.message.answer(f\"Details of the user who clicked the button:\\nName: {callback.entities.from_user.full_name}\\nID: {callback.entities.from_user.id}\\nLanguage: {callback.entities.from_user.language_code}\\nBot: {callback.entities.from_user.is_bot}\")\r\n await callback.answer(text=\"You clicked the button!\", show_alert=True)\r\n\r\nasync def main():\r\n await bot.delete_webhook(True)\r\n await bot.run()\r\n\r\nasyncio.run(main())\r\n```\r\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0, see LICENSE file",
"summary": "AioTele is a Python module for building Telegram bots using asyncio. It offers an intuitive API for handling updates, commands, and messaging, supporting both long polling and webhooks for scalable, high-performance bots.",
"version": "0.1.6",
"project_urls": {
"Download": "https://github.com/Bogdan-godot/AioTele/archive/v0.1.6.zip",
"Homepage": "https://github.com/Bogdan-godot/AioTele"
},
"split_keywords": [
"telegram",
"bot",
"asyncio",
"async",
"telegram"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cd841ecfc248f77a93e88da5aa94042ae2e26586075fae5e28630f7b06ce66e6",
"md5": "baff564468fdc775ac3bae98fce70567",
"sha256": "8980c7eb4d232a6bd3f39f8235785e98caaa4d6e75f1f015df717ff52cce9cb4"
},
"downloads": -1,
"filename": "aiotele-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "baff564468fdc775ac3bae98fce70567",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11705,
"upload_time": "2025-02-18T12:03:47",
"upload_time_iso_8601": "2025-02-18T12:03:47.523933Z",
"url": "https://files.pythonhosted.org/packages/cd/84/1ecfc248f77a93e88da5aa94042ae2e26586075fae5e28630f7b06ce66e6/aiotele-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-18 12:03:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Bogdan-godot",
"github_project": "AioTele",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aiotele"
}