yellow='\033[1;33m'
green='\033[1;32m'
blue='\033[1;34m'
red='\033[1;31m'
reset='\033[0m'


WIDTH=56


get_spaces() {

    printf "%*s" "$1" ""
}


echo_center() {
    text="$1"
    color="$2"
    

    spaces=$(( (WIDTH - ${#text}) / 2 ))

    printf "${color}$(get_spaces $spaces)${text}$(get_spaces $spaces)${reset}\n" >&2
    

    [ $((WIDTH % 2)) -ne $(( ${#text} % 2 )) ] && printf " \b" >&2
}


echo_separator() {
    color="$1"
    char="$2"
    
    
    separator=$(get_spaces $WIDTH | tr ' ' "$char")
    printf "${color}${separator}${reset}\n" >&2
}


if [ "$(whoami)" != "root" ]; then
    clear
    echo_separator "$red" "="
    echo_center "错误：必须用 root 运行！" "$red"
    echo_center "错误：Permission denied！" "$red"
    echo_separator "$red" "="
    exit 1
fi


clear
echo_separator "$blue" "="
echo_center "117公益过验证工具" "$yellow"
echo_separator "$blue" "="
echo_center "已获取 root 权限，运行开始！" "$green"


mkdir -p /data/media/0/Android/data/org.telegram.messenger.web/cache


clear
echo_separator "$blue" "="
echo_center "BY公益过验证工具" "$yellow"
echo_separator "$blue" "="
echo_center "正在创建过验证文件..." "$green"
sleep 1


echo "117公益 - 频道：@WO117WO" > /data/media/0/Android/data/org.telegram.messenger.web/cache/-6168116093177150640_99.jpg


clear
echo_separator "$green" "="
echo_center "过验证成功！" "$green"
echo_center "官方频道：@BY520A" "$green"
echo_separator "$green" "="

echo_center "请保持此频道订阅状态以继续使用！" "$yellow"
echo ""
echo_center "按任意键退出..." "$blue"

read -n 1 -s

exit 0
