From 5371f5acfb368b7efedd04c99d1000ac5ca645fc Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 28 Jun 2023 10:03:34 +0700 Subject: [PATCH] (#33) update template message for some events v4 --- resources/events/issues/action/closed.php | 10 +++------- resources/events/issues/action/deleted.php | 14 ++++++++++++++ resources/events/issues/action/edited.php | 11 +++++------ resources/events/issues/action/locked.php | 16 ++++++++++++++++ resources/events/issues/action/opened.php | 10 +++------- resources/events/issues/action/pinned.php | 16 ++++++++++++++++ resources/events/issues/action/reopened.php | 10 +++------- resources/events/issues/action/unlocked.php | 16 ++++++++++++++++ resources/events/issues/action/unpinned.php | 16 ++++++++++++++++ resources/events/issues/partials/_body.php | 14 ++++++++++++++ resources/events/ping/default.php | 2 +- resources/events/pull_request/opened.php | 4 ++++ resources/events/push/default.php | 2 +- 13 files changed, 112 insertions(+), 29 deletions(-) create mode 100644 resources/events/issues/action/deleted.php create mode 100644 resources/events/issues/action/locked.php create mode 100644 resources/events/issues/action/pinned.php create mode 100644 resources/events/issues/action/unlocked.php create mode 100644 resources/events/issues/action/unpinned.php create mode 100644 resources/events/issues/partials/_body.php diff --git a/resources/events/issues/action/closed.php b/resources/events/issues/action/closed.php index d077f4f..f38dd5c 100644 --- a/resources/events/issues/action/closed.php +++ b/resources/events/issues/action/closed.php @@ -3,18 +3,14 @@ * @var $payload mixed */ -$message = "🚫 Issue Closed to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}\n\n"; +$message = "🚫 Issue Closed to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number} by issue->user->html_url}\">@{$payload->issue->user->login}\n\n"; -$message .= "🔔 {$payload->issue->title} by issue->user->html_url}\">@{$payload->issue->user->login}\n"; +$message .= "📢 {$payload->issue->title}\n"; if (isset($payload->issue->assignee)) { $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; } -$body = $payload->issue->body; -if (strlen($body) > 50) { - $body = substr($body, 0, 50) . '...'; -} -$message .= "📖 {$body}"; +$message .= require __DIR__ . '/../partials/_body.php'; echo $message; diff --git a/resources/events/issues/action/deleted.php b/resources/events/issues/action/deleted.php new file mode 100644 index 0000000..d3730c2 --- /dev/null +++ b/resources/events/issues/action/deleted.php @@ -0,0 +1,14 @@ +Issue Deleted from repository->html_url}\">{$payload->repository->full_name} by sender->html_url}\">@{$payload->sender->login}\n\n"; + +$message .= "📢 {$payload->issue->title}\n"; + +if (isset($payload->issue->assignee)) { + $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; +} + +echo $message; diff --git a/resources/events/issues/action/edited.php b/resources/events/issues/action/edited.php index 589b796..9545d6b 100644 --- a/resources/events/issues/action/edited.php +++ b/resources/events/issues/action/edited.php @@ -3,9 +3,9 @@ * @var $payload mixed */ -$message = "⚠️ Issue has been edited to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}\n\n"; +$message = "⚠️ Issue has been edited to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number} by issue->user->html_url}\">@{$payload->issue->user->login}\n\n"; -$message .= "🔔 {$payload->issue->title} by issue->user->html_url}\">@{$payload->issue->user->login}\n"; +$message .= "📢 {$payload->issue->title}\n"; if (isset($payload->issue->assignee)) { $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; @@ -13,10 +13,9 @@ if (isset($payload->changes->title)) { $message .= "📖 Title has been changed\n"; - $message .= "📝 From: {$payload->changes->title->from}\n"; - $message .= "📝 To: {$payload->issue->title}\n"; -} -if (isset($payload->changes->body)) { + $message .= " 📝 From: {$payload->changes->title->from}\n"; + $message .= " 🏷 To: {$payload->issue->title}\n"; +} elseif (isset($payload->changes->body)) { $message .= "📖 Body has been changed\n"; $message .= "Please check the issue for more details\n"; } diff --git a/resources/events/issues/action/locked.php b/resources/events/issues/action/locked.php new file mode 100644 index 0000000..cbedc11 --- /dev/null +++ b/resources/events/issues/action/locked.php @@ -0,0 +1,16 @@ +Issue Locked from repository->html_url}\">{$payload->repository->full_name} by sender->html_url}\">@{$payload->sender->login}\n\n"; + +$message .= "📢 {$payload->issue->title}\n"; + +if (isset($payload->issue->assignee)) { + $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; +} + +$message .= require __DIR__ . '/../partials/_body.php'; + +echo $message; diff --git a/resources/events/issues/action/opened.php b/resources/events/issues/action/opened.php index e748070..001cd5d 100644 --- a/resources/events/issues/action/opened.php +++ b/resources/events/issues/action/opened.php @@ -3,18 +3,14 @@ * @var $payload mixed */ -$message = "⚠️ New Issue to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}\n\n"; +$message = "⚠️ New Issue to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number} by issue->user->html_url}\">@{$payload->issue->user->login}\n\n"; -$message .= "🔔 {$payload->issue->title} by issue->user->html_url}\">@{$payload->issue->user->login}\n"; +$message .= "📢 {$payload->issue->title}\n"; if (isset($payload->issue->assignee)) { $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; } -$body = $payload->issue->body; -if (strlen($body) > 50) { - $body = substr($body, 0, 50) . '...'; -} -$message .= "📖 {$body}"; +$message .= require __DIR__ . '/../partials/_body.php'; echo $message; diff --git a/resources/events/issues/action/pinned.php b/resources/events/issues/action/pinned.php new file mode 100644 index 0000000..49eb9b9 --- /dev/null +++ b/resources/events/issues/action/pinned.php @@ -0,0 +1,16 @@ +Issue Pinned from repository->html_url}\">{$payload->repository->full_name} by sender->html_url}\">@{$payload->sender->login}\n\n"; + +$message .= "📢 {$payload->issue->title}\n"; + +if (isset($payload->issue->assignee)) { + $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; +} + +$message .= require __DIR__ . '/../partials/_body.php'; + +echo $message; diff --git a/resources/events/issues/action/reopened.php b/resources/events/issues/action/reopened.php index f29d713..0a20b28 100644 --- a/resources/events/issues/action/reopened.php +++ b/resources/events/issues/action/reopened.php @@ -3,18 +3,14 @@ * @var $payload mixed */ -$message = "⚠️ Issue has been reopened to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}\n\n"; +$message = "⚠️⚠️ Issue has been reopened to issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number} by issue->user->html_url}\">@{$payload->issue->user->login}\n\n"; -$message .= "🔔 {$payload->issue->title} by issue->user->html_url}\">@{$payload->issue->user->login}\n"; +$message .= "📢 {$payload->issue->title}\n"; if (isset($payload->issue->assignee)) { $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; } -$body = $payload->issue->body; -if (strlen($body) > 50) { - $body = substr($body, 0, 50) . '...'; -} -$message .= "📖 {$body}"; +$message .= require __DIR__ . '/../partials/_body.php'; echo $message; diff --git a/resources/events/issues/action/unlocked.php b/resources/events/issues/action/unlocked.php new file mode 100644 index 0000000..e39397b --- /dev/null +++ b/resources/events/issues/action/unlocked.php @@ -0,0 +1,16 @@ +Issue Unlocked from repository->html_url}\">{$payload->repository->full_name} by sender->html_url}\">@{$payload->sender->login}\n\n"; + +$message .= "📢 {$payload->issue->title}\n"; + +if (isset($payload->issue->assignee)) { + $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; +} + +$message .= require __DIR__ . '/../partials/_body.php'; + +echo $message; diff --git a/resources/events/issues/action/unpinned.php b/resources/events/issues/action/unpinned.php new file mode 100644 index 0000000..1af4a41 --- /dev/null +++ b/resources/events/issues/action/unpinned.php @@ -0,0 +1,16 @@ +Issue Unpinned from repository->html_url}\">{$payload->repository->full_name} by sender->html_url}\">@{$payload->sender->login}\n\n"; + +$message .= "📢 {$payload->issue->title}\n"; + +if (isset($payload->issue->assignee)) { + $message .= "🙋 Assignee: issue->assignee->html_url}\">@{$payload->issue->assignee->login}\n\n"; +} + +$message .= require __DIR__ . '/../partials/_body.php'; + +echo $message; diff --git a/resources/events/issues/partials/_body.php b/resources/events/issues/partials/_body.php new file mode 100644 index 0000000..228f103 --- /dev/null +++ b/resources/events/issues/partials/_body.php @@ -0,0 +1,14 @@ +issue->body)) { + $body = $payload->issue->body; + if (strlen($body) > 50) { + $body = substr($body, 0, 50) . '...'; + } + return "📖 {$body}"; +} + +return ""; diff --git a/resources/events/ping/default.php b/resources/events/ping/default.php index b28c932..189bdba 100644 --- a/resources/events/ping/default.php +++ b/resources/events/ping/default.php @@ -14,7 +14,7 @@ } if (isset($payload->sender)) { - $message .= "🙋 Sender (triggered the event): {$payload->sender->login}\n"; + $message .= "👤 Sender (triggered the event): {$payload->sender->login}\n"; } echo $message; diff --git a/resources/events/pull_request/opened.php b/resources/events/pull_request/opened.php index e69de29..a960def 100644 --- a/resources/events/pull_request/opened.php +++ b/resources/events/pull_request/opened.php @@ -0,0 +1,4 @@ +url}\">{$commitId}: {$commit->message} - by {$commit->author->name}\n"; } -$message .= "\nPushed by : {$payload->pusher->name}\n"; +$message .= "\n 👤 Pushed by : {$payload->pusher->name}\n";