46 lines
992 B
Bash
Executable File
46 lines
992 B
Bash
Executable File
#!/bin/bash
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
|
|
input=ramadan.png
|
|
output=ramadan_added.png
|
|
source .env
|
|
rm $output > /dev/null
|
|
|
|
# Get today's date in seconds since the epoch
|
|
today=$(date +%s)
|
|
# Get the target date in seconds since the epoch
|
|
target=$(date -d "$1" +%s)
|
|
# Calculate the number of seconds between the two dates
|
|
diff=$(($target - $today))
|
|
|
|
# Only output the number of days if the target date is in the future
|
|
if [ $diff -gt 0 ]
|
|
then
|
|
# Convert the number of seconds to days
|
|
days=$(($diff / 86400))
|
|
|
|
# Add a leading zero if the day count is less than 10
|
|
if [ $days -lt 10 ]
|
|
then
|
|
days=$(printf "%02d" $days)
|
|
fi
|
|
else
|
|
echo The day already passed...
|
|
exit
|
|
fi
|
|
|
|
# Set variables for processing
|
|
position=+350+560
|
|
fontsize=250
|
|
fontstyle=$PWD/ARLRDBD.TTF
|
|
color='#be954a'
|
|
|
|
convert $input \
|
|
-font $fontstyle \
|
|
-pointsize $fontsize \
|
|
-fill $color \
|
|
-annotate $position $days \
|
|
$output
|
|
|
|
curl -s -F photo=@$output $TG_BOTAPI$TG_BOT_TOKEN/sendphoto?chat_id=$TG_CHATID
|