nhance/app/Controllers/Chatbot/TypingMiddleware.php
2025-02-04 15:51:39 +05:30

28 lines
610 B
PHP

<?php
namespace App\Controllers\Chatbot;
use BotMan\BotMan\BotMan;
class TypingMiddleware
{
/**
* Handle the middleware logic.
*
* @param BotMan $bot
* @param callable $next
* @return mixed
*/
public function handle($bot, $next)
{
$this->myLogger = \Config\Services::mylogger();
$this->myLogger->logme('error', 'MIDDLEWARE');
// Simulate typing indicator
$bot->types();
sleep(0.1); // Cap delay at 5 seconds (convert to microseconds)
// Proceed to the next middleware or response
return $next($bot);
}
}