Closed Badiboy closed 10 months ago
Or at least make some stubs returning None with warnings in InaccessibleMessage to prevent such fails.
Yes, we didn't think of that.. What are the side effects of inheriting message in inaccessiblemessage? It is a hard decision, because firstly, by inheriting message we will probably introduce more trouble.. secondly, I believe we cannot do anything against API change which breaks everything... So I guess maybe we could return warnings when trying to access non-existent fields in the class..
I also do not like that. But the situation is really VERY bad. Once again: not for me, but for users. I know what happend and will care about it).
Wait, i'll think about making some kind of universal stub for any Message field there. I'll let you know.
Did not found better way, because fields of Message are dynamically constructed and this cannot be automated.
If you confirm - I'll push the update.
PS. The idea of developers to add InaccessibleMessage to Bot API is really shitty. 😔
why not use getattr?
because fields of Message are dynamically constructed and this cannot be automated 👆
Or you mean override it?
"Called when an attribute lookup has not found the attribute in the usual places (i.e. it is not an instance attribute nor is it found in the class tree for self)." Why not just create getattr function in inaccessiblemessage ?
and maybe remove inheriting from message to make it work
Why not just create getattr function in inaccessiblemessage ?
I'll check, thanks.
and maybe remove inheriting from message to make it work
No inheritance.
Like this?
Yes
@coder2020official
Due to new InaccessibleMessage returned for some cases I got a lot of troubles in project. Before I can access fields like message.from and check if they are filled:
and lot of other fields of message. They were always presented but None if not accessible.
Now all such code raises exceptions, because InaccessibleMessage has no such fields!
For me personally I'll update the project, it's not so critical. BUT. It will bring great backward incompatibility for thousands of users.
I propose to inherit InaccessibleMessage from Message to keep compatibility.