public function handle(Request $request) { foreach ($this->handlers as $handler) { if ($this->isAdminCommand() && !$request->isAdmin()) { continue; } $type = $handler['type']; if ($type === 'responds' && !$request->isBotMention()) { continue; } $pattern = $handler['pattern']; $callback = $handler['callback']; $content = $request->getContent($type === 'responds'); $regex = Factory::getGuard(); $matched = $regex->match($pattern, $content, $matches); if (!$matched) { continue; } if ($callback($request, $matches) !== false) { return true; } } return false; }