diff --git a/.env.example b/.env.example index 7e9a9bf..56040a0 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,10 @@ PRIVATE_KEY=your_private_key_here SENDER=YOUR_ADDRESS +# Telegram Bot configuration +TELEGRAM_BOT_TOKEN=your_bot_token_here +TELEGRAM_CHAT_ID=your_chat_id_here + # RPC Endpoints (Replace with your own endpoints if necessary) RPC_MAINNET=http://your_mainnet_rpc_endpoint RPC_AVALANCHE=https://api.avax.network/ext/bc/C/rpc diff --git a/.gitignore b/.gitignore index 40c42c0..cb17b55 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ cache_hardhat/ # Misc *.log -*.bak \ No newline at end of file +*.bak.env diff --git a/dolce_vita_collector_with_notifications.sh b/dolce_vita_collector_with_notifications.sh index 528bf73..caff8b0 100755 --- a/dolce_vita_collector_with_notifications.sh +++ b/dolce_vita_collector_with_notifications.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Get the directory of the script +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# Load environment variables +source "$SCRIPT_DIR/.env" + LOG_DIR="/var/log/dolce_vita_collector" COUNTER_FILE="${LOG_DIR}/counter.log" MAX_LINES=2000 @@ -7,13 +13,12 @@ MAX_LINES=2000 # Function to send Telegram messages send_telegram_message() { local message=$1 - local bot_token="7292479786:AAGb1isSfJpjRpIsgGzwYy6GalIIc6-jNqI" - local chat_id="253560971" - curl -s -X POST "https://api.telegram.org/bot$bot_token/sendMessage" -d chat_id="$chat_id" -d text="$message" + curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" -d chat_id="$TELEGRAM_CHAT_ID" -d text="$message" } # Initialize the counter and date if they don't exist if [ ! -f $COUNTER_FILE ]; then + mkdir -p "$LOG_DIR" echo "Loop Counter: 0" > $COUNTER_FILE echo "Last Run: Never" >> $COUNTER_FILE fi @@ -48,7 +53,7 @@ fi send_telegram_message "🚀 Starting Dolce Vita Collector $run_type script. Loop Counter: $counter. Last Run: $current_date" # Run the original script - if /home/mzeller/dolce_vita_collector/dolce_vita_collector.sh "$@"; then + if "$SCRIPT_DIR/dolce_vita_collector.sh" "$@"; then echo "🎉 Dolce Vita Collector $run_type script completed successfully." send_telegram_message "🎉 Dolce Vita Collector $run_type script completed successfully. Loop Counter: $counter." else @@ -61,4 +66,4 @@ fi # Concatenate the counter file and the log file cat $COUNTER_FILE $log_file > $log_file.tmp && mv $log_file.tmp $log_file -} | ts '[%Y-%m-%d %H:%M:%S]' >> $log_file +} | ts '[%Y-%m-%d %H:%M:%S]' >> $log_file \ No newline at end of file