Skip to content

Instantly share code, notes, and snippets.

@yumusb
Last active February 9, 2023 07:33
Show Gist options
  • Save yumusb/1c27091a0b9433c2749b7d2d7bff24fc to your computer and use it in GitHub Desktop.
Save yumusb/1c27091a0b9433c2749b7d2d7bff24fc to your computer and use it in GitHub Desktop.
判断是否可用openai
if [[ $(curl -sS https://chat.openai.com/ -I | grep "text/plain") != "" ]]
then
echo "IP被BAN"
else
iso2_code=$(curl -sS https://chat.openai.com/cdn-cgi/trace | grep "loc=" | awk -F= '{print $2}')
country=$(curl -sS https://raw.githubusercontent.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all/all.csv | grep ",$iso2_code," | awk -F, '{print $1}')
country=$(echo ${country/\"/})
if [[ $(curl -sS "https://openaiapi-site.azureedge.net/public-assets/d/7f4419c385/static/js/main.3133adcb.js" | grep "\"${country}\"") != "" ]]
then
echo "可正常使用"
else
echo "地域不支持,被CloudFlare识别为:${country} \n可用地域列表:https://platform.openai.com/docs/supported-countries"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment