Alfred/index.php

44 lines
1005 B
PHP
Raw Normal View History

2020-03-26 00:11:37 +01:00
<?php
use Shikiryu\Bot\Bot;
use Shikiryu\Bot\Commands\Lorem;
use Shikiryu\Bot\Commands\Tasks;
use Shikiryu\Bot\Commands\TasksList;
use Shikiryu\Bot\Commands\TasksProjects;
use Shikiryu\Bot\Commands\Youtubedl;
use Shikiryu\Bot\Request;
require 'vendor/autoload.php';
error_reporting(E_ALL);
ini_set('log_errors', 1);
$config = include 'config.php';
$bot = new Bot($config);
$request = new Request($_POST);
if (!$bot->isValid($request)) {
exit(1);
}
// 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('liste.*projets?', TasksProjects::class);
$bot->hears('ajoute.*t(a|â)che (.*) dans "(.*)"', Tasks::class);
$bot->hears('(?:donne|liste).*t(?:a|â)ches? de "(.*)"', TasksList::class);
$bot->hears('(hello|hi|bonjour|salut)', function (Bot $bot) {
$bot->replyPolitely('Bonjour');
});
// Start listening
$bot->listen($_POST['text']);