wondergram-org / wonda

A light, blazing fast framework for developing capable bots.
https://pypi.org/project/wonda
MIT License
8 stars 0 forks source link

Shortcut methods for any compatible model type #5

Open ghost opened 10 months ago

ghost commented 10 months ago

Description

I propose giving users ability to use shortcut methods like .answer(), .reply() and .forward() on any compatible model, not just update models in particular.

At the moment I don't know how exactly it's going to work. I don't want to violate integrity of types generated from schema. One way to go about this is to implement some sort of mixin that would patch the model in question.

Pseudocode

@bot.on.callback_query()
async def handler(cq: CallbackQuery) -> None:
    # Before this feature, you'd have to write this much
    # verbose code
    await cq.ctx_api.delete_message(
        cq.message.message_id, cq.message.chat.id
    )

    # After this feature gets implemented, the amount of code
    # it takes to achieve the same result becomes much lower
    await cq.message.delete()