# shellcheck shell=dash

___x_cmd_feishu_abot_data(){
    param:void

    [ $# -gt 0 ]    ||  set -- which

    local op="$1" ;     shift
    case "$op" in
        -h|--help)      ___x_cmd help -m feishu abot data "$@" ; return 0 ;;
        get|which|which_)
                        ___x_cmd_feishu_abot_data_"$op"   "$@" ;;
    esac
}

___x_cmd_feishu_abot_data_which_(){
    local chatid="$1"
    x_="${___X_CMD_FEISHU_BOT_PATH}/data_${chatid}.tsv"
}

___x_cmd_feishu_abot_data_which(){
    local chatid="$1"
    [ -n "$chatid" ] || N=feishu M="Not Found chat id" log:ret:1
    local x_
    ___x_cmd_feishu_abot_data_which_ "$chatid" || return $?
    printf "%s\n" "$x_"
}

___x_cmd_feishu_abot_data_get(){
    local chatid="$1"
    [ -n "$chatid" ] || N=feishu M="Not Found chat id" log:ret:1
    local data_path="${___X_CMD_FEISHU_BOT_PATH}/sent/data_${chatid}.tsv"
    [ -f "$data_path" ] || N=feishu M="Data file not found for chat ${chatid}" log:ret:1
    ___x_cmd_cmds cat "$data_path"
}
