function webhook() { $telegram = app('telegram')->bot(); $message = $telegram->getWebhookUpdates()->getMessage(); if (!$message || !$message->getFrom()) { return response('OK'); } AsukaDB::createOrUpdateUser($message->getFrom()); if (Helpers::isGroup($message->getChat())) { // Store this group if it's a new group or the title was updated if ($message->getGroupChatCreated() || $message->getSupergroupChatCreated() || $message->getNewChatParticipant()) { AsukaDB::createOrUpdateGroup($message->getChat()); } if ($message->getNewChatTitle()) { AsukaDB::updateGroup($message->getChat()); } // Check if this group is authorised to use the bot if (!Helpers::groupIsAuthorized($message->getChat())) { return response('OK'); } } if (AsukaDB::getUser($message->getFrom()->getId())->ignored) { return response('OK'); } $telegram->commandsHandler(true); return response('OK'); }