Skip to content

Commit

Permalink
smol fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marczeller committed Aug 12, 2024
1 parent 61bfade commit ee14fba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ cache_hardhat/

# Misc
*.log
*.bak
*.bak.env
15 changes: 10 additions & 5 deletions dolce_vita_collector_with_notifications.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#!/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

# 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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit ee14fba

Please sign in to comment.