alfred-nextcloud/nextcloud.php

31 lines
677 B
PHP

<?php
use Shikiryu\Bot\Bot;
use Shikiryu\Bot\Request;
require 'vendor/autoload.php';
error_reporting(E_ALL);
ini_set('log_errors', 1);
$config = include __DIR__.'/config.php';
$request = new Request($config);
$bot = new Bot($request, $config);
if (!$request->isValid()) {
$bot->reply('I received an invalid request');
exit;
}
// Give the bot something to listen for.
foreach ($bot->listCommands() as $command) {
$bot->hears(call_user_func([$command, 'getPattern']), $command);
}
$bot->hears('(hello|hi|bonjour|salut)', function (Bot $bot) { $bot->replyPolitely('Bonjour'); });
if (!$request->isMessage()) { exit(); }
$bot->listen($request->getMessage());