# -*- coding: utf-8 -*-
# /var/www/html/fluxo_geral.py

import json
from utils_hibrido import registrar_log, enviar_whatsapp

def processar(conn, cursor, job, atendimento, configs, mensagem_bruta):
    atendimento_id = atendimento['id']
    numero = atendimento['cliente_numero']
    
    registrar_log('GERAL', f"Atendimento {atendimento_id} encaminhado para fila Geral")
    
    enviar_whatsapp(configs, numero, "Vou transferir você para o setor de Atendimento Geral. Por favor, aguarde.")
    
    cursor.execute("""
        UPDATE atendimentos
        SET status = 'fila', setor_id = 1, fluxo_atual = 'HUMANO', estado_atual = 'AGUARDANDO'
        WHERE id = %s
    """, (atendimento_id,))
    conn.commit()
