#!/bin/bash
[ "$6" == "" ] && exec echo "Usage: $0 <MESSAGES_TYPE> <MESSAGES_LOG_NAME> <MESSAGES_TITLE> <TAG_NAME> <TIME_TYPE> <TIME_INTERVAL>"

source $HOME/.gamerc

MESSAGES_TYPE="$1"
MESSAGES_LOG_NAME="$2"
MESSAGES_TITLE="$3"
TAG_NAME="$4"
TIME_TYPE="$5"
TIME_INTERVAL="$6"

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