mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-08-26 18:56:41 -04:00
8cdd62509d
- Updated the PluginExecutor and related classes to improve type annotations and clarity, particularly in methods handling OAuth credentials and trigger subscriptions. - Refactored the PluginRegistration and TriggerFactory classes to streamline the retrieval of trigger providers and event handlers, ensuring better type safety and consistency. - Adjusted the YAML loader function to specify return types, enhancing code readability and maintainability. These changes improve the overall structure and usability of the trigger subscription system, making it more robust and easier to understand.
30 lines
907 B
Python
30 lines
907 B
Python
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from werkzeug import Request
|
|
|
|
from dify_plugin.entities.trigger import Variables
|
|
from dify_plugin.interfaces.trigger import Event
|
|
|
|
|
|
class StarCreatedEvent(Event):
|
|
"""
|
|
GitHub Star Created Event
|
|
|
|
This event transforms GitHub star created webhook events and extracts relevant
|
|
information from the webhook payload to provide as variables to the workflow.
|
|
"""
|
|
|
|
def _on_event(self, request: Request, parameters: Mapping[str, Any]) -> Variables:
|
|
"""
|
|
Transform GitHub star created webhook event into structured Variables
|
|
"""
|
|
payload = request.get_json()
|
|
if not payload:
|
|
raise ValueError("No payload received")
|
|
|
|
sender = payload.get("sender")
|
|
if not sender:
|
|
raise ValueError("No sender data in payload")
|
|
return Variables(variables={**payload})
|