alfred-nextcloud/nextcloud.php

31 lines
677 B
PHP
Raw Normal View History

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