# shellcheck shell=dash
___X_CMD_TELEGRAM_BOT_DATA_MEDIA_DIR="$___X_CMD_ROOT_DATA/telegram/bot/data"

___x_cmd_telegram_bot_data(){
    param:void

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

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

___x_cmd_telegram_bot_data_which_(){
    local chatid="$1"
    x_="${___X_CMD_TELEGRAM_BOT_PATH}/data_${chatid}.tsv"
}

___x_cmd_telegram_bot_data_which(){
    local chatid="$1"
    [ -n "$chatid" ] || N=telegram M="Not Found chat id" log:ret:1

    local x_
    ___x_cmd_telegram_bot_data_which_ "$chatid" || return $?
    printf "%s\n" "$x_"
}

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