Changed used avatar url + added actions when app is ran in development enviroment
This commit is contained in:
@@ -126,13 +126,19 @@ class WebhookController extends Controller
|
||||
$twitchWebhook->save();
|
||||
$twitchWebhook->callback .= "?hook_id=" . $twitchWebhook->id;
|
||||
$subscription = Twitch::subscribeWebhook($twitchWebhook->callback, $topic, $lease);
|
||||
|
||||
} else if (config("app.env") !== "production") {
|
||||
$subscription = Twitch::subscribeWebhook($twitchWebhook->callback, $topic, $lease);
|
||||
$twitchWebhook->expires_at = Carbon::now()->addSeconds($lease);
|
||||
}
|
||||
|
||||
$twitchWebhook->save();
|
||||
|
||||
if ((isset($subscription) && $subscription->success) || true) {
|
||||
if (isset($subscription) && $subscription->success) {
|
||||
return response("Ok");
|
||||
} else {
|
||||
$twitchWebhook->disabled = true;
|
||||
$twitchWebhook->save();
|
||||
return response()->json($subscription, $subscription->status);
|
||||
}
|
||||
}
|
||||
@@ -197,7 +203,10 @@ class WebhookController extends Controller
|
||||
$twitchWebhook->save();
|
||||
}
|
||||
|
||||
if ($eventType === "start" && $twitchWebhook->webhookActions) {
|
||||
if (
|
||||
($eventType === "start" && $twitchWebhook->webhookActions) ||
|
||||
(config("app.env") !== "production" && $twitchWebhook->webhookActions && $eventType !== "end")
|
||||
) {
|
||||
// TODO: move this (generation of the message embed) to a separate method
|
||||
$userInfo = Twitch::getUserById(intval($data["user_id"]))->data[0];
|
||||
$gameInfo = null;
|
||||
@@ -208,7 +217,7 @@ class WebhookController extends Controller
|
||||
|
||||
$embed = new DiscordEmbedMessage();
|
||||
$embed->setUsername(config("app.name"))
|
||||
->setAvatar("https://tse1.mm.bing.net/th?id=OIP.kncd96A4OjouPDpT8ymkIAHaHa&pid=Api&f=1")
|
||||
->setAvatar(asset("img/twitch-icon.png"))
|
||||
->setContent("¡Hola @everyone! " . $data["user_name"] . " está ahora en directo https://twitch.tv/" . $userInfo->login . " ! Ven a verle :wink:!")
|
||||
// embed
|
||||
->setColor(hexdec(substr("#9147ff", 1)))
|
||||
@@ -222,11 +231,8 @@ class WebhookController extends Controller
|
||||
->addField("Espectadores", $data["viewer_count"], true);
|
||||
|
||||
foreach($twitchWebhook->webhookActions as $hookAction) {
|
||||
|
||||
// TODO: change the url with the appropiate one
|
||||
$webhook = new DiscordWebhook($hookAction->discord_hook_url);
|
||||
$webhook->send($embed);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user