Skip to content

Commit

Permalink
👽 regenerate event list
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Jan 1, 2024
1 parent dd80ea3 commit 7a38424
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ repos:
stages: [commit]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.11.0
rev: 23.12.1
hooks:
- id: black
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json]
Expand Down
18 changes: 9 additions & 9 deletions nonebot/adapters/github/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,23 @@ def payload_to_event(
types = events.get(event_name)
if isinstance(types, dict):
if action := event_payload.get("action"):
return types[action].parse_obj({
"id": event_id, "name": event_name, "payload": event_payload
})
return types[action].parse_obj(
{"id": event_id, "name": event_name, "payload": event_payload}
)
else:
raise ValueError(
f"Payload missing action, either of {', '.join(types)}."
)
elif types is None:
raise ValueError(f"Unknown event type {event_name}.")
return types.parse_obj({
"id": event_id, "name": event_name, "payload": event_payload
})
return types.parse_obj(
{"id": event_id, "name": event_name, "payload": event_payload}
)
except Exception as e:
log("WARNING", f"Failed to parse webhook payload {event_id}", e)
return Event.parse_obj({
"id": event_id, "name": event_name, "payload": event_payload
})
return Event.parse_obj(
{"id": event_id, "name": event_name, "payload": event_payload}
)

@classmethod
def custom_send(
Expand Down
26 changes: 26 additions & 0 deletions nonebot/adapters/github/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@
from githubkit.webhooks.models import (
DependabotAlertDismissed as DependabotAlertDismissedPayload,
)
from githubkit.webhooks.models import (
DeploymentReviewApproved as DeploymentReviewApprovedPayload,
)
from githubkit.webhooks.models import (
DeploymentReviewRejected as DeploymentReviewRejectedPayload,
)
from githubkit.webhooks.models import (
DiscussionCommentCreated as DiscussionCommentCreatedPayload,
)
Expand All @@ -272,6 +278,9 @@
from githubkit.webhooks.models import (
CodeScanningAlertReopened as CodeScanningAlertReopenedPayload,
)
from githubkit.webhooks.models import (
DeploymentReviewRequested as DeploymentReviewRequestedPayload,
)
from githubkit.webhooks.models import (
DiscussionCategoryChanged as DiscussionCategoryChangedPayload,
)
Expand Down Expand Up @@ -656,6 +665,18 @@ class DeploymentProtectionRuleRequested(Event):
payload: DeploymentProtectionRuleRequestedPayload


class DeploymentReviewApproved(Event):
payload: DeploymentReviewApprovedPayload


class DeploymentReviewRejected(Event):
payload: DeploymentReviewRejectedPayload


class DeploymentReviewRequested(Event):
payload: DeploymentReviewRequestedPayload


class DeploymentStatusCreated(Event):
payload: DeploymentStatusCreatedPayload

Expand Down Expand Up @@ -1494,6 +1515,11 @@ class WorkflowRunRequested(Event):
"deployment_protection_rule": {
"requested": DeploymentProtectionRuleRequested,
},
"deployment_review": {
"approved": DeploymentReviewApproved,
"rejected": DeploymentReviewRejected,
"requested": DeploymentReviewRequested,
},
"deployment_status": {
"created": DeploymentStatusCreated,
},
Expand Down

0 comments on commit 7a38424

Please sign in to comment.