Add new revamped brcon-countdown script. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 1471ecccb7580cffdcd0d10e58562c875fda1ca0 | |
parent ddef9880f96f2d8a0d9290a2a94ab77e59dfb46c | |
Author: Annna Robert-Houdin <[email protected]> | |
Date: Thu, 13 May 2021 22:35:38 +0200 | |
Add new revamped brcon-countdown script. | |
Diffstat: | |
A brcon-countdown | 74 +++++++++++++++++++++++++++++… | |
1 file changed, 74 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/brcon-countdown b/brcon-countdown | |
@@ -0,0 +1,74 @@ | |
+#!/bin/sh | |
+ | |
+PATH="$HOME/bin:$PATH" | |
+ | |
+announcechannels="#bitreich-con #bitreich-en #bitreich-de #bitreich-fr #bitrei… | |
+schedulebase="/br/gopher/con/%s/index.gph" | |
+ | |
+function announce { | |
+ announcechannels="$1" | |
+ announcestr="$2" | |
+ | |
+ #echo "$announcestr" | |
+ annna-say -c "${announcechannels}" "${announcestr}" | |
+} | |
+ | |
+if [ $# -gt 0 ]; | |
+then | |
+ curdate="$1T00:00:00" | |
+else | |
+ curdate="$(date +%Y-%m-%d -d "00:00:00")" | |
+fi | |
+ | |
+year="$(date +%Y -d "${curdate}")" | |
+schedule="$(printf "${schedulebase}" "${year}")" | |
+ | |
+days="$(grep -E "^${year}-[0-9]{2}-[0-9]{2} - " "${schedule}" | cut -d' ' -f 1… | |
+fromdate="$(printf "%s\n" "${days}" | head -n 1)" | |
+todate="$(printf "%s\n" "${days}" | tail -n 1)" | |
+ | |
+daysuntil=$((($(date +%s -d "${fromdate}T00:00:00") - $(date +%s -d "${curdate… | |
+if [ $daysuntil -gt 0 ]; | |
+then | |
+ case "$daysuntil" in | |
+ 1) | |
+ daysstr="${daysuntil} day" | |
+ ;; | |
+ *) | |
+ daysstr="${daysuntil} days" | |
+ ;; | |
+ esac | |
+ announce "${announcechannels}" \ | |
+ "$(printf "%s until bitreichcon! gopher://bitreich.org/1/con/%… | |
+ "${daysstr}" "${year}")" | |
+ exit 0 | |
+fi | |
+ | |
+dayssince=$((($(date +%s -d "${curdate}") - $(date +%s -d "${todate}T00:00:00"… | |
+if [ $dayssince -gt 0 ]; | |
+then | |
+ [ $dayssince -gt 10 ] && exit 0 | |
+ | |
+ case "$dayssince" in | |
+ 1) | |
+ daysstr="${dayssince} day" | |
+ ;; | |
+ *) | |
+ daysstr="${dayssince} days" | |
+ ;; | |
+ esac | |
+ | |
+ announce "${announcechannels}" \ | |
+ "$(printf "It has been %s since bitreichcon. Are you still hap… | |
+ "${daysstr}")" | |
+ exit 0 | |
+fi | |
+ | |
+conferenceday=$((($(date +%s -d "${curdate}") - $(date +%s -d "${fromdate}T00:… | |
+daytopic="$(grep -E "^$(date +%Y-%m-%d -d"${curdate}") - " "${schedule}" | cut… | |
+announce "${announcechannels}" \ | |
+ "$(printf "Welcome to bitreichcon %s day %s ( %s )! Schedule: gopher:/… | |
+ "${year}" "${conferenceday}" "${daytopic}" "${year}")" | |
+ | |
+exit 0 | |
+ |