All Projects → szastupov → Aiotg

szastupov / Aiotg

Licence: mit
Asynchronous Python library for building Telegram bots

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Aiotg

Rocketgram
Modern and powerful asynchronous telegram bot framework.
Stars: ✭ 37 (-90.11%)
Mutual labels:  bot, asyncio, telegram
AmimeWatch
Telegram bot made in Python 3 using the @pyrogram framework.
Stars: ✭ 19 (-94.92%)
Mutual labels:  telegram, asyncio
Swiftybot
How to create a Telegram, Facebook Messenger, and Google Assistant bot with Swift using Vapor on Ubuntu / macOS.
Stars: ✭ 247 (-33.96%)
Mutual labels:  bot, telegram
Pokemongo Bot
The Pokemon Go Bot, baking with community.
Stars: ✭ 3,730 (+897.33%)
Mutual labels:  bot, telegram
Bottender
⚡️ A framework for building conversational user interfaces.
Stars: ✭ 3,803 (+916.84%)
Mutual labels:  bot, telegram
Publicleech
can be found on Telegram as https://telegram.dog/PublicLeechGroup
Stars: ✭ 236 (-36.9%)
Mutual labels:  bot, telegram
Telegram List
List of telegram groups, channels & bots // Список интересных групп, каналов и ботов телеграма // Список чатов для программистов
Stars: ✭ 3,362 (+798.93%)
Mutual labels:  bot, telegram
Anydlbot
An Open Source GPLv3 All-In-One Telegram Bot
Stars: ✭ 236 (-36.9%)
Mutual labels:  bot, telegram
Tg Keyword Reply Bot
[DEPRECATED] Telegram关键词自动回复机器人: 根据群组管理员设定的关键词或者正则规则,自动回复文字、图片、文件或者进行永久禁言、临时禁言、踢出等群管操作
Stars: ✭ 299 (-20.05%)
Mutual labels:  bot, telegram
Pytg
Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
Stars: ✭ 365 (-2.41%)
Mutual labels:  bot, telegram
The Guard Bot
The Guard, a Telegram bot to moderate groups.
Stars: ✭ 299 (-20.05%)
Mutual labels:  bot, telegram
Unifiedmessagerelay
Group Message Forward Framework (supports QQ Telegram Line Discord)
Stars: ✭ 363 (-2.94%)
Mutual labels:  asyncio, telegram
Userge
Userge, Durable as a Serge
Stars: ✭ 363 (-2.94%)
Mutual labels:  asyncio, telegram
Telegram channel downloader
一个电报群组、频道下载脚本,支持上传到GD、OD等rclone可以挂载的网盘。
Stars: ✭ 216 (-42.25%)
Mutual labels:  bot, telegram
Profiles
👍 Make JavaScript Great Again
Stars: ✭ 238 (-36.36%)
Mutual labels:  bot, telegram
Telegram Bot Swift
Telegram Bot SDK for Swift (unofficial)
Stars: ✭ 275 (-26.47%)
Mutual labels:  bot, telegram
Tgbot
Modular telegram group management bot
Stars: ✭ 334 (-10.7%)
Mutual labels:  bot, telegram
Tlg joincaptchabot
Telegram Bot to verify if users that join a group, are humans. The Bot send an image captcha for each new user, and kick any of them that can't solve the captcha in a specified time.
Stars: ✭ 226 (-39.57%)
Mutual labels:  bot, telegram
Python Telegram Bot
We have made you a wrapper you can't refuse
Stars: ✭ 17,209 (+4501.34%)
Mutual labels:  bot, telegram
Telegram.bot.examples
Examples for the Telegram.Bot C# Library
Stars: ✭ 290 (-22.46%)
Mutual labels:  bot, telegram

aiotg

.. image:: https://travis-ci.org/szastupov/aiotg.svg?branch=master :target: https://travis-ci.org/szastupov/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 <https://github.com/szastupov/aiotg/blob/master/examples/async.py>__
  • Send image <https://github.com/szastupov/aiotg/blob/master/examples/getimage.py>__
  • Post to channel <https://github.com/szastupov/aiotg/blob/master/examples/post_to_channel.py>__
  • Webhooks mode <https://github.com/szastupov/aiotg/blob/master/examples/webhook.py>__
  • Sender id <https://github.com/szastupov/aiotg/blob/master/examples/whoami.py>__

For a real world example, take a look at WhatisBot <https://github.com/szastupov/whatisbot/blob/master/main.py>__ or Music Catalog Bot <https://github.com/szastupov/musicbot>__.

For more information on how to use the project, see the project's documentation <http://szastupov.github.io/aiotg/index.html>__.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].