Add better ytdl

This commit is contained in:
2024-08-06 16:06:07 +02:00
parent a63538c768
commit 1dfcb4a4d5
8 changed files with 895 additions and 63 deletions

View File

@@ -12,7 +12,7 @@ ini_set('log_errors', 1);
$config = include 'config.php';
$bot = new \Shikiryu\Bot\Bot($config);
$bot = new Bot($config);
$signature = $_SERVER['HTTP_X_NEXTCLOUD_TALK_SIGNATURE'] ?? '';
$random = $_SERVER['HTTP_X_NEXTCLOUD_TALK_RANDOM'] ?? '';
@@ -27,18 +27,26 @@ $bot->hears('(convertis|télécharges?) (https?:\/\/[^\s]+) en (audio|video|vid
$bot->hears('lorem( ipsum)?', Lorem::class);
$bot->hears('(hello|hi|bonjour|salut)', function (\Shikiryu\Bot\Bot $bot) {
$bot->hears('(hello|hi|bonjour|salut)', function (Bot $bot) {
$bot->replyPolitely('Bonjour');
});
$body = file_get_contents('php://input');
$data = json_decode($body, true);
try {
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
$data = [];
}
// Only on message, not on event or whatever
if ($data['type'] !== 'Create' || $data['object']['name'] !== 'message') {
return ;
}
$message = json_decode($data['object']['content'], true)['message'];
try {
$message = json_decode($data['object']['content'], true, 512, JSON_THROW_ON_ERROR)['message'];
} catch (JsonException $e) {
return;
}
$bot->listen($message);