mewbotorg / mewbot

Bot go mew~
Other
0 stars 4 forks source link

core: Add Protocol support for `InputEvent`s. #238

Open javajawa opened 1 year ago

javajawa commented 1 year ago

A number of existing behaviours that are being proposed are agnostic to the kind of Input that they are coming from. When you are receiving a chat message, you don't necessarily need to know where it is from, so long as you can get the message, and reply to it.

Likewise, creators of plugins should not need to be aware of every possible InputEvent abstraction that they could use. The common solution to this would be Protocol. However as we have a marker base class that we use for registering interests, the type system does not like the simple construction of these Protocols.

This is solved by adding custom MetaClasses to override issubclass() and isinstance(). This allows the Protocols to always be considered subclasses of InputEvent, and at the same time specific InputEvents being instances of the protocols if they have the appropriate members.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

91.3% 91.3% Coverage
0.0% 0.0% Duplication

sonarcloud[bot] commented 11 months ago

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

6 New issues
0 Security Hotspots
91.3% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud