Get the code below and convert it to a telegram bot based on “python-telegram-bot 3.17”, but change its funtion to like these explanation:

- It should review and analyze the files when someone forward it to the bot according the sample bashscript below.
- Only Device Overview, Config Overview and mining Overview are needed as first responses.
- If the user send /error it should shows last errors.
- if the user send /warn it should shows last warns.

#!/bin/sh

################################
# Project name: BOS+ Log Reader macOS version
# Description: Braiins OS+ Support Archive Parser/Reader
# Share your ideas to <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
################################

version=1.2.0

######## Defining colors ########
RED='\033[0;31m'
GRN='\033[0;32m'
YEL='\033[0;33m'
PRL='\033[0;34m'
CYN='\033[0;35m'
BLU='\033[0;36m'
NC='\033[0m'

######## Usage #########
usage() {
if [ $# -eq 0 ]; then
        echo " "
        echo "Usage: ${GRN}sh $0 ${CYN}<flag>${NC}"
        echo " "
        echo "==================== Flags ===================="
        echo "-d Deeper review for errors, warns and compressed bosminer.log.*.gz files"
        echo "-c Open the bosminer.log in an app (default is VS Code)"
        echo "-s Review for notable events e.g. shutdown"
        echo "-v Show version"
        echo "-h Show helps"
        echo "=============================================="
    exit 1
fi
}

######## Operation flags ########
code=0
deep=0
smart=0
while getopts "dvhsc" opt; do
        case $opt in
        d) 
          deep=1 ;;
        v) 
          echo "Version $version" 
          exit 0 ;;
        h) 
          echo " "
          echo "==================== Flags ===================="
          echo "-d Deeper review for errors, warns and compressed bosminer.log.*.gz files"
          echo "-c Open the bosminer.log in an app (default is VS Code)"
          echo "-s Review for notable events e.g. shutdown"
          echo "-v Show version"
          echo "-h Show helps"
          echo "=============================================="
          exit 0 ;;
        s)
          smart=1 ;; 
        c)
          code=1 ;; 
        *)
        usage ;;    
        
        esac
done

# Type the support_archive file name
read -p "Type archive name (Hit ENTER for default name 'support_archive.zip.enc')? " -e in_name
in_name=${in_name:-support_archive.zip.enc}
        
# Type the folder name that you want to decoded into it
read -p "Output folder name (Hit ENTER for default name 'support_archive')? " -e out_name
out_name=${out_name:-support_archive}


######## Check log version ########
if [[ $in_name == *.zip ]]; then

    # unzip archive
    unzip -q -P braiins "$in_name" -d "$out_name"

    ver=2101
    filepath="$out_name"
    configpath="$out_name"/bosminer.toml
    pingpath="$out_name"/ping
    localip="$out_name"/ifconfig
    metricspath="$out_name"/log/metrics.prom
    logpath="$out_name"/log/syslog
    loggzpath="$out_name"/log/syslog.*
    profilepath="$out_name"/bosminer-autotune.json
    hwidpah="$out_name"/miner_hwid
    refidpath="$out_name"/bos_refid

elif [[ $in_name == *.zip*.enc ]]; then

    # decrypt and unzip archive
    openssl aes-128-cbc -d -md md5 -nosalt -pass pass:braiins -in "$in_name" -out "$out_name".zip
    # Unzip decode zip file
    unzip -q "$out_name".zip -d "$out_name"
    # Remove decoded zip file
    rm "$out_name".zip

    bosver=$(cat "$out_name"/filesystem/etc/bos_version)

    if [[ $bosver == *"22.05-plus"* ]]; then
        ver=2205
        filepath="$out_name"/filesystem/etc
        configpath="$out_name"/filesystem/etc/bosminer.toml
        pingpath="$out_name"/builtin/ping_report
        metricspath="$out_name"/filesystem/var/log/metrics.prom
        logpath="$out_name"/filesystem/var/log/syslog
        loggzpath="$out_name"/log/syslog.*
        uptimepath="$out_name"/filesystem/proc/uptime
        ippath="$out_name"/builtin/public_ip
        localip="$out_name"/command/ifconfig_-a
        profilepath="$out_name"/filesystem/etc/bosminer-autotune.json
        hwidpah="$out_name"/filesystem/tmp/miner_hwid
        refidpath="$out_name"/filesystem/etc/bos_refid
        platformpath="$out_name"/filesystem/etc/bos_platform
        dmesgpath="$out_name"/command/dmesg
        cpupath="$out_name"/filesystem/proc/cpuinfo
    else
        ver=latest
        filepath="$out_name"/filesystem/etc
        configpath="$out_name"/filesystem/etc/bosminer.toml
        pingpath="$out_name"/builtin/ping_report
        metricspath="$out_name"/filesystem/var/log/metrics/metrics.prom
        logpath="$out_name"/filesystem/var/log/bosminer/bosminer.log
        loggzpath="$out_name"/filesystem/var/log/bosminer/bosminer.log.*
        uptimepath="$out_name"/filesystem/proc/uptime
        ippath="$out_name"/builtin/public_ip
        localip="$out_name"/command/ifconfig_-a
        profilepath="$out_name"/filesystem/etc/bosminer-autotune.json
        hwidpah="$out_name"/filesystem/tmp/miner_hwid
        refidpath="$out_name"/filesystem/etc/bos_refid
        platformpath="$out_name"/filesystem/etc/bos_platform
        dmesgpath="$out_name"/command/dmesg
        cpupath="$out_name"/filesystem/proc/cpuinfo
    fi    

else

    echo "The file name is not recognized!"    

fi

######## Collecting logs ########
echo " "
printf "${PRL}============================ Device Overview ============================ \n${NC}"
# board=$filepath/board.json
# if [[ -f "$board" ]]; then
#         sed -e '4q;d' $filepath/board.json | xargs -L1 echo "Board"
# fi
grep -o 'BHB[0-9]*' $dmesgpath | xargs -L1 echo "Variant:   "
grep -m1 'PSU: version' $logpath | cut -d\' -f2 | awk '{print $1}' | xargs -L1 echo "PSU type:  "
if [[ -f $platformpath ]]; then
cat $filepath/bos_platform | xargs -L1 echo "Platform:  "
fi
grep 'Hardware' $cpupath | cut -d':' -f2 | sed 's/Generic AM33XX/BeagleBone/' | xargs -L1 echo "CB Type:   "
cat $filepath/bos_mode | xargs -L1 echo "BOS+ Mode: "
cat $filepath/bos_version | xargs -L1 echo "Version:   "
printf "${BLU}"
cat $hwidpah | xargs -L1 echo "HW ID:     "
printf "${NC}"
grep -m1 'inet addr' $localip | cut -d: -f2 | awk '{print $1}' | xargs -L1 echo "Local IP:  "
if [[ -f $ippath ]]; then
    cat $ippath | xargs -L1 echo "Public IP: "
else
    echo "Public IP:  Not found!"  
fi
if [[ -f $uptimepath ]]; then
    printf "Uptime:     " && awk '{print int($1/3600)":"int(($1%3600)/60)":"int($1%60)}' $uptimepath
    else
    echo "Uptime:     Not found!"  
fi
if [[ ! -f $refidpath ]]; then
    echo "Ref ID:     Not found!"
else
    cat $refidpath | xargs -L1 echo "Ref ID:    "
fi
printf "${PRL}============================ Config Overview ============================ \n${NC}"
printf "${GRN}"
grep 'model_detection' -A1 $configpath | grep -v 'model_detection' | xargs -L1
printf "${NC}"
if grep -q 'Antminer X' $configpath; then
        printf "EEPROM = ${RED}Model Detection Failed${NC}\n"
else
        printf "EEPROM = ${GRN}Model Detection OK${NC}\n"
fi
echo " "
cat -s $configpath | xargs -L1
printf "${PRL}============================ Mining Overview ============================ \n${NC}"
if [[ -f "$profilepath" ]]; then
        printf "${GRN}Saved Profiles found:\n${NC}"
        json=$(cat $profilepath)
        # Use jq to extract the "Power" values
        powers=$(echo $json | jq '.boards[].profile_target.Power'
        )
        echo $powers 

else
        printf "${YEL}No saved profile\n${NC}"
fi
echo " "
if grep -q 'Antminer S\|Antminer T' $configpath; then
         # Power limits
        printf "${BLU}"
        grep -Eo '^miner_power{socket="N/A",type="estimated"}\s(\d.*)\s\d.*' $metricspath | tail -n 1 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Estimated(W):     "
        done <tmp && rm tmp
        grep -Eo '^miner_power_target_w{active="1",type="current"}\s(\d.*)\s\d.*' $metricspath | tail -n 1 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Current(W):       "
        done <tmp && rm tmp
        printf "${NC}"
        grep -Eo '^hashboard_power{hashboard=\".*\",type="estimated"}\s(\d.*)\s\d.*' $metricspath | tail -n 3 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "HBs Estimated(W): "
        done <tmp && rm tmp
        # Hashboards chips count
        printf "${BLU}"
        grep -Eo '^chips_discovered{hashboard=\".*\"}\s(\d.*)\s\d.*' $metricspath | tail -n 3 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Hashboard Chips:  "
        done <tmp && rm tmp
        # Fans RPM
        printf "${NC}"
        grep -Eo '^fan_speed_control\s(\d.*)\s\d.*' $metricspath | tail -n 1 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Fans Speed % :    "
        done <tmp && rm tmp
        grep -Eo '^fan_rpm_feedback{idx=\".*\"}\s(\d.*)\s\d.*' $metricspath | tail -n 4 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Fans Speed RPM:   "
        done <tmp && rm tmp 
        # Hashboards temperature
        printf "${BLU}"
        grep -Eo '^hashboard_temperature{hashboard=\".*\",type="raw"}\s(\d.*)\s\d.*' $metricspath | head -n 3 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Hashboard Temp:   "
        done <tmp && rm tmp
        # Nominal Hashrate
        # printf "${NC}"
        # grep -Eo '^hashboard_nominal_hashrate_gigahashes_per_second{hashboard=\".*\"}\s(\d.*)\s\d.*' $metricspath | head -n 3 >tmp
        # while read -r line; do
        #         echo $line | cut -d " " -f 2 | xargs -n1 echo "Nominal HR(GH/s): "
        # done <tmp && rm tmp
        # Tuenr Iteration
        printf "${NC}"
        grep -Eo '^tuner_iteration{hashboard=\".*\"}\s(\d.*)\s\d.*' $metricspath | tail -n 3 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Tuner Iteration:  "
        done <tmp && rm tmp
         printf "${BLU}"
        grep -Eo '^tuner_stage{hashboard="3"}\s(\d.*)\s\d.*' $metricspath | tail -n 1 >tmp
        while read -r line; do
                echo $line | cut -d " " -f 2 | xargs -n1 echo "Tuner Stage:      "
        done <tmp && rm tmp
