🌟 Github Action과 시스템 올 그린! 발진 준비완료!
This commit is contained in:
parent
2ba9b8ee32
commit
3a888af951
5 changed files with 53 additions and 7 deletions
31
app/gen-config.sh
Normal file
31
app/gen-config.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Required environment variables
|
||||||
|
required_vars=("BOT_ROOT" "BOT_INSTAGRAM_ID" "BOT_INSTAGRAM_PASSWORD" "BOT_KEY" "BOT_WEBHOOK_URL")
|
||||||
|
|
||||||
|
# Check for missing environment variables
|
||||||
|
missing_vars=()
|
||||||
|
for var in "${required_vars[@]}"; do
|
||||||
|
if [ -z "${!var}" ]; then
|
||||||
|
missing_vars+=("$var")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#missing_vars[@]} -ne 0 ]; then
|
||||||
|
echo "Error: Missing required environment variables:"
|
||||||
|
printf '%s\n' "${missing_vars[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate config.json
|
||||||
|
cat > config.json << EOF
|
||||||
|
{
|
||||||
|
"ROOT": "${BOT_ROOT}",
|
||||||
|
"INSTAGRAM_ID": "${BOT_INSTAGRAM_ID}",
|
||||||
|
"INSTAGRAM_PASSWORD": "${BOT_INSTAGRAM_PASSWORD}",
|
||||||
|
"KEY": "${BOT_KEY}",
|
||||||
|
"WEBHOOK_URL": "${BOT_WEBHOOK_URL}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Successfully generated config.json"
|
||||||
|
|
@ -9,10 +9,15 @@ with open('./config.json') as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
|
|
||||||
ROOT = json_data['ROOT']
|
ROOT = json_data['ROOT']
|
||||||
INSTAGRAM_AUTH = [json_data['INSTAGRAM_ID'], json_data['INSTAGRAM_PASSWORD']]
|
INSTAGRAM_AUTH = [json_data['INSTAGRAM_ID'], json_data['INSTAGRAM_PASSWORD'], json_data['INSTAGRAM_TOTP']]
|
||||||
|
|
||||||
|
|
||||||
cl = Client()
|
cl = Client()
|
||||||
cl.login(INSTAGRAM_AUTH[0], INSTAGRAM_AUTH[1])
|
code = cl.totp_generate_code(INSTAGRAM_AUTH[2])
|
||||||
|
cl.login(INSTAGRAM_AUTH[0], INSTAGRAM_AUTH[1], verification_code=code)
|
||||||
|
cl.set_timzone_offset(9 * 60 * 60)
|
||||||
|
cl.set_user_agent('Instagram 361.0.0.46.88 Android (35/15; 394dpi; 1084x2412; Nothing; A065; Pong; qcom; ko_KR_#u-fw-sun-mu-celsius; 674675147)')
|
||||||
|
cl.get_settings()
|
||||||
|
|
||||||
json.dump(
|
json.dump(
|
||||||
cl.get_settings(),
|
cl.get_settings(),
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,9 @@ def 급식_칼로리_얻기(MLSV_YMD:str):
|
||||||
|
|
||||||
|
|
||||||
def 얻기(MLSV_YMD:str):
|
def 얻기(MLSV_YMD:str):
|
||||||
|
print("집가고싶다발동")
|
||||||
급식 = 급식_정보_얻기(MLSV_YMD)
|
급식 = 급식_정보_얻기(MLSV_YMD)
|
||||||
print(f"{ROOT}library/skeleton.png")
|
# print(f"{ROOT}library/skeleton.png")
|
||||||
사진 = Image.open(f"{ROOT}library/skeleton.png")
|
사진 = Image.open(f"{ROOT}library/skeleton.png")
|
||||||
|
|
||||||
#if vts.get_vts_true_or_false() == True: 사진 = Image.open(f'{ROOT}library/skeleton-vts.png')
|
#if vts.get_vts_true_or_false() == True: 사진 = Image.open(f'{ROOT}library/skeleton-vts.png')
|
||||||
|
|
@ -65,6 +66,7 @@ def 얻기(MLSV_YMD:str):
|
||||||
print("🍲 | Meal Info Image Saved")
|
print("🍲 | Meal Info Image Saved")
|
||||||
|
|
||||||
def 스토리_얻기(MLSV_YMD:str):
|
def 스토리_얻기(MLSV_YMD:str):
|
||||||
|
print("이건 왜?")
|
||||||
# 1:1 to 9:16 temp/{MLSV_YMD}.png
|
# 1:1 to 9:16 temp/{MLSV_YMD}.png
|
||||||
|
|
||||||
사진 = Image.open(f"{ROOT}temp/{MLSV_YMD}.png")
|
사진 = Image.open(f"{ROOT}temp/{MLSV_YMD}.png")
|
||||||
|
|
@ -112,4 +114,4 @@ def 디스코드(MLSV_YMD:str):
|
||||||
except requests.exceptions.HTTPError as err:
|
except requests.exceptions.HTTPError as err:
|
||||||
print(err)
|
print(err)
|
||||||
else:
|
else:
|
||||||
print(f"✨ | Payload successfully, code {result.status_code}.")
|
print(f"✨ | Payload successfully, code {result.status_code}.")
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ print("📅 | Getting MLSV_YMD Timestamp")
|
||||||
print("📅 | Date:", MLSV_YMD)
|
print("📅 | Date:", MLSV_YMD)
|
||||||
|
|
||||||
print("🍲 | Getting Meal Info Image")
|
print("🍲 | Getting Meal Info Image")
|
||||||
|
lib.얻기(MLSV_YMD)
|
||||||
|
|
||||||
lib.스토리_얻기(MLSV_YMD)
|
lib.스토리_얻기(MLSV_YMD)
|
||||||
print("📸 | Uploading Story")
|
print("📸 | Uploading Story")
|
||||||
|
|
|
||||||
13
app/run.sh
13
app/run.sh
|
|
@ -1,3 +1,10 @@
|
||||||
|
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||||||
|
echo "Debug: Script started at $(date)" >> /code/app/temp/debug.log
|
||||||
|
echo "Debug: Current directory is $(pwd)" >> /code/app/temp/debug.log
|
||||||
|
echo "Debug: User is $(whoami)" >> /code/app/temp/debug.log
|
||||||
|
echo "Debug: Environment variables:" >> /code/app/temp/debug.log
|
||||||
|
env >> /code/app/temp/debug.log
|
||||||
|
|
||||||
cd /code/app
|
cd /code/app
|
||||||
|
|
||||||
# If doesn't have temp folder, create it
|
# If doesn't have temp folder, create it
|
||||||
|
|
@ -7,7 +14,7 @@ fi
|
||||||
|
|
||||||
# If doesn't have temp/cookies.json, create it
|
# If doesn't have temp/cookies.json, create it
|
||||||
if [ ! -f "temp/cookies.json" ]; then
|
if [ ! -f "temp/cookies.json" ]; then
|
||||||
python3 library/init-auth.py
|
/code/app/venv/bin/python3 library/init-auth.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the log file name with the current date and time
|
# Set the log file name with the current date and time
|
||||||
|
|
@ -15,7 +22,7 @@ log_file="temp/$(date +%Y%m%d-%H%M%S).log"
|
||||||
|
|
||||||
# Run the Python script with or without --today and output to both the console and log file
|
# Run the Python script with or without --today and output to both the console and log file
|
||||||
if [[ "$1" == "--today" ]]; then
|
if [[ "$1" == "--today" ]]; then
|
||||||
python3 run.py --today | tee "$log_file"
|
/code/app/venv/bin/python3 run.py --today | tee "$log_file"
|
||||||
else
|
else
|
||||||
python3 run.py | tee "$log_file"
|
/code/app/venv/bin/python3 run.py | tee "$log_file"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue