Files
dify-plugin-sdks/python/examples/github_trigger/events/star/star_created.py
T
Harry 8cdd62509d refactor: enhance trigger subscription handling and improve type annotations
- 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.
2025-10-11 21:09:12 +08:00

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