else
        printf "${YEL}There is no metrics data due to failed model detection!${NC}\n"
fi
printf "${PRL}============================== Ping Report ============================== \n${NC}"
if [[ ver == 2101 ]]; then
    sed -n 17,25p $pingpath
else    
    sed -n 5,9p $pingpath
fi
printf "${PRL}============================== Logs Report ============================== \n${NC}"
grep -c 'ERROR' $logpath | xargs -L1 echo "Errors: "
grep -c 'WARN' $logpath | xargs -L1 echo "Warns:  "
printf "${RED}::Last ERROR: "
grep -m1 'ERROR' $logpath | xargs -L1
echo " "
printf "${YEL}::Last WARN: "
grep -m1 'WARN' $logpath | xargs -L1
echo " "
printf "${CYN}::Smart Search: "
grep -m1 'Shutdown' -e 'DANGEROUS' -e 'Init failed' -e 'panicked' -e 'NoChipsDetected' -e 'BUG' $logpath  | xargs -L1
printf "${NC} \n"
printf "${PRL}===============================================================\n${NC}"
######## Flag -d Review logs ########
if [[ $deep == 1 ]]; then
read -p "Do you want to review ERROR logs [Default is (y)es]? " error_log
error_log=${error_log:-y}
if [[ $error_log == y ]]; then
        printf "${RED}::ERROR:\n"
        grep 'ERROR' $logpath | sort -u
fi
printf "${NC}========================================================================\n"
read -p "Do you want to review WARN logs [Default is (y)es]? " warn_log
warn_log=${warn_log:-y}
if [[ $warn_log == y ]]; then
        printf "${YEL}\n::WARN:\n"
        grep 'WARN' $logpath | sort -u
fi
printf "${NC}========================================================================\n"
    read -p "Do you want to review 'compressed' ERROR logs [Default is (y)es]? " cerror_log
    cerror_log=${cerror_log:-y}
    if [[ $cerror_log == y ]]; then
            printf "${RED}\n::ERROR:\n"
            if ls $loggzpath 1> /dev/null 2>&1; then
                    zgrep -h "ERROR" $(ls -tr $loggzpath) | sort -u
            else
                    echo "There is no compressed bosminer.log files"
            fi
    fi
    printf "${NC}========================================================================\n"
    read -p "Do you want to review 'compressed' WARN logs [Default is (y)es]? " cwarn_log
    cwarn_log=${cwarn_log:-y}
    if [[ $cwarn_log == y ]]; then
            printf "${YEL}\n::WARN:\n"
            if ls $loggzpath 1> /dev/null 2>&1; then
                    zgrep -h "WARN" $(ls -tr $loggzpath) | sort -u
            else
                    echo "There is no compressed bosminer.log files"
            fi
    fi
    printf "${NC}=======================================================================\n"
fi
######## Flag -s Detect notable events in the logs ########
if [[ $smart == 1 ]]; then
read -p "Do you want to show notable events [Default is (y)es]? " notable
notable=${notable:-y}
if [[ $notable == y ]]; then
        printf "${CYN}"
        grep -e 'Shutdown' -e 'shutdown' -e 'DANGEROUS' -e 'Init failed' -e 'panicked' -e 'NoChipsDetected' -e 'BUG' $logpath | sort -u
fi
        printf "${NC}=======================================================================\n"
fi
####### Flag -c to open bosminer.log file in VScode ######
if [[ $code == 1 ]]; then
read -p "Do you want to open logs automatically on VSCode [Default is (y)es]? " open_auto
open_auto=${open_auto:-y}
if [[ $open_auto == y ]]; then
        open -a "Visual Studio Code" $logpath && open -a "Visual Studio Code"
fi
fi