-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f6ef75
commit f38f9de
Showing
5 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pydantic import BaseModel | ||
|
||
from wechatter.models.github.base import Repository, User | ||
|
||
|
||
class Release(BaseModel): | ||
url: str | ||
assets_url: str | ||
upload_url: str | ||
html_url: str | ||
author: User | ||
body: str | ||
tag_name: str | ||
target_commitish: str | ||
name: str | ||
draft: bool | ||
prerelease: bool | ||
created_at: str | ||
published_at: str | ||
id: int | ||
|
||
|
||
class GithubReleaseWebhook(BaseModel): | ||
action: str | ||
release: Release | ||
repository: Repository | ||
sender: User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from loguru import logger | ||
|
||
from wechatter.models.github import GithubReleaseWebhook | ||
from wechatter.sender import sender | ||
from wechatter.webhook_handlers.hanlders import github_webhook_handler | ||
|
||
|
||
@github_webhook_handler("release") | ||
def handle_release(data: dict): | ||
payload = GithubReleaseWebhook(**data) | ||
if payload.action != "published": | ||
return | ||
logger.info( | ||
f"Release event on {payload.release.html_url} in repository {payload.repository.full_name}." | ||
) | ||
message = ( | ||
"== GitHub Release 事件 ==\n" | ||
f"🚀 新的版本发布了!\n" | ||
f"📚 仓库:{payload.repository.full_name}\n" | ||
f"🏷️ 版本:{payload.release.tag_name}\n" | ||
f"🧑💻 提交者:{payload.sender.login}\n" | ||
f"🔗 查看详情:{payload.release.html_url}" | ||
) | ||
|
||
sender.mass_send_msg_to_github_webhook_receivers(message) |