it works
This commit is contained in:
commit
382001ca80
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.env
|
||||
ramadan_added.png
|
BIN
ARLRDBD.TTF
Normal file
BIN
ARLRDBD.TTF
Normal file
Binary file not shown.
20
README.md
Normal file
20
README.md
Normal 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
7
env.sample
Normal 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
BIN
ramadan.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 818 KiB |
45
roadhfeshen.sh
Executable file
45
roadhfeshen.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user