neonize icon indicating copy to clipboard operation
neonize copied to clipboard

Make send_* functions return an instance of the message sent

Open Nubuki-all opened this issue 1 year ago • 2 comments

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 avatar Jan 28 '25 17:01 Nubuki-all

https://github.com/krypton-byte/neonize/blob/863306cadfce1d1e82950bbdfca2f17f3d4605f2/neonize/aioze/client.py#L942-L946

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; https://github.com/krypton-byte/neonize/blob/863306cadfce1d1e82950bbdfca2f17f3d4605f2/neonize/proto/Neonize_pb2.pyi#L719 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 https://github.com/krypton-byte/neonize/blob/863306cadfce1d1e82950bbdfca2f17f3d4605f2/neonize/utils/message.py#L11 that does that So we can do the the patching in client.send_message

@krypton-byte your thoughts?

Nubuki-all avatar Jan 31 '25 10:01 Nubuki-all

@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)

Nubuki-all avatar Feb 05 '25 11:02 Nubuki-all

Fixed in #127

Nubuki-all avatar Jun 16 '25 16:06 Nubuki-all