telegrinder

Modern visionary telegram bot framework — for effective and reliable bot building.

$pip install telegrinder
Version
1.1.3
Bot API
10.3
Python
3.14+
License
MIT

Demo

The example from the README. Below, the bot answers exactly what this code returns.

from telegrinder import API, Message, Telegrinder, Token
from telegrinder.modules import setup_logger
from telegrinder.rules import Text

setup_logger(level="INFO")
api = API(token=Token("123:token"))
bot = Telegrinder(api)


@bot.on.message(Text("/start"))
async def start(message: Message) -> None:
    me = (await api.get_me()).unwrap()
    await message.answer(f"Hello, {message.from_user.full_name}! I'm {me.full_name}.")


bot.run_forever()

/start

Hello, George! I'm Telegrinder Demo.

Tutorial

Read in order: every chapter builds on the previous one.

No. Chapter Starts with Min Code
01 Setting up Okay, so you decided to switch to telegrinder. Probably because you want something fresh and cool. Or probably its your first time with bots. This tutorial is ok for both occasions. Let's start with initializing the core instance of our bot. 3 4
02 Rules Wow so in this part now we will learn how to filter the incoming events. That's pretty easy! 2 8
03 Functional bits As you probably noticed earlier in telegrinder we use some freaky constructions like .unwrap(), .map() and others. If you previously have had experience with some functional languages this concepts might be easy to grasp for you, but even if not, this article will explain why it is so useful. 2 5
04 Telegram API The essential part to build something for telegram is of course running telegram API methods. 2 6
05 Nodes If you want the short version, nodes in telegrinder are a way to stop repeating the same preparation logic in every handler. 4 8
06 Dispatch If nodes help prepare data, Dispatch answers a different question: "where does this event go, and who gets to handle it?" 4 12
07 Keyboard, payload handling Keyboards are usually the first thing that makes a bot feel friendlier. 4 17
08 Working with text: formatting, localization Almost every bot eventually becomes text-heavy. 3 9
09 States: waiters, long states This is one of the most important sections for real bots. 6 11
10 Media Bots almost never work with text only. In telegrinder media work usually falls into three common scenarios: 1 4
11 Handling errors Errors are unavoidable in bots: network failures, user input, external services, databases, and your own business logic. Telegrinder has a built-in exception routing path through event_error. 1 2
12 Out-of-the-box scenarios Once the basic building blocks are clear, the next step is usually not “write more handlers”, but “assemble recurring bot flows from reusable parts”. Telegrinder already provides quite a few of those patterns. 2 0

Tools · Reference