Skip to content

Instantly share code, notes, and snippets.

@acidjazz
Created August 8, 2021 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidjazz/d8da559adbf9cd533154a83b1e142242 to your computer and use it in GitHub Desktop.
Save acidjazz/d8da559adbf9cd533154a83b1e142242 to your computer and use it in GitHub Desktop.
webhooks
<?
public function test()
{
if ($this->hook->type === 'discord') {
Http::post(
$this->hook->url,
[
'username' => 'fume',
'avatar_url' => 'https://fume.app/fume-light-full.png',
'embeds' => [
[
'author' => [
'name' => 'Spicy Chicken',
'icon_url' =>
'https://haze.s3.amazonaws.com/hB436S9eEeTPxFrqcGItJ9iVyeHPDqBIfwwBQsuM.jpg',
],
'color' => '3551096',
'url' => 'https://fume.app/',
'fields' => [
[
'name' => 'Commit',
'value' =>
<<<'TAG'
Bob Chevrolet committed [⬆️ Updated dependencies](https://github.com) to [master](https://github.com/)
TAG
,
],
[
'name' => 'Deployment',
'value' =>
<<<'TAG'
John smith deployed [spicy chicken](https://fume.app) to
[staging](https://fume.app/) using the Fume CLI on John's Macbook Pro
TAG
,
],
],
],
],
]
);
}
if ($this->hook->type === 'slack') {
$commit = <<<'TAG'
Bob Chevrolet committed <https://github.com|⬆️ Updated dependencies> to <https://github.com|master>
TAG;
$deployment = <<<'TAG'
John smith deployed <https://fume.app|spicy chicken> to
<https://fume.app/|staging> using the Fume CLI on John's Macbook Pro
TAG;
$payload = [
'username' => 'fume',
'icon_url' => 'https://fume.app/fume-light-full.png',
'text' => <<<'TAG'
Project: *Spicy Chicken*
TAG
. "\n" . ' *Commit* ' . "\n\t" . $commit . "\n" . ' *Deployment* ' . "\n\t" . $deployment . "\n\n",
];
Http::post($this->hook->url, $payload);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment