
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
.. image:: https://badge.fury.io/py/aiotgbot.svg :target: https://pypi.org/project/aiotgbot :alt: Latest PyPI package version
.. image:: https://img.shields.io/badge/license-MIT-blue.svg :target: https://github.com/gleb-chipiga/aiotgbot/blob/master/LICENSE :alt: License
.. image:: https://img.shields.io/pypi/dm/aiotgbot :target: https://pypistats.org/packages/aiotgbot :alt: Downloads count
aiohttp <https://github.com/aio-libs/aiohttp>
_ basedTelegram Bot API <https://core.telegram.org/bots/api>
_ types and methods supportedPEP 484 <https://www.python.org/dev/peps/pep-0484/>
_)aiotgbot is available on PyPI. Use pip to install it:
.. code-block:: bash
pip install aiotgbot
aiohttp <https://github.com/aio-libs/aiohttp>
_aiojobs <https://github.com/aio-libs/aiojobs>
_msgspec <https://github.com/jcrist/msgspec>
_backoff <https://github.com/litl/backoff>
_frozenlist <https://github.com/aio-libs/frozenlist>
_aiofreqlimit <https://github.com/gleb-chipiga/aiofreqlimit>
_yarl <https://github.com/aio-libs/yarl>
_.. code-block:: python
from typing import AsyncIterator
from aiotgbot import (Bot, BotUpdate, HandlerTable, PollBot,
PrivateChatFilter, Runner)
from aiotgbot.storage_memory import MemoryStorage
handlers = HandlerTable()
@handlers.message(filters=[PrivateChatFilter()])
async def reply_private_message(bot: Bot, update: BotUpdate) -> None:
assert update.message is not None
name = (f'{update.message.chat.first_name} '
f'{update.message.chat.last_name}')
await bot.send_message(update.message.chat.id, f'Hello, {name}!')
async def run_context(runner: Runner) -> AsyncIterator[None]:
storage = MemoryStorage()
await storage.connect()
handlers.freeze()
bot = PollBot(runner['token'], handlers, storage)
await bot.start()
yield
await bot.stop()
await storage.close()
def main() -> None:
runner = Runner(run_context)
runner['token'] = 'some:token'
runner.run()
if __name__ == '__main__':
main()
FAQs
Asynchronous library for Telegram bot API
We found that aiotgbot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.