This commit is contained in:
Shihaam Abdul Rahman 2023-02-14 10:47:43 +05:00
commit 382001ca80
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
6 changed files with 74 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
ramadan_added.png

BIN
ARLRDBD.TTF Normal file

Binary file not shown.

20
README.md Normal file
View File

@ -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
```

7
env.sample Normal file
View File

@ -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'

BIN
ramadan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 KiB

45
roadhfeshen.sh Executable file
View File

@ -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