Skip to main content

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.

Project description

A simple example of a bot that will repeat after the user

from aiotele import Bot
from aiotele.types import MessageObject, CommandObject
import asyncio

TOKEN = "YOU_TOKEN"
bot = Bot(TOKEN)

@bot.message_handler()
async def repeat(msg: MessageObject, command: CommandObject):
    await msg.reply(f"I don't know such a command!")


async def main():
    await bot.run()

asyncio.run(main())

deleting webhook

async def main():
    await bot.delete_webhook(True)
    await bot.run()

To check whether a new user has joined or not

from aiotele import JOIN_TRANSITION
from aiotele.types import NewChatMember

@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}!")

To check whether a user has logged out or not

from aiotele import LEAVE_TRANSITION
from aiotele.types import LeaveChatMember

@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}!")

Check whether the bot has been added to the group or not

from aiotele import JOIN_TRANSITION
from aiotele.types import NewChatMember

@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}!")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotele-0.1.8.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file aiotele-0.1.8.tar.gz.

File metadata

  • Download URL: aiotele-0.1.8.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for aiotele-0.1.8.tar.gz
Algorithm Hash digest
SHA256 e137cbc17ae13fc180f62b0f80fd9b3a85a3f1609e7d90d791feac3420b5eb3a
MD5 9c546191209c6ae8febdda46b6a204d2
BLAKE2b-256 566ca39ecfe5e7d893b68d8917ff747046e32baf5f01778a7bca97de5a55aae6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page