Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running commands from drafts #32

Open
evgfilim1 opened this issue Nov 4, 2022 · 0 comments
Open

Allow running commands from drafts #32

evgfilim1 opened this issue Nov 4, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@evgfilim1
Copy link
Owner

evgfilim1 commented Nov 4, 2022

This will require wrapping the original message class from Pyrogram into something that will behave almost the same but will support drafts.

Handling requires registering RawUpdateHandler like this:

client.add_handler(
RawUpdateHandler(partial(react2ban_raw_reaction_handler, storage=storage)),
group=1,
)

Usage:
async def react2ban_raw_reaction_handler(
client: Client,
update: base.Update,
users: dict[int, types.User],
_: dict[int, types.Chat | types.Channel],
*,
storage: Storage,
) -> None:
if not isinstance(update, types.UpdateMessageReactions):
raise ContinuePropagation() # don't consume an update here, it's not for this handler

UpdateDraftMessage will be received when something is saved as a draft:
https://docs.pyrogram.org/telegram/types/update-draft-message#pyrogram.raw.types.UpdateDraftMessage

Implementing this may open new abilities like silent execution without having to edit sources, looped execution, etc.

@evgfilim1 evgfilim1 added the enhancement New feature or request label Nov 4, 2022
@evgfilim1 evgfilim1 moved this from 🆕 New to 📋 Backlog in evgfilim1/userbot project Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant