#!/bin/bash
source $HOME/.gamerc

[ "$1" == "" ] && exec echo "Usage: $0 <FILE_EXTENSIONS_1> <FILE_EXTENSIONS_2> ..."

LOG_OUTPUT="/tmp/check_client_file_should_not_exist_monitor.log"

FILELIST="$HOME/bin/FullFileList_${GAME_TYPE}${COUNTRY_CODE_DISPLAY}.txt"

GREP_STR=""
for extension in $*; do
	GREP_STR="${GREP_STR}\.${extension}|"
done
GREP_STR=$(echo ${GREP_STR}|sed 's/|$//')

egrep -a ${GREP_STR} ${FILELIST} > ${LOG_OUTPUT}

# 如果輸出的 LOG 檔案有內容, 則發送訊息到 API, 請機器人送群組
LOG_SIZE=$(stat --printf="%s" ${LOG_OUTPUT})

# 發送當下時間
DATETIME=$(date +"%Y-%m-%d %T %Z")

if [ "${LOG_SIZE}" -gt 0 ]; then
	send_messages ERROR check_client_file_should_not_exist "Client Patch 包版檔案錯誤 請確認"
fi
