🎉 Hello world
This commit is contained in:
44
nextcloud.php
Normal file
44
nextcloud.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Shikiryu\Bot\Bot;
|
||||
use Shikiryu\Bot\Commands\Lorem;
|
||||
use Shikiryu\Bot\Commands\Youtubedl;
|
||||
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('log_errors', 1);
|
||||
|
||||
$config = include 'config.php';
|
||||
|
||||
$bot = new \Shikiryu\Bot\Bot($config);
|
||||
|
||||
$signature = $_SERVER['HTTP_X_NEXTCLOUD_TALK_SIGNATURE'] ?? '';
|
||||
$random = $_SERVER['HTTP_X_NEXTCLOUD_TALK_RANDOM'] ?? '';
|
||||
$server = $_SERVER['HTTP_X_NEXTCLOUD_TALK_BACKEND'] ?? '';
|
||||
|
||||
$delivery = $_SERVER['HTTP_X_H1_DELIVERY'] ?? '';
|
||||
$event = $_SERVER['HTTP_X_H1_EVENT'] ?? '';
|
||||
$signature = $_SERVER['HTTP_X_H1_SIGNATURE'] ?? '';
|
||||
|
||||
// Give the bot something to listen for.
|
||||
$bot->hears('(convertis|télécharges?) (https?:\/\/[^\s]+) en (audio|video|vidéo)', Youtubedl::class);
|
||||
|
||||
$bot->hears('lorem( ipsum)?', Lorem::class);
|
||||
|
||||
$bot->hears('(hello|hi|bonjour|salut)', function (\Shikiryu\Bot\Bot $bot) {
|
||||
$bot->replyPolitely('Bonjour');
|
||||
});
|
||||
|
||||
$body = file_get_contents('php://input');
|
||||
$data = json_decode($body, true);
|
||||
|
||||
if ($data['type'] !== 'Create' || $data['object']['name'] !== 'message') {
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
$message = json_decode($data['object']['content'], true)['message'];
|
||||
|
||||
$bot->listen($message);
|
Reference in New Issue
Block a user