feat: menus por permission_type (1=info, 2=informes, 3=completo)

This commit is contained in:
Lizandro Guarnizo
2026-06-27 18:46:35 -05:00
parent 7407c716d4
commit b96dbcc394
2 changed files with 70 additions and 8 deletions
+14 -8
View File
@@ -6,9 +6,12 @@ class NormalBot
public static function process(array $company, array $context, string $input): ?array
{
$config = self::getConfig($company);
$commands = $config['commands'] ?? [];
$flows = $config['flows'] ?? [];
$menus = $config['menus'] ?? [];
$permType = (string)($company['_permission_type'] ?? 1);
$perType = $config['per_type'][$permType] ?? [];
$commands = $perType['commands'] ?? $config['commands'] ?? [];
$flows = array_merge($config['flows'] ?? [], $perType['flows'] ?? []);
$menus = array_merge($config['menus'] ?? [], $perType['menus'] ?? []);
$ctxId = null;
$botCtx = ConversationContext::getOrCreate((int)$company['id'], $context['from'], 'normal');
@@ -43,18 +46,19 @@ class NormalBot
return null;
}
$greeting = $config['greeting'] ?? null;
$greeting = $perType['greeting'] ?? $config['greeting'] ?? null;
if ($greeting !== null && $currentNode === null) {
ConversationContext::updateNode($ctxId, 'greeting');
if (isset($flows['greeting'])) {
return self::handleFlow($flows['greeting'], $context, $company, $ctxId);
$greetingFlowId = $perType['greeting_flow'] ?? 'greeting';
if (isset($flows[$greetingFlowId])) {
return self::handleFlow($flows[$greetingFlowId], $context, $company, $ctxId);
}
return self::sendText($greeting, $context['from'], $company);
}
$fallback = $config['fallback'] ?? null;
$fallback = $perType['fallback'] ?? $config['fallback'] ?? null;
if ($fallback !== null) {
return self::sendText($fallback, $context['from'], $company);
}
@@ -324,7 +328,9 @@ class NormalBot
public static function processInteractive(array $company, array $context, string $input): ?array
{
$config = self::getConfig($company);
$flows = $config['flows'] ?? [];
$permType = (string)($company['_permission_type'] ?? 1);
$perType = $config['per_type'][$permType] ?? [];
$flows = array_merge($config['flows'] ?? [], $perType['flows'] ?? []);
$botCtx = ConversationContext::getOrCreate((int)$company['id'], $context['from'], 'normal');
$ctxId = (int)$botCtx['id'];