Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 优化GitHub webhook消息排版 #73

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ python3 -m wechatter
| | `to_person_list` | 消息转发目标用户列表,即消息接收用户 | 可以填多个用户名称或为空列表 |
| | `to_group_list` | 消息转发目标群列表,即消息接收群 | 可以填多个群名称或为空列表 |

### ⚙️ Offical Account Reminder 配置
### ⚙️ Official Account Reminder 配置

| 配置项 | 子项 | 解释 | 备注 |
| --- | --- | --- | --- |
Expand Down
4 changes: 2 additions & 2 deletions wechatter/webhook_handlers/github/create_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle_create(data: dict):
if payload.ref_type == "branch":
logger.info(f"Branch {payload.ref} was created by {payload.sender.login}.")
message = (
"==== GitHub Create 事件 ====\n"
"== GitHub Create 事件 ==\n"
"🆕 有新的分支创建!\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🆕 创建了 {payload.ref} 分支\n"
Expand All @@ -22,7 +22,7 @@ def handle_create(data: dict):
elif payload.ref_type == "tag":
logger.info(f"Tag {payload.ref} was created by {payload.sender.login}.")
message = (
"==== GitHub Create 事件 ====\n"
"== GitHub Create 事件 ==\n"
"🆕 有新的标签创建!\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🆕 创建了 {payload.ref} 标签\n"
Expand Down
4 changes: 2 additions & 2 deletions wechatter/webhook_handlers/github/delete_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle_delete(data: dict):
if payload.ref_type == "branch":
logger.info(f"Branch {payload.ref} was deleted by {payload.sender.login}")
message = (
"==== GitHub Delete 事件 ====\n"
"== GitHub Delete 事件 ==\n"
f"🚮 有分支被删除了!\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🚮 删除了 {payload.ref} 分支\n"
Expand All @@ -22,7 +22,7 @@ def handle_delete(data: dict):
elif payload.ref_type == "tag":
logger.info(f"Tag {payload.ref} was deleted by {payload.sender.login}")
message = (
"==== GitHub Delete 事件 ====\n"
"== GitHub Delete 事件 ==\n"
f"🚮 有标签被删除了!\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🚮 删除了 {payload.ref} 标签\n"
Expand Down
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/fork_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle_fork(data: dict):
f"A new fork by {payload.sender.login} to {payload.repository.full_name}"
)
message = (
"==== GitHub Fork 事件 ====\n"
"== GitHub Fork 事件 ==\n"
f"🍴 {payload.repository.full_name} 有新的 Fork!🆙\n"
)
sender.mass_send_msg_to_github_webhook_receivers(message)
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/issue_comment_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def handle_issue_comment(data: dict):
else:
content = payload.comment.body
message = (
"==== GitHub Comment 事件 ====\n"
"== GitHub Comment 事件 ==\n"
f"💬 有评论被 {payload.action.capitalize()} !\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"📝 标题:{payload.issue.title}\n"
Expand Down
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/issue_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle_issue(data: dict):
f"Issue {payload.issue.number} was {payload.action} by {payload.issue.user.login}."
)
message = (
"==== GitHub Issue 事件 ====\n"
"== GitHub Issue 事件 ==\n"
f"📬 有问题被 {payload.action.capitalize()} !\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"📝 标题:{payload.issue.title}\n"
Expand Down
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/ping_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def handle_ping(data: dict):
payload = GithubPingWebhook(**data)
logger.info(f"Ping from {payload.repository.full_name}.")
message = (
"==== GitHub Ping 事件 ====\n"
"== GitHub Ping 事件 ==\n"
"❇️ 有 Ping 事件!\n"
f"📝 ZEN:{payload.zen}\n"
f"📚 仓库:{payload.repository.full_name}\n"
Expand Down
4 changes: 2 additions & 2 deletions wechatter/webhook_handlers/github/pr_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle_pr(data: dict):
# 如果是closed,判断是否是合并
if payload.action == "closed" and payload.pull_request.merged:
message = (
"==== GitHub Pull Request 事件 ====\n"
"== GitHub Pull Request 事件 ==\n"
f"⬇️ 有 PR 被 Merged !🥳\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"📝 标题:{payload.pull_request.title}\n"
Expand All @@ -25,7 +25,7 @@ def handle_pr(data: dict):
sender.mass_send_msg_to_github_webhook_receivers(message)
return
message = (
"==== GitHub Pull Request 事件 ====\n"
"== GitHub Pull Request 事件 ==\n"
f"⬇️ 有 PR 被 {payload.action.capitalize()} !\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🌱 分支: {payload.pull_request.head.ref}\n"
Expand Down
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/pr_review_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle_pr_review(data: dict):
f"Pull Request Review {payload.review.state} by {payload.review.user.login}."
)
message = (
"==== GitHub Pull Request Review 事件 ====\n"
"== GitHub Pull Request Review 事件 ==\n"
f"⬇️ 有 PR Review 被 {payload.review.state.capitalize()} !\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"📝 标题:{payload.pull_request.title}\n"
Expand Down
2 changes: 1 addition & 1 deletion wechatter/webhook_handlers/github/push_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def handle_push(data: dict):
# 用 h5 的 a 标签,用于在微信中打开(经测试微信会吞掉 href 里的链接),下面方法失效
# branch_url = '<a href=" https://github.com/Cassius0924 ">查看详情</a>'
message = (
"==== GitHub Push 事件 ====\n"
"== GitHub Push 事件 ==\n"
"🚀 新的代码已经推送到了仓库!\n"
f"📚 仓库:{payload.repository.full_name}\n"
f"🌱 分支:{payload.ref}\n"
Expand Down
4 changes: 2 additions & 2 deletions wechatter/webhook_handlers/github/star_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def handle_star(data: dict):
logger.info(f"Star {payload.action} by {payload.sender.login}.")
if payload.action == "created":
message = (
"==== GitHub Star 事件 ====\n"
"== GitHub Star 事件 ==\n"
f"⭐️ {payload.repository.full_name} 的 Star 数量 +1 🆙!\n"
)
sender.mass_send_msg_to_github_webhook_receivers(message)
else:
message = (
"==== GitHub Star 事件 ====\n"
"== GitHub Star 事件 ==\n"
f"⭐️ {payload.repository.full_name} 的 Star 数量 -1 🔽!\n"
)
sender.mass_send_msg_to_github_webhook_receivers(message)
Loading