moe-serifu-circle / moe-serifu-agent

Anime-themed personal assistant and goal-oriented intelligent agent
GNU Lesser General Public License v3.0
41 stars 7 forks source link

Adds a notification plugin, and a few tweaks to help support this #153

Closed jghibiki closed 3 years ago

jghibiki commented 3 years ago

Please reference an issue, or fill out the below information


Adds a notification plugin, with back-ends for pushbullet, email, and slack (the underlying library notifiers supports additional platforms).

Also updates the Server API system to add a ServerResponse object to better standardize the responses from the plugin/builtin server api hooks.

Also refactors the IntenEvent system to have it's own builtin. Added a handler that will take an Intent object and convert it to a typed Event subclass object that can be submitted to the event bus. This allows plugins and builtins to be loosly coupled as a builtin or plugin can create an intent which will be converted to a required typed event that another builtin or plugin can handle.

e.g.

IntentEvent({"type": "msa.plugins.my_plugin.events.MyCustomEvent", "context": { <my event init data}) 
  -> IntentHandler 
    -> MyCustomEvent instance 
      -> event bus

For example to trigger a notification via the notification plugin via the cli (requires that the notification plugin is configured, and configured to be loaded in the msa_config.json):

# Tightly coupled version, requires being able to import the SendNotificationEvent
from msa.plugins.notifications.events import SendNotificationEvent  
from msa.plugins.notifications.notification_providers import NotificationProvider
a = SendNotificationEvent()
    .init({
        "provider": NotificationProvider.pushbullet.value, 
        "title": "test!", 
        "message": "this is a sample message"
    })
    .network_propagate()

# Loosely coupled version:
from msa.builtins.intents.events.IntentEvent
a = IntentEvent()
    .init({
        "type": "msa.plugins.notifications.events.SendNotificationEvent",
        "context": {
            "provider": "pushbullet",
            "title": "test!",
            "message": "this is a sample message"
    }}
   .network_propagate()

❗️🖊 If you have not yet, please sign our Contributor License Agreement. Your PR will not be accepted until we have confirmed that you have signed.

jghibiki commented 3 years ago

Test Coverage is up to 70%, new plugins are fully tested.

jghibiki commented 3 years ago

@dekarrin Any idea why the build would be failing as it is on the git clone step?

jghibiki commented 3 years ago

Hm, well the clone step worked this time. Must have been a temp. problem.

jghibiki commented 3 years ago

:tada: build finally succeeded!

jghibiki commented 3 years ago

@dekarrin whenever you have some free time, i think this is ready for review.