Skip to main content

Async Telegram framework for bot building

Project description

Mubble 1.3.0 (stable)

Downloads Downloads

Github Examples

Mubble is a next-generation framework known for its great speed and simplicity. It is written using aiohttp, asyncio, and msgspec.
(Author's words) Make the fastest bot ever!


Speed measurement

Each test contains 100 different API calls

Test Mubble (sec/avg) Aiogram (sec/avg) Telebot (sec/avg) Winner
1 0.12896 0.30656 0.24000 Mubble
2 0.12620 0.14554 0.17649 Mubble
3 0.13366 0.14902 0.13141 Mubble
4 0.12437 0.14864 0.13717 Mubble
5 0.12754 0.15863 0.18894 Mubble
6 0.12261 0.15175 0.17157 Mubble
7 0.14395 0.16154 0.19383 Mubble
8 0.12508 0.15084 0.24207 Mubble
9 0.12239 0.14838 0.14282 Mubble
10 0.12610 0.14478 0.13068 Mubble
AVG 0.12869 0.16687 0.17550 Mubble

Getting started

Installing:

pip install mubble
poetry add mubble
poetry add git+https://github.com/vladislavkovalskyi/mubble.git#master

Simple bot example:

import random

from mubble import Token, API, Mubble, Message, CallbackQuery
from mubble.rules import StartCommand, Text, Markup, CallbackData
from mubble.tools.keyboard import InlineKeyboard, InlineButton

api = API(Token("Your token"))
bot = Mubble(api)


class Keyboard:
    menu = (
        InlineKeyboard()
        .add(InlineButton("✍️ Write hello", callback_data="hello"))
        .row()
        .add(InlineButton("🍌 Choice banana", callback_data="banana"))
    ).get_markup()

    back = (
        InlineKeyboard().add(InlineButton("⬅️ Back", callback_data="menu"))
    ).get_markup()


@bot.on.message(StartCommand())
async def start_handler(message: Message):
    await message.answer(
        "👋 Hello, I'm Mubble! How can I help you?\n\n"
        "My available commands:\n"
        "- /start\n"
        "- /menu\n"
        "- /random [from number] [to number]"
    )


@bot.on.message(Text("/menu"))
async def menu_handler(message: Message):
    await message.answer(
        "📃 Here's your menu! Use the keyboard.", reply_markup=Keyboard.menu
    )


@bot.on.message(Markup(["/random", "/random <a:int> <b:int>"]))
async def random_handler(message: Message, a: int = None, b: int = None):
    if None in (a, b):
        await message.answer(
            "🤓 Wrong syntax. You also need to write the first number and the second number."
        )
        return

    await message.answer(f"🎲 Your random number is {random.randint(a, b)}")


@bot.on.callback_query(CallbackData("menu"))
async def menu_handler(cq: CallbackQuery):
    await cq.edit_text(
        "📃 Here's your menu! Use the keyboard.", reply_markup=Keyboard.menu
    )


@bot.on.callback_query(CallbackData("hello"))
async def hello_handler(cq: CallbackQuery):
    await cq.edit_text("👋 Hello, I'm Mubble!", reply_markup=Keyboard.back)


@bot.on.callback_query(CallbackData("banana"))
async def fruits_handler(cq: CallbackQuery):
    await cq.answer("You clicked on the 🍌!")


bot.run_forever()

Слава Україні! 🇺🇦

by Vladyslav Kovalskyi

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

mubble-1.4.0.tar.gz (174.1 kB view details)

Uploaded Source

Built Distribution

mubble-1.4.0-py3-none-any.whl (234.3 kB view details)

Uploaded Python 3

File details

Details for the file mubble-1.4.0.tar.gz.

File metadata

  • Download URL: mubble-1.4.0.tar.gz
  • Upload date:
  • Size: 174.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/24.1.0

File hashes

Hashes for mubble-1.4.0.tar.gz
Algorithm Hash digest
SHA256 4eb5296567b6be7d74dc5c073abba29a951a2e02c7c5fc05f2ad3aa5f2e7022f
MD5 ae33ae479bd76e5c225e1ba84417d771
BLAKE2b-256 11747d3d60a276549c1c22c33292c4a2ef8ebe62434dd7e3ba5884aa6dda97f9

See more details on using hashes here.

File details

Details for the file mubble-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: mubble-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 234.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/24.1.0

File hashes

Hashes for mubble-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00dcb196f7d64713969df7da4f467a91fcead981417ea0515e7d6f49127c8514
MD5 0639961807c7e54e5f54eb7794364cde
BLAKE2b-256 5eca677680207a9003f091fca545dd1d3bb57ef840c3546fba66adfb581e6809

See more details on using hashes here.

Supported by

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