#!/bin/bash
[ "$4" == "" ] && exec echo "Usage: $0 <TAG_NAME> <MESSAGES_CONTENT> <TIME_TYPE> <TIME_INTERVAL>"

source $HOME/.gamerc

TAG_NAME=$1
MESSAGE_CONTENT=$2
TIME_TYPE=$3
TIME_INTERVAL=$4

if [[ -n "${EXEC_SOURCE}" ]]; then
    send_chatbot_text_only_by_thread_tag "${TAG_NAME}" "網頁工具操作" "${MESSAGE_CONTENT}" "${TIME_TYPE}" "${TIME_INTERVAL}"
else
    LOGIN_USER=$(who -m|awk '{print $1}')
    if [[ ! -z "${LOGIN_USER}" ]]; then
        send_chatbot_text_only_by_thread_tag "${TAG_NAME}" "系統腳本" "${MESSAGE_CONTENT}" "${TIME_TYPE}" "${TIME_INTERVAL}"
    #else
    #    send_chatbot_text_only_by_thread_tag "${TAG_NAME}" "Cron 排程" "${MESSAGE_CONTENT}" "${TIME_TYPE}" "${TIME_INTERVAL}"
    fi
fi
    
