Skip to content

Commit

Permalink
(#33) update template message for some events v4
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Jun 28, 2023
1 parent 8b54248 commit 5371f5a
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 29 deletions.
10 changes: 3 additions & 7 deletions resources/events/issues/action/closed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* @var $payload mixed
*/

$message = "🚫 <b>Issue Closed </b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a>\n\n";
$message = "🚫 <b>Issue Closed </b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n\n";

$message .= "🔔 <b>{$payload->issue->title}</b> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n";
$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\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;
14 changes: 14 additions & 0 deletions resources/events/issues/action/deleted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @var $payload mixed
*/

$message = "️🗑 <b>Issue Deleted</b> from <a href=\"{$payload->repository->html_url}\">{$payload->repository->full_name} </a> by <a href=\"{$payload->sender->html_url}\">@{$payload->sender->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

echo $message;
11 changes: 5 additions & 6 deletions resources/events/issues/action/edited.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
* @var $payload mixed
*/

$message = "⚠️ <b>Issue has been edited</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a>\n\n";
$message = "⚠️ <b>Issue has been edited</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n\n";

$message .= "🔔 <b>{$payload->issue->title}</b> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n";
$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

if (isset($payload->changes->title)) {
$message .= "📖 <b>Title</b> has been changed\n";
$message .= "📝 <b>From:</b> {$payload->changes->title->from}\n";
$message .= "📝 <b>To:</b> {$payload->issue->title}\n";
}
if (isset($payload->changes->body)) {
$message .= " 📝 <b>From:</b> {$payload->changes->title->from}\n";
$message .= " 🏷 <b>To:</b> {$payload->issue->title}\n";
} elseif (isset($payload->changes->body)) {
$message .= "📖 <b>Body</b> has been changed\n";
$message .= "Please check the issue for more details\n";
}
Expand Down
16 changes: 16 additions & 0 deletions resources/events/issues/action/locked.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
*/

$message = "🔒 <b>Issue Locked</b> from <a href=\"{$payload->repository->html_url}\">{$payload->repository->full_name} </a> by <a href=\"{$payload->sender->html_url}\">@{$payload->sender->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

$message .= require __DIR__ . '/../partials/_body.php';

echo $message;
10 changes: 3 additions & 7 deletions resources/events/issues/action/opened.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* @var $payload mixed
*/

$message = "⚠️ <b>New Issue</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a>\n\n";
$message = "⚠️ <b>New Issue</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n\n";

$message .= "🔔 <b>{$payload->issue->title}</b> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n";
$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\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;
16 changes: 16 additions & 0 deletions resources/events/issues/action/pinned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
*/

$message = "📌 <b>Issue Pinned</b> from <a href=\"{$payload->repository->html_url}\">{$payload->repository->full_name} </a> by <a href=\"{$payload->sender->html_url}\">@{$payload->sender->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

$message .= require __DIR__ . '/../partials/_body.php';

echo $message;
10 changes: 3 additions & 7 deletions resources/events/issues/action/reopened.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* @var $payload mixed
*/

$message = "⚠️ <b>Issue has been reopened</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a>\n\n";
$message = "⚠️⚠️ <b>Issue has been reopened</b> to <a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n\n";

$message .= "🔔 <b>{$payload->issue->title}</b> by <a href=\"{$payload->issue->user->html_url}\">@{$payload->issue->user->login}</a>\n";
$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\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;
16 changes: 16 additions & 0 deletions resources/events/issues/action/unlocked.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
*/

$message = "🔐 <b>Issue Unlocked</b> from <a href=\"{$payload->repository->html_url}\">{$payload->repository->full_name} </a> by <a href=\"{$payload->sender->html_url}\">@{$payload->sender->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

$message .= require __DIR__ . '/../partials/_body.php';

echo $message;
16 changes: 16 additions & 0 deletions resources/events/issues/action/unpinned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
*/

$message = "🔔 <b>Issue Unpinned</b> from <a href=\"{$payload->repository->html_url}\">{$payload->repository->full_name} </a> by <a href=\"{$payload->sender->html_url}\">@{$payload->sender->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

if (isset($payload->issue->assignee)) {
$message .= "🙋 Assignee: <a href=\"{$payload->issue->assignee->html_url}\">@{$payload->issue->assignee->login}</a>\n\n";
}

$message .= require __DIR__ . '/../partials/_body.php';

echo $message;
14 changes: 14 additions & 0 deletions resources/events/issues/partials/_body.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @var $payload mixed
*/

if (!empty($payload->issue->body)) {
$body = $payload->issue->body;
if (strlen($body) > 50) {
$body = substr($body, 0, 50) . '...';
}
return "📖 {$body}";
}

return "";
2 changes: 1 addition & 1 deletion resources/events/ping/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

if (isset($payload->sender)) {
$message .= "🙋 Sender (triggered the event): <b>{$payload->sender->login}</b>\n";
$message .= "👤 Sender (triggered the event): <b>{$payload->sender->login}</b>\n";
}

echo $message;
4 changes: 4 additions & 0 deletions resources/events/pull_request/opened.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
/**
* @var $payload mixed
*/
2 changes: 1 addition & 1 deletion resources/events/push/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
$message .= "<a href=\"{$commit->url}\">{$commitId}</a>: {$commit->message} - by <i>{$commit->author->name}</i>\n";
}

$message .= "\nPushed by : <b>{$payload->pusher->name}</b>\n";
$message .= "\n 👤 Pushed by : <b>{$payload->pusher->name}</b>\n";

0 comments on commit 5371f5a

Please sign in to comment.