aiotg

Asynchronous Python library for building Telegram bots

https://github.com/szastupov/aiotg

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary

Keywords

asyncio bot python telegram
Last synced: 6 months ago · JSON representation

Repository

Asynchronous Python library for building Telegram bots

Basic Info
  • Host: GitHub
  • Owner: szastupov
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 508 KB
Statistics
  • Stars: 382
  • Watchers: 23
  • Forks: 42
  • Open Issues: 3
  • Releases: 31
Topics
asyncio bot python telegram
Created over 10 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.rst

aiotg
=====

Asynchronous Python API for building Telegram bots, featuring:

- Easy and declarative API
- Hassle-free setup - no need for SSL certificates or static IP
- Built-in support for analytics via chatbase.com
- Automatic handling of Telegram API throttling or timeouts

Install it with pip:

.. code:: sh

    pip install aiotg

Then you can create a new bot in few lines:

.. code:: python

    from aiotg import Bot, Chat

    bot = Bot(api_token="...")

    @bot.command(r"/echo (.+)")
    def echo(chat: Chat, match):
        return chat.reply(match.group(1))

    bot.run()

Now run it with a proper API\_TOKEN and it should reply to /echo commands.

.. note:: Type annotations are not required but will help your editor/IDE to provide code completion.

The example above looks like a normal synchronous code but it actually returns a coroutine.
If you want to make an external request (and that's what bots usually do) just use aiohttp and async/await syntax:

.. code:: python

    import aiohttp
    from aiotg import Bot, Chat

    bot = Bot(api_token="...")

    @bot.command("bitcoin")
    async def bitcoin(chat: Chat, match):
        url = "https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD"
        async with aiohttp.ClientSession() as session:
            response = await session.get(url)
            info = await response.json()
            await chat.send_text(str(info["averages"]["day"]))

    bot.run()


But what if you just want to write a quick integration and don't need to provide a conversational interface? We've got you covered!
You 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:

.. code:: python

    ...
    channel = bot.channel("@yourchannel")
    private = bot.private("1111111")

    async def greeter():
        await channel.send_text("Hello from channel!")
        await private.send_text("Why not greet personally?")
    ...


Examples
---------------

- `Async IO `__
- `Send image `__
- `Post to channel `__
- `Webhooks mode `__
- `Sender id `__

For a real world example, take a look at
`WhatisBot `__ or `Music Catalog Bot `__.

For more information on how to use the project, see the project's `documentation `__.

Owner

  • Name: Stepan Zastupov
  • Login: szastupov
  • Kind: user
  • Location: London

GitHub Events

Total
  • Watch event: 5
  • Pull request event: 1
Last Year
  • Watch event: 5
  • Pull request event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 251
  • Total Committers: 33
  • Avg Commits per committer: 7.606
  • Development Distribution Score (DDS): 0.291
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Stepan Zastupov s****v@g****m 178
Sijmen Schoon s****n@g****m 19
Yury Krylov s****s@g****m 9
M.Furkan b****e@y****m 5
4yBa4oK o****o@u****t 3
Krylov.YS K****S@d****u 3
Leonid Kozarin k****o@s****u 3
Anton Anisimov r****1@g****m 2
Ilya Pavlov s****a@g****m 2
Oleg Gromyak o****k@g****m 2
JustDolanIt 4****b@g****m 2
Dmitry Galkin m****r@g****m 2
Grigory Bakunov b****k@j****g 1
Sardor Muminov s****r@i****m 1
Alexander Romanov a****o@l****u 1
Andrew Dunai a****i@g****m 1
Marsel v****n@g****m 1
mfoxru m****u@g****m 1
Diwank Singh Tomer s****h@d****e 1
Ilya Shalyapin i****n@g****m 1
Leontiev Aleksey a****l@l****u 1
Luis López l****z@g****m 1
Marco Ceppi m****o@c****t 1
Pouya Mobasher Behrouz p****b@g****m 1
Rahiel Kasim r****m@g****m 1
Ross Nomann r****n@p****m 1
Sardor Muminov m****f 1
Sergey Kostyuchenko d****x@g****m 1
Sijmen Schoon me@s****l 1
Vyacheslav Shevchenko b****7@g****m 1
and 3 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 23
  • Total pull requests: 67
  • Average time to close issues: 3 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 17
  • Total pull request authors: 36
  • Average comments per issue: 2.04
  • Average comments per pull request: 1.66
  • Merged pull requests: 56
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • szastupov (3)
  • raprek (3)
  • shadrus (3)
  • muminoff (2)
  • Podidiving (1)
  • HerrMuellerluedenscheid (1)
  • un1t (1)
  • FedorArbuzov (1)
  • mdbetancourt (1)
  • JustDolanIt (1)
  • Kyle2142 (1)
  • MechanisM (1)
  • martroi (1)
  • kozalosev (1)
  • 1755 (1)
Pull Request Authors
  • shadrus (12)
  • vijfhoek (6)
  • muhammedfurkan (5)
  • raprek (3)
  • szastupov (3)
  • muminoff (2)
  • olehbozhok (2)
  • kozalosev (2)
  • ogroleg (2)
  • bliz937 (2)
  • JustDolanIt (2)
  • mon4ter (2)
  • mdbetancourt (2)
  • and3rson (1)
  • pooyamb (1)
Top Labels
Issue Labels
enhancement (3) bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 2,090 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 39
  • Total versions: 46
  • Total maintainers: 1
pypi.org: aiotg

Asynchronous Python API for building Telegram bots

  • Versions: 46
  • Dependent Packages: 0
  • Dependent Repositories: 39
  • Downloads: 2,090 Last month
Rankings
Dependent repos count: 2.3%
Stargazers count: 3.3%
Forks count: 6.2%
Average: 6.3%
Downloads: 9.6%
Dependent packages count: 10.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • aiohttp >=3.0.0
  • aiosocksy >=0.1.1
  • watchdog >=0.9.0