5
5
mirror of https://github.com/trueChristian/daily-light.git synced 2024-11-28 23:16:27 +00:00
daily-light/src/today.sh

106 lines
4.1 KiB
Bash
Raw Normal View History

2021-04-30 02:19:29 +00:00
#!/bin/bash
#█████████████████████████████████████████████████████████████ SCRIPT PATH ███
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#█████████████████████████████████████████████████████████████ DAILY LIGHT ███
DAILY="$DIR/Daily_Light"
#████████████████████████████████████████████████████████████ MORNING KEYS ███
M_TIME_M=2
M_TIME_V=3
M_TIME_N="Morning"
#████████████████████████████████████████████████████████████ EVENING KEYS ███
E_TIME_M=4
E_TIME_V=5
E_TIME_N="Evening"
#█████████████████████████████████████████████████████████████████████ DAY ███
2021-05-04 04:02:50 +00:00
TODAY=$(TZ="Africa/Windhoek" date '+%B-%d')
TODAY_DATE=$(TZ="Africa/Windhoek" date '+%A %d-%B, %Y')
2021-04-30 02:19:29 +00:00
#███████████████████████████████████████████████████████ GET TODAY'S LIGHT ███
LIGHT=$(grep "${TODAY,,}" "${DAILY}");
#█████████████████████████████████████████████████████████████ FORMAT TEXT ███
IFS='|' read -ra DAILYLIGHT <<< "${LIGHT}"
# Get Morning Message
IFS='+' read -ra DAILYLIGHTARRAY_M <<< "${DAILYLIGHT[$M_TIME_M]}"
DAILYLIGHT_M_M=$( IFS=$'\n'; echo "${DAILYLIGHTARRAY_M[*]}" )
# Get Evening Message
IFS='+' read -ra DAILYLIGHTARRAY_E <<< "${DAILYLIGHT[$E_TIME_M]}"
DAILYLIGHT_M_E=$( IFS=$'\n'; echo "${DAILYLIGHTARRAY_E[*]}" )
#████████████████████████████████████████████ SET TODAY'S MESSAGES IN HTML ███
2021-05-04 04:02:50 +00:00
MORNING="<i><u>${M_TIME_N}</u></i>
${DAILYLIGHT_M_M}
2021-04-30 02:19:29 +00:00
2021-05-04 04:02:50 +00:00
<strong>${DAILYLIGHT[$M_TIME_V]}</strong>"
EVENING="<i><u>${E_TIME_N}</u></i>
${DAILYLIGHT_M_E}
<strong>${DAILYLIGHT[$E_TIME_V]}</strong>"
TELEGRAM_LINK="
<a id=\"daily-light-link\" href=\"https://t.me/daily_light\">${TODAY_DATE}</a>"
2021-04-30 02:19:29 +00:00
#████████████████████████████████████████ SET TODAY'S MESSAGES IN MARKDOWN ███
2021-05-04 04:02:50 +00:00
DAILYLIGHT_M_M="${DAILYLIGHT_M_M/<strong>/**}"
DAILYLIGHT_M_M="${DAILYLIGHT_M_M/<\/strong>/**}"
MORNING_MD="**${M_TIME_N}**
2021-04-30 02:19:29 +00:00
2021-05-04 04:02:50 +00:00
${DAILYLIGHT_M_M}
2021-04-30 02:19:29 +00:00
**${DAILYLIGHT[$M_TIME_V]}**"
2021-05-04 04:02:50 +00:00
DAILYLIGHT_M_E="${DAILYLIGHT_M_E/<strong>/**}"
DAILYLIGHT_M_E="${DAILYLIGHT_M_E/<\/strong>/**}"
EVENING_MD="**${E_TIME_N}**
2021-04-30 02:19:29 +00:00
2021-05-04 04:02:50 +00:00
${DAILYLIGHT_M_E}
2021-04-30 02:19:29 +00:00
**${DAILYLIGHT[$E_TIME_V]}**"
TELEGRAM_LINK_MD="
[${TODAY_DATE}](https://t.me/daily_light)"
#███████████████████████████████████████████████████████████████ SET FILES ███
2021-04-30 02:58:09 +00:00
echo "${MORNING}${TELEGRAM_LINK}" > morning.html
echo "${EVENING}${TELEGRAM_LINK}" > evening.html
2021-04-30 02:19:29 +00:00
2021-04-30 02:58:09 +00:00
echo "${MORNING_MD}${TELEGRAM_LINK_MD}" > morning.md
echo "${EVENING_MD}${TELEGRAM_LINK_MD}" > evening.md
2021-04-30 02:19:29 +00:00
#██████████████████████████████████████████████████████████████ SET README ███
2021-05-04 04:02:50 +00:00
echo "# ${M_TIME_N}
${DAILYLIGHT_M_M}
**${DAILYLIGHT[$M_TIME_V]}**
# ${E_TIME_N}
${DAILYLIGHT_M_E}
2021-04-30 02:19:29 +00:00
2021-05-04 04:02:50 +00:00
**${DAILYLIGHT[$E_TIME_V]}**
2021-04-30 02:19:29 +00:00
---
[${TODAY_DATE}](https://t.me/s/daily_light)
> Jonathan Bagster, the son of Samuel Bagster, created the Daily Light for his own family's daily devotion in 1875
2021-04-30 02:58:09 +00:00
" > README.md
git commit -am"${TODAY_DATE}"
git push
exit 0