{"id":13937009,"url":"https://github.com/szastupov/aiotg","last_synced_at":"2025-05-16T11:07:04.166Z","repository":{"id":34394466,"uuid":"38321888","full_name":"szastupov/aiotg","owner":"szastupov","description":"Asynchronous Python library for building Telegram bots","archived":false,"fork":false,"pushed_at":"2024-04-18T09:45:22.000Z","size":520,"stargazers_count":381,"open_issues_count":3,"forks_count":42,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-05-10T13:55:36.554Z","etag":null,"topics":["asyncio","bot","python","telegram"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szastupov.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-30T17:01:15.000Z","updated_at":"2025-04-15T17:00:25.000Z","dependencies_parsed_at":"2022-09-14T06:00:22.129Z","dependency_job_id":"a3637cb0-2007-46df-9cc3-903cfef1ed8d","html_url":"https://github.com/szastupov/aiotg","commit_stats":{"total_commits":251,"total_committers":33,"mean_commits":7.606060606060606,"dds":"0.29083665338645415","last_synced_commit":"4e79e5af60283c89e96a6cbe29665a4f3bacb3bd"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szastupov%2Faiotg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szastupov%2Faiotg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szastupov%2Faiotg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szastupov%2Faiotg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szastupov","download_url":"https://codeload.github.com/szastupov/aiotg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518381,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","bot","python","telegram"],"created_at":"2024-08-07T23:03:12.239Z","updated_at":"2025-05-16T11:06:59.156Z","avatar_url":"https://github.com/szastupov.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"aiotg\n=====\n\nAsynchronous Python API for building Telegram bots, featuring:\n\n- Easy and declarative API\n- Hassle-free setup - no need for SSL certificates or static IP\n- Built-in support for analytics via chatbase.com\n- Automatic handling of Telegram API throttling or timeouts\n\nInstall it with pip:\n\n.. code:: sh\n\n    pip install aiotg\n\nThen you can create a new bot in few lines:\n\n.. code:: python\n\n    from aiotg import Bot, Chat\n\n    bot = Bot(api_token=\"...\")\n\n    @bot.command(r\"/echo (.+)\")\n    def echo(chat: Chat, match):\n        return chat.reply(match.group(1))\n\n    bot.run()\n\nNow run it with a proper API\\_TOKEN and it should reply to /echo commands.\n\n.. note:: Type annotations are not required but will help your editor/IDE to provide code completion.\n\nThe example above looks like a normal synchronous code but it actually returns a coroutine.\nIf you want to make an external request (and that's what bots usually do) just use aiohttp and async/await syntax:\n\n.. code:: python\n\n    import aiohttp\n    from aiotg import Bot, Chat\n\n    bot = Bot(api_token=\"...\")\n\n    @bot.command(\"bitcoin\")\n    async def bitcoin(chat: Chat, match):\n        url = \"https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD\"\n        async with aiohttp.ClientSession() as session:\n            response = await session.get(url)\n            info = await response.json()\n            await chat.send_text(str(info[\"averages\"][\"day\"]))\n\n    bot.run()\n\n\nBut what if you just want to write a quick integration and don't need to provide a conversational interface? We've got you covered!\nYou can send messages (or any other media) by constructing a Chat object with user_id or channel name. We even saved you some extra keystrokes by providing handy Channel constructors:\n\n.. code:: python\n\n    ...\n    channel = bot.channel(\"@yourchannel\")\n    private = bot.private(\"1111111\")\n\n    async def greeter():\n        await channel.send_text(\"Hello from channel!\")\n        await private.send_text(\"Why not greet personally?\")\n    ...\n\n\nExamples\n---------------\n\n- `Async IO \u003chttps://github.com/szastupov/aiotg/blob/master/examples/async.py\u003e`__\n- `Send image \u003chttps://github.com/szastupov/aiotg/blob/master/examples/getimage.py\u003e`__\n- `Post to channel \u003chttps://github.com/szastupov/aiotg/blob/master/examples/post_to_channel.py\u003e`__\n- `Webhooks mode \u003chttps://github.com/szastupov/aiotg/blob/master/examples/webhook.py\u003e`__\n- `Sender id \u003chttps://github.com/szastupov/aiotg/blob/master/examples/whoami.py\u003e`__\n\nFor a real world example, take a look at\n`WhatisBot \u003chttps://github.com/szastupov/whatisbot/blob/master/main.py\u003e`__ or `Music Catalog Bot \u003chttps://github.com/szastupov/musicbot\u003e`__.\n\nFor more information on how to use the project, see the project's `documentation \u003chttp://szastupov.github.io/aiotg/index.html\u003e`__.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszastupov%2Faiotg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszastupov%2Faiotg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszastupov%2Faiotg/lists"}