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

Make send_* functions return an instance of the message sent #68

Open
Nubuki-all opened this issue Jan 28, 2025 · 2 comments
Open

Make send_* functions return an instance of the message sent #68

Nubuki-all opened this issue Jan 28, 2025 · 2 comments

Comments

@Nubuki-all
Copy link
Contributor

Or is there already a way to do this?
For clarification I need send methods like send_video to return an instance of the message it sent with Message.ID already set could be added to response.Message ?

@Nubuki-all
Copy link
Contributor Author

Nubuki-all commented Jan 31, 2025

return await self.send_message(
to,
await self.build_video_message(file, caption, quoted, viewonce, gifplayback, is_gif),
)

The message gotten from the message builder should be referenced (to be reused) then after the message is successfully sent, the MessageWithContextInfo is extracted from the message and then patched into a new message class with Info and Info.MessageSource set from response.ID and (Chat & Sender) JID respectively
the message should then be patched into the response;

class SendResponse(google.protobuf.message.Message):
with the attribute response.Message

This would have been easier if we can extract any MessageWithContextInfo without knowing what message type it is specifically (I guess it's possible)
It seems there's already a function in

def get_message_type(message: Message) -> MediaMessageType | TextMessageType:
that does that
So we can do the the patching in client.send_message

@krypton-byte your thoughts?

@Nubuki-all
Copy link
Contributor Author

@krypton-byte I can't modify SendResponse since it's connected with the go code and I honestly have no idea how that works :neckbeard:

Returning a new object instead of SendResponse since protobuf doesn't support inheritance, would break other users code. (especially if they have strict type checking enabled)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant