commit 382001ca80e26c738edbca61c6818250bfe16876 Author: Shihaam Abdul Rahman Date: Tue Feb 14 10:47:43 2023 +0500 it works diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..380b9d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +ramadan_added.png diff --git a/ARLRDBD.TTF b/ARLRDBD.TTF new file mode 100644 index 0000000..20b92a2 Binary files /dev/null and b/ARLRDBD.TTF differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..78a0567 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Roadhafeshen + + +# Getting started + +```bash +git clone https://git.shihaam.dev/shihaam/roadhafeshen.git +cd roadhafeshen +chmod +x roadhafeshen.sh +cp env.sample .env +$EDITOR .env # add telegram chatid and botapikey +``` + +## Usage +- Script takes a date in "YYYY-MM-DD" format as an argument. +```bash +./roadhafeshen.sh 2023-01-23 +``` + + diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..97b3a77 --- /dev/null +++ b/env.sample @@ -0,0 +1,7 @@ +# Telegram Config +TG_BOT_TOKEN='' #Your Telegram Bot API Token, Contact @BotFather on Telegram to obtain token +TG_CHATID='' #Your Telegram chat ID, This could be your user, group, supergroup or channel ID, add "-100" first if supergroup or channel + +# DO NOT EDIT THESE UNLESS YOU KNOW WHAT YOURE DOING +TG_BOTAPI='https://api.telegram.org/bot' + diff --git a/ramadan.png b/ramadan.png new file mode 100644 index 0000000..b6904d8 Binary files /dev/null and b/ramadan.png differ diff --git a/roadhfeshen.sh b/roadhfeshen.sh new file mode 100755 index 0000000..0e23d66 --- /dev/null +++ b/roadhfeshen.sh @@ -0,0 +1,45 @@ +#!/